Significant-Gravitas / AutoGPT

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
https://agpt.co
Other
168.26k stars 44.38k forks source link

AutoGPT attempting to make API request but it exceeds token limit #3360

Closed remriel closed 1 year ago

remriel commented 1 year ago

⚠️ Search for existing issues first ⚠️

Which Operating System are you using?

Windows

Which version of Auto-GPT are you using?

Latest Release

GPT-3 or GPT-4?

GPT-3.5

Steps to reproduce 🕹

I gave my agent an apikeys.txt file to retrieve API keys for my News API account. It tried to make an API request but it exceeded the token limit. Is there any way to break it into chunks so GPT can accept it or is this just a limitation?

Current behavior 😯

Crashes when token limit is exceeded

Expected behavior 🤔

No response

Your prompt 📝

ai_goals:
- Retrieve the latest earnings report using the API keys provided in APIkeys.txt.
- Analyze the report and provide a detailed summary that highlights the most important
  information in a highly readable format.
- Assign a sentiment rating from 1 to 10 based on the overall tone of the report,
  with 1 being very negative and 10 being very positive.
- Ensure that the summary and sentiment rating are delivered in a timely manner to
  allow for quick decision-making.
- Continuously learn and improve its analysis and reporting capabilities to provide
  even more valuable insights to its users.
ai_name: EarningsReportGPT
ai_role: an AI assistant that specializes in providing detailed and highly readable
  summaries of earnings reports, along with a sentiment rating, to help businesses
  make informed decisions.
api_budget: 0.0

Your Logs 📒

Continuous Mode:  ENABLED
WARNING:  Continuous mode is not recommended. It is potentially dangerous and may cause your AI to run forever or carry out actions you would not usually authorise. Use at your own risk.
GPT3.5 Only Mode:  ENABLED
WARNING: Plugin SystemInformationPlugin found. But not in the allowlist... Load? (y/n):
WARNING: Plugin AutoGPT_YouTube found. But not in the allowlist... Load? (y/n):
Welcome back!  Would you like me to return to being EarningsReportGPT?
Continue with the last settings?
Name:  EarningsReportGPT
Role:  an AI assistant that specializes in providing detailed and highly readable summaries of earnings reports, along with a sentiment rating, to help businesses make informed decisions.
Goals: ['Retrieve the latest earnings report using the API keys provided in APIkeys.txt.', 'Analyze the report and provide a detailed summary that highlights the most important information in a highly readable format.', 'Assign a sentiment rating from 1 to 10 based on the overall tone of the report, with 1 being very negative and 10 being very positive.', 'Ensure that the summary and sentiment rating are delivered in a timely manner to allow for quick decision-making.', 'Continuously learn and improve its analysis and reporting capabilities to provide even more valuable insights to its users.']
API Budget: infinite
Continue (y/n):
EarningsReportGPT  has been created with the following details:
Name:  EarningsReportGPT
Role:  an AI assistant that specializes in providing detailed and highly readable summaries of earnings reports, along with a sentiment rating, to help businesses make informed decisions.
Goals:
-  Retrieve the latest earnings report using the API keys provided in APIkeys.txt.
-  Analyze the report and provide a detailed summary that highlights the most important information in a highly readable format.
-  Assign a sentiment rating from 1 to 10 based on the overall tone of the report, with 1 being very negative and 10 being very positive.
-  Ensure that the summary and sentiment rating are delivered in a timely manner to allow for quick decision-making.
-  Continuously learn and improve its analysis and reporting capabilities to provide even more valuable insights to its users.
Using memory of type:  PineconeMemory
Using Browser:  chrome
 THOUGHTS:  I need to retrieve the latest earnings report using the API keys provided in APIkeys.txt. I will start by reading the API keys from the file and then use them to make a request to the API endpoint.
