見出し画像

話題のAutoGPTをローカルで動かして、「おすすめテント」を探してもらう(ブラウザで試す方法も記載)

はじめに

こんにちは。エクスプラザ代表の kazuki @vvxo です。GPTを完全自動で動かすことができるAutoGPT (https://autogpt.net/) が話題ですね。今回はAutoGPTを動かす方法と、試した事例について紹介しようと思います。

※ 内容は、2023年4月時点のものです

AutoGPTについて

Auto GPT is an experimental open-source application that showcases the capabilities of the GPT-4 language model. It is designed to help businesses increase their net worth by providing intelligent recommendations and insights into their current processes. Auto GPT is one of the first examples of GPT-4 running autonomously, and it pushes the boundaries of what is possible with AI.

https://autogpt.net/autogpt-step-by-step-full-setup-guide/

公式曰く、AutoGPTは「GPT-4の実験的なオープンソースアプリケーション」とのことです。目的としては企業の純資産増のための提案などを行うためのものとのことです。ですが、今回はちょっと消費者向けっぽい使い方をしてみます。

使い方・インストール

上記の公式サイトを参考にしています。

必要な環境

  • 必須

    • Python 3.8 or later

    • OpenAI API key

    • Pinecone API key

      • ※ AI に長期記憶させるためのサービス。サイトには必須項目に入ってましたが、なくても動くは動きました

  • (任意)

    • Google API ※ Google 検索を利用したい場合

    • ElevenLabs Key ※ AI音声生成ツールを使用したい場合

インストール

1. コマンドラインで git clone する

git clone https://github.com/Torantulino/Auto-GPT.git

2. ディレクトリ移動 → 指定の txt をインストール

cd 'Auto-GPT'
pip install -r requirements.txt

3. ".env.template" を ".env" にリネームし、".env" をエディタで開き以下を埋める

実行〜試してみた

1. コマンドライン等で以下を実行

python scripts/main.py

2. AIのAI Name(名前)を決める 

Welcome to Auto-GPT!  Enter the name of your AI and its role below. Entering nothing will load defaults.
Name your AI:  For example, 'Entrepreneur-GPT'
AI Name: Tent-Search-AI-v1 

ここはなんでもいいです。今回はおすすめのキャンプテントを探すAIを作ってみようと思うので、"Tent-Search-AI-v1"としてみました。

3. AIのRole(=目的)を指定する 

Tent-Search-AI-v1 here!  I am at your service.
Describe your AI's role:  For example, 'an AI designed to autonomously develop and run businesses with the sole goal of increasing your net worth.'
Tent-Search-AI-v1 is: あなたはおすすめのキャンプ用テントをユーザーに紹介するAIです。ユーザーのテントに対する好みを聞き出し、好みに応じてGoogleでテントの検索をかけてください。検索した結果、いくつかのページを読み込み、ユーザーが好むであろうテントを商品名で紹介してください。

この部分がプロンプトになります。

今回は "あなたはおすすめのキャンプ用テントをユーザーに紹介するAIです。ユーザーのテントに対する好みを聞き出し、好みに応じてGoogleでテントの検索をかけてください。検索した結果、いくつかのページを読み込み、ユーザーが好むであろうテントを商品名で紹介してください。" と入力してみました。

4. 個別のGoalを指定する(任意)

Enter up to 5 goals for your AI:  For example: Increase net worth, Grow Twitter Account, Develop and manage multiple businesses autonomously'
Enter nothing to load defaults, enter nothing when finished.
Goal 1: 

このAIが (3) のRoleに合わせて行うべきGoal(タスク)を順番に5つまで設定できます。 (3) がきちんと書けているのであればここはEnterを押してそのままスキップしてもらっても構いません。

今回は (3) のプロンプトに賭けて、Goal設定をせずそのままEnterで実行してみます。

5. AutoGPTが動く (1) 

Using memory of type: LocalCache
TENT-SEARCH-AI-V1 THOUGHTS:  I think the best next command for me to use is "google" to search for tents that match the user's preference.
REASONING:  Since the user is looking for a specific type of tent that fits their preferences, I can use Google search to obtain a list of relevant tents. This will provide me with a starting point to look for information on the user's preferred type of tent.
PLAN: 
-  Use the "google" command to search for tents.
-  Evaluate the search results and choose relevant pages to browse.
-  Use the "browse_website" command to browse the websites for information on the user's preferred type of tent.
-  Narrow down the search results to a subset of recommended tents based on the user's preferences.
CRITICISM:  I should avoid relying solely on the search results and ensure that I do an adequate evaluation of the pages before making recommendations.
Attempting to fix JSON by finding outermost brackets 
Apparently json was fixed. 
NEXT ACTION:  COMMAND = google ARGUMENTS = {'input': 'Tents good for mountain camping'}
Enter 'y' to authorise command, 'y -N' to run N continuous commands, 'n' to exit program, or enter feedback for Tent-Search-AI-v1...

まず 1回目の処理が表示されました。

THOUGHTS : 考えていること
REASONING : なぜそう考えたか
PLAN : これからやろうとしていること
CRITICISM : 一方で、批判的に考えていること
NEXT ACTION : 次に実行すること

といった具合にAIが考えていることが表示されます。

'y' を押すとNEXT ACTIONに書かれているCOMMANDが実行されます。ここで'y -N' を押せば N回分このあと実行しようとしているコマンドを勝手に実行し続けます。実行停止したい場合は 'n' を押せば停止します。

僕が試した事例でいくと、まずは「ユーザーの好みに合うテントをまずググるのがよさそう」と考えているみたい。'Tents good for mountain camping' というキーワードを"google" コマンドでググって、検索結果を元に "browse_website" コマンドでサイトをいくつか巡回して、一番いいテントを紹介してくれるみたいです。(すごい)

・・・というか、ユーザーの好みは僕に聞いてこない(これはちゃんとゴール設定させるとできます) & なぜか mountain camping (山キャンプ)に特化されているけど、まあいいか。

NEXT ACTION に COMMAND = google とあるので、'y' を押してコマンドを実行してもらいます。

5. AutoGPTが動く (2) 

Input:y
-=-=-=-=-=-=-= COMMAND AUTHORISED BY USER -=-=-=-=-=-=-= 
SYSTEM:  Command google returned: ['https://www.switchbacktravel.com/best-4-season-tents', 'https://gearjunkie.com/camping/tents/best-camping-tents', 'https://www.switchbacktravel.com/best-camping-tents', 'https://www.nytimes.com/wirecutter/reviews/best-tent-for-family-and-car-camping/', 'https://www.outdoorgearlab.com/topics/camping-and-hiking/best-camping-tent', 'https://mountainhouse.com/blogs/backpacking-hiking/buying-a-tent-for-camping-and-backpacking', 'https://www.outdoorgearlab.com/topics/camping-and-hiking/best-4-season-tent', 'https://talesofamountainmama.com/best-family-tents/']
TENT-SEARCH-AI-V1 THOUGHTS:  Now that I have a list of relevant websites, I should use the "browse_website" command to browse them for relevant information on mountain camping tents. I also need to determine what types of tents the user is interested in before proceeding further.
REASONING:  Browsing relevant websites will provide me with the necessary information on tents that are suitable for mountain camping. The types of tents the user is interested in will determine which tents to recommend.
PLAN: 
-  Use the "browse_website" command to browse the websites from the previous "google" command.
-  Analyze the content of each website that was relevant for mountain-camping tents.
-  Determine what types of tents the user is interested in.
-  Use the information gathered to recommend tents that fit the user's preferences.
CRITICISM:  I should ensure that I have a comprehensive understanding of the user's tent preferences before making recommendations so that the user will be satisfied with the suggested tents.
Attempting to fix JSON by finding outermost brackets 
Apparently json was fixed. 
NEXT ACTION:  COMMAND = browse_website ARGUMENTS = {'url': 'https://www.switchbacktravel.com/best-4-season-tents', 'question': 'What types of tents are recommended for mountain camping?'}
Enter 'y' to authorise command, 'y -N' to run N continuous commands, 'n' to exit program, or enter feedback for Tent-Search-AI-v1...

検索してみると、以下のページ等が見つかったみたいです。

さらに1つ目のページをブラウズしてみるみたいです。次のコマンド "browse_website" コマンドに進んでもらいます。

6. AutoGPTが動く (3) 

Input:y
-=-=-=-=-=-=-= COMMAND AUTHORISED BY USER -=-=-=-=-=-=-= 
Text length: 67564 characters
Summarizing chunk 1 / 9
Summarizing chunk 2 / 9
Summarizing chunk 3 / 9
Summarizing chunk 4 / 9
Summarizing chunk 5 / 9
Summarizing chunk 6 / 9
Summarizing chunk 7 / 9
Summarizing chunk 8 / 9
Summarizing chunk 9 / 9
Summarized 9 chunks.
SYSTEM:  Command browse_website returned: Website Content Summary: "Result" : Four-season tents are recommended for mountain camping, with different types of tents recommended for different environments such as mountaineering, basecamp, and treeline. Mountaineering tents are described as strong and lightweight with a small floor area, while basecamp and treeline tents are more comfortable and heavier with double-wall designs for better ventilation and space. It is important to consider factors such as weight, packed size, double-wall vs. single-wall designs, floor area, peak height and slope, and ventilation when choosing a 4-season tent for mountain camping. Double-wall designs tend to breathe better than single-wall tents, and heavy and durable fabrics such as those used in the Mountain Hardwear Trango are recommended for harsh weather conditions. Generally, all four-season tents are designed to withstand heavy wind, rain, and snow. Links: [' (#)', '\n\n (/)', 'Switchback Travel (/)', 'Ski\n (/ski-gear-reviews)', 'All-Mountain Skis\n (/best-all-mountain-skis)']
TENT-SEARCH-AI-V1 THOUGHTS:  Now that I have analyzed websites that include information about tents, types of tents and factors to consider, I will use the information I gathered to recommend some tents that would fit your preferences. I will message the GPT Agent with the details of each recommended tent, so that it can come up with a short summary of the tent for me to present to you.
REASONING:  Using the information gathered from the websites, I can choose some tents that will match the user's preference, allowing the GPT Agent to come up with a summary that I can present back to the user.
PLAN: 
-  Make use of the data obtained from the websites to generate a list of potential tents.
-  Message the GPT Agent with the details of each tent, so that it can generate a short summary of the tent.
-  Review the summaries generated by the GPT Agent before presenting them to the user.
CRITICISM:  I should ensure that I provide the necessary details about the potential tents to the GPT Agent, so that it can generate comprehensive summaries of the tents.
Attempting to fix JSON by finding outermost brackets 
Apparently json was fixed. 
NEXT ACTION:  COMMAND = message_agent ARGUMENTS = {'key': 'tent-recommendation', 'message': ['Mountain Hardwear Trango 2', 'The North Face Mountain 25', 'Marmot Thor 2 Person']}
Enter 'y' to authorise command, 'y -N' to run N continuous commands, 'n' to exit program, or enter feedback for Tent-Search-AI-v1...

指定したWebサイトの67,564文字のテキストを読み込んで、結果が出ました。Result の部分をDeepL和訳したものを下に書くと、

山でのキャンプにはフォーシーズンテントがおすすめで、登山用、ベースキャンプ用、トレラン用など環境に応じてテントの種類を変えています。登山用テントは床面積が小さく丈夫で軽量、ベースキャンプやトレラン用テントは通気性や広さを重視したダブルウォール仕様でより快適で重厚なテントと評されます。山キャンプ用の4シーズンテントを選ぶ際には、重量、パッキングサイズ、ダブルウォールとシングルウォールのデザイン、床面積、ピークの高さと傾斜、通気性などの要素を考慮することが重要です。ダブルウォールデザインはシングルウォールテントよりも通気性が良く、マウンテンハードウェア・トランゴに使われているような重くて丈夫な生地は、厳しい気象条件におすすめです。一般的に、4シーズンテントはどれも激しい風雨や雪に耐えられるように設計されています

それっぽい。文中にある「マウンテンハードウェア・トランゴ」はブラウズしたページ内にある「Mountain Hardwear Trango 3」という商品を指しているので、ちゃんと要約してくれたようです。

そして、次のコマンドに書いてある部分のmessageに、 ['Mountain Hardwear Trango 2', 'The North Face Mountain 25', 'Marmot Thor 2 Person']  という3つのおすすめ商品を紹介してくれていました!

サイト内に Mountain Hardwear Trango 2 や The North Face Mountain 25の指摘はあったのでそこから取ってきたように思うのですが、Marmot Thor 2 Personは実在するテントではあるものの記事内に記載はありませんでした(どこから取ってきたのだろう)

注意点

  • Rule / Goal で プロンプトを指定する際に、日本語で書いても問題ないものの、ChatGPT でもあるあるですが、サイトをブラウズさせる場合に日本語ページだとトークンの問題でキャパオーバーして要約を止めてしまうことがあります。とりあえず動かしてみるぶんには英語でやるほうがいいかもしれません

  • 今回GPT-3.5で試しているので、GPT-4でやるともっと精度上がるかもしれません(早く試したい)

  • 結構API叩くことになるので、OpenAI 側 で Usage どれくらいかかってるかは確認したほうがいいかもです。僕の事例でいくと、30~40回くらい叩いた気がしますが、だいたい7ドルくらいかかりました

思ったこと

トークンの問題やGPT-3.5でしか試せていないため精度の問題はあるのですが、指定したプロンプトからゴールに向かって改善しながら実行し続けていく動きは見ていて非常に面白いです。

そしてコマンドに "google" や "browse_website" なんかがあるわけですが、このコマンドが精度が上がり、かつ増えていくと、GPTがやれることがどんどん増えていくことになるので、今だと、うまく使いこなせば調査〜サマリ〜アウトプットみたいなところを自動化できるかもってイメージですが、他にもどんなことを自動化させられるか考えてみるのも面白そうです。

AutoGPTをブラウザで試す方法

上記のサービスはブラウザでAutoGPTを試すことができるWebサービスです。現段階だと今回試した Google検索 のようなコマンドはない(はず)ので、あくまで ChatGPT が連続して思考していくような部分だけができるイメージです。

おわりに

エクスプラザでは ChatGPT をはじめとした LLMを活用したい企業さまの PoC をサポートする事業を実施中です。ぜひお気軽にご相談ください!


この記事が気に入ったらサポートをしてみませんか?