Open9

Auto-GPTに入門する

foxfox
pip install -r requirements.txt

pipがなかった

foxfox

brew install pyenv
pyenv install --list
pyenv install 3.11.3
pyenv global 3.11.3
python3 -m pip install -r requirements.txt

foxfox

python scripts/main.py --speak
でエラー

~/gpt/Auto-GPT master*
❯ python scripts/main.py --speak
Speak Mode:  ENABLED
Traceback (most recent call last):
  File "/Users/xxx/gpt/Auto-GPT/scripts/main.py", line 275, in <module>
    prompt = construct_prompt()
             ^^^^^^^^^^^^^^^^^^
  File "/Users/xxx/gpt/Auto-GPT/scripts/main.py", line 164, in construct_prompt
    print_to_console(
  File "/Users/xxx/gpt/Auto-GPT/scripts/main.py", line 30, in print_to_console
    speak.say_text(f"{title}. {content}")
  File "/Users/xxx/gpt/Auto-GPT/scripts/speak.py", line 43, in say_text
    gtts_speech(text)
  File "/Users/xxx/gpt/Auto-GPT/scripts/speak.py", line 38, in gtts_speech
    playsound("speech.mp3")
  File "/opt/homebrew/lib/python3.11/site-packages/playsound.py", line 55, in _playsoundOSX
    from AppKit     import NSSound
ModuleNotFoundError: No module named 'AppKit'

~/gpt/Auto-GPT master*
foxfox

python scripts/main.py でもエラー

Traceback (most recent call last):
  File "/Users/xxx/gpt/Auto-GPT/scripts/main.py", line 295, in <module>
    assistant_reply = chat.chat_with_ai(
                      ^^^^^^^^^^^^^^^^^^
  File "/Users/xxx/gpt/Auto-GPT/scripts/chat.py", line 69, in chat_with_ai
    relevant_memory = permanent_memory.get_relevant(str(full_message_history[-5:]), 10)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xxx/gpt/Auto-GPT/scripts/memory.py", line 55, in get_relevant
    query_embedding = get_ada_embedding(data)
                      ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xxx/gpt/Auto-GPT/scripts/memory.py", line 10, in get_ada_embedding
    return openai.Embedding.create(input=[text], model="text-embedding-ada-002")["data"][0]["embedding"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/openai/api_resources/embedding.py", line 33, in create
    response = super().create(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 149, in create
    ) = cls.__prepare_create_request(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 106, in __prepare_create_request
    requestor = api_requestor.APIRequestor(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/openai/api_requestor.py", line 130, in __init__
    self.api_key = key or util.default_api_key()
                          ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/openai/util.py", line 186, in default_api_key
    raise openai.error.AuthenticationError(
openai.error.AuthenticationError: No API key provided. You can set your API key in code using 'openai.api_key = <API-KEY>', or you can set the environment variable OPENAI_API_KEY=<API-KEY>). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = <PATH>'. You can generate API keys in the OpenAI web interface. See https://onboard.openai.com for details, or email support@openai.com if you have any questions.

Open APIのKEYをセットして解決
export OPENAI_API_KEY=自分のやつ

https://platform.openai.com/account/api-keys
から取得できます

foxfox

その前に出てたやつも貼っておく

Traceback (most recent call last):
  File "/Users/xxx/gpt/Auto-GPT/scripts/main.py", line 287, in <module>
    memory.clear()
  File "/Users/xxx/gpt/Auto-GPT/scripts/memory.py", line 46, in clear
    self.index.delete(deleteAll=True)
  File "/opt/homebrew/lib/python3.11/site-packages/pinecone/core/utils/error_handling.py", line 17, in inner_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/pinecone/index.py", line 329, in delete
    return self._vector_api.delete(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/pinecone/core/client/api_client.py", line 776, in __call__
    return self.callable(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/pinecone/core/client/api/vector_operations_api.py", line 117, in __delete
    return self.call_with_http_info(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/pinecone/core/client/api_client.py", line 838, in call_with_http_info
    return self.api_client.call_api(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/pinecone/core/client/api_client.py", line 413, in call_api
    return self.__call_api(resource_path, method,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/pinecone/core/client/api_client.py", line 207, in __call_api
    raise e
  File "/opt/homebrew/lib/python3.11/site-packages/pinecone/core/client/api_client.py", line 200, in __call_api
    response_data = self.request(
                    ^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/pinecone/core/client/api_client.py", line 459, in request
    return self.rest_client.POST(url,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/pinecone/core/client/rest.py", line 271, in POST
    return self.request("POST", url,
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/pinecone/core/client/rest.py", line 222, in request
    raise ForbiddenException(http_resp=r)
pinecone.core.client.exceptions.ForbiddenException: (403)
Reason: Forbidden
HTTP response headers: HTTPHeaderDict({'content-length': '0', 'date': 'Thu, 06 Apr 2023 17:03:03 GMT', 'server': 'envoy'})

これはREAD.md通り
export PINECONE_API_KEY="YOUR_PINECONE_API_KEY"
export PINECONE_ENV="Your pinecone region" # something like: us-east4-gcp
をやって直った

foxfox

遠回りしてしまったことに気づいた
cp .env.template .env
vi .env
でよかった