REASONING:  I need to retrieve the latest earnings report to analyze and provide a summary with a sentiment rating. This will help businesses make informed decisions.
PLAN:
-  Read API keys from APIkeys.txt
-  Make request to API endpoint using the keys
-  Retrieve the latest earnings report
-  Analyze the report and provide a summary with a sentiment rating
-  Deliver the summary and sentiment rating in a timely manner
CRITICISM:  I need to ensure that I am using the correct API keys and that the request to the API endpoint is successful. I also need to make sure that the summary and sentiment rating are accurate and useful to the user.
NEXT ACTION:  COMMAND = read_file ARGUMENTS = {'filename': 'D:\\GPT\\Autogpt\\autogpt\\auto_gpt_workspace\\APIkeys.txt'}
SYSTEM:  Command read_file returned: 
 THOUGHTS:  Now that I have the API keys, I will use them to make a request to the API endpoint and retrieve the latest earnings report.
REASONING:  I need to retrieve the latest earnings report to analyze and provide a summary with a sentiment rating. This will help businesses make informed decisions.
PLAN:
-  Make request to API endpoint using the keys
-  Retrieve the latest earnings report
-  Analyze the report and provide a summary with a sentiment rating
-  Deliver the summary and sentiment rating in a timely manner
CRITICISM:  I need to ensure that the request to the API endpoint is successful and that I am retrieving the correct information. I also need to make sure that the summary and sentiment rating are accurate and useful to the user.
NEXT ACTION:  COMMAND = execute_shell ARGUMENTS = {'command_line': 'curl -H "Authorization: Bearer " -H "Content-Type: application/json" "https://newsapi.org/v2/everything?q=earnings%20report&sortBy=publishedAt&apiKey="'}
Executing command 'curl -H "Authorization: Bearer " -H "Content-Type: application/json" "https://newsapi.org/v2/everything?q=earnings%20report&sortBy=publishedAt&apiKey="' in working directory 'D:\GPT\Autogpt\autogpt\auto_gpt_workspace'
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\GPT\Autogpt\autogpt\__main__.py", line 5, in <module>
    autogpt.cli.main()
  File "C:\Python311\Lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\click\core.py", line 1635, in invoke
    rv = super().invoke(ctx)
         ^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\click\decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\GPT\Autogpt\autogpt\cli.py", line 90, in main
    run_auto_gpt(
  File "D:\GPT\Autogpt\autogpt\main.py", line 154, in run_auto_gpt
    agent.start_interaction_loop()
  File "D:\GPT\Autogpt\autogpt\agent\agent.py", line 242, in start_interaction_loop
    self.memory.add(memory_to_add)
  File "D:\GPT\Autogpt\autogpt\memory\pinecone.py", line 47, in add
    vector = get_ada_embedding(data)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\GPT\Autogpt\autogpt\llm_utils.py", line 231, in get_ada_embedding
    embedding = create_embedding(text, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\GPT\Autogpt\autogpt\llm_utils.py", line 46, in _wrapped
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "D:\GPT\Autogpt\autogpt\llm_utils.py", line 257, in create_embedding
    return openai.Embedding.create(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\openai\api_resources\embedding.py", line 33, in create
    response = super().create(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
                           ^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\openai\api_requestor.py", line 226, in request
    resp, got_stream = self._interpret_response(result, stream)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\openai\api_requestor.py", line 619, in _interpret_response
    self._interpret_response_line(
  File "C:\Python311\Lib\site-packages\openai\api_requestor.py", line 682, in _interpret_response_line
    raise self.handle_error_response(
**openai.error.InvalidRequestError: This model's maximum context length is 8191 tokens, however you requested 26735 tokens (26735 in your prompt; 0 for the completion). Please reduce your prompt; or completion length.**
MyNuggets666 commented 1 year ago

i found same issue even when looking into the work directory, same error and crash in some cases the AI seems to duplicate the responce eg c:/ c:/ c:/ c:/ c:/ c:/ c:/ c:/ c:/ c:/ witch cause the same token issue

seems to be more common when using ---gpt3only

sfchrisgleason commented 1 year ago

Same. 95% of my runs fail with either the token issue, or the JSONDecodeError.