MetaGPT
MetaGPT copied to clipboard
Abort with message too long error
I tried to build one simple web app with GPT-4-0613 model, but get error:
openai.error.APIError: The message you submitted was too long, please reload the conversation and submit something shorter.
how can I reload the conversation and control the content length?
here is the log detail.
Traceback (most recent call last):
File "/app/metagpt/startup.py", line 29, in <module>
fire.Fire(main)
File "/usr/local/lib/python3.9/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/usr/local/lib/python3.9/site-packages/fire/core.py", line 466, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "/usr/local/lib/python3.9/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "/app/metagpt/startup.py", line 25, in main
asyncio.run(startup(idea, investment, n_round))
File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/app/metagpt/startup.py", line 15, in startup
await company.run(n_round=n_round)
File "/app/metagpt/metagpt/software_company.py", line 60, in run
await self.environment.run()
File "/app/metagpt/metagpt/environment.py", line 64, in run
await asyncio.gather(*futures)
File "/app/metagpt/metagpt/roles/role.py", line 229, in run
rsp = await self._react()
File "/app/metagpt/metagpt/roles/role.py", line 200, in _react
return await self._act()
File "/app/metagpt/metagpt/roles/engineer.py", line 143, in _act
return await self._act_sp()
File "/app/metagpt/metagpt/roles/engineer.py", line 128, in _act_sp
code_rsp = await WriteCode().run(
File "/app/metagpt/metagpt/actions/write_code.py", line 69, in run
code_rsp = await self._aask(prompt)
File "/app/metagpt/metagpt/actions/action.py", line 47, in _aask
return await self.llm.aask(prompt, system_msgs)
File "/app/metagpt/metagpt/provider/base_gpt_api.py", line 44, in aask
rsp = await self.acompletion_text(message, stream=True)
File "/app/metagpt/metagpt/provider/openai_api.py", line 27, in wrapper
return await f(*args, **kwargs)
File "/app/metagpt/metagpt/provider/openai_api.py", line 213, in acompletion_text
return await self._achat_completion_stream(messages)
File "/app/metagpt/metagpt/provider/openai_api.py", line 146, in _achat_completion_stream
response = await openai.ChatCompletion.acreate(
File "/usr/local/lib/python3.9/site-packages/openai/api_resources/chat_completion.py", line 45, in acreate
return await super().acreate(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 217, in acreate
response, _, api_key = await requestor.arequest(
File "/usr/local/lib/python3.9/site-packages/openai/api_requestor.py", line 382, in arequest
resp, got_stream = await self._interpret_async_response(result, stream)
File "/usr/local/lib/python3.9/site-packages/openai/api_requestor.py", line 726, in _interpret_async_response
self._interpret_response_line(
File "/usr/local/lib/python3.9/site-packages/openai/api_requestor.py", line 763, in _interpret_response_line
raise self.handle_error_response(
openai.error.APIError: The message you submitted was too long, please reload the conversation and submit something shorter. {"error":{"message":"The message you submitted was too long, please reload the conversation and submit something shorter.","type":"invalid_request_error","param":"sk-6FL4nMVecP3FSRDLVZcZ7mr********************","code":"context_length_exceeded"}} 413 {'error': {'message': 'The message you submitted was too long, please reload the conversation and submit something shorter.', 'type': 'invalid_request_error', 'param': 'sk-6FL4nMVecP3FSRDLVZcZ7mr********************', 'code': 'context_length_exceeded'}} <CIMultiDictProxy('Date': 'Thu, 17 Aug 2023 12:46:33 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '245', 'Connection': 'keep-alive', 'CF-Cache-Status': 'DYNAMIC', 'Report-To': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=JjfZ1%2BB0E8wMGR1kKgLjCRvodL11jXX1oH8RdmDQRveWs0MV1ZPLJXyk4L59nPjqrKoOlKqrcjK18BJXfRxiRWMx%2F1%2B0wIL2XcJ2PqL1w0%3D"}],"group":"cf-nel","max_age":604800}', 'NEL': '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains; preload', 'X-Content-Type-Options': 'nosniff', 'Server': 'cloudflare', 'CF-RAY': '7f82053e1e872b7a-LAX', 'alt-svc': 'h3=":443"; ma=86400')>```
Increase MAX_TOKENS
in config/config.yaml
or config/key.yaml
.
Looks like this is a hack for the gpt-4 desktop version? Its maximum length is relatively small.
I tried to build one simple web app with GPT-4-0613 model, but get error:
openai.error.APIError: The message you submitted was too long, please reload the conversation and submit something shorter.
how can I reload the conversation and control the content length?
here is the log detail.
Traceback (most recent call last): File "/app/metagpt/startup.py", line 29, in <module> fire.Fire(main) File "/usr/local/lib/python3.9/site-packages/fire/core.py", line 141, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "/usr/local/lib/python3.9/site-packages/fire/core.py", line 466, in _Fire component, remaining_args = _CallAndUpdateTrace( File "/usr/local/lib/python3.9/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace component = fn(*varargs, **kwargs) File "/app/metagpt/startup.py", line 25, in main asyncio.run(startup(idea, investment, n_round)) File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete return future.result() File "/app/metagpt/startup.py", line 15, in startup await company.run(n_round=n_round) File "/app/metagpt/metagpt/software_company.py", line 60, in run await self.environment.run() File "/app/metagpt/metagpt/environment.py", line 64, in run await asyncio.gather(*futures) File "/app/metagpt/metagpt/roles/role.py", line 229, in run rsp = await self._react() File "/app/metagpt/metagpt/roles/role.py", line 200, in _react return await self._act() File "/app/metagpt/metagpt/roles/engineer.py", line 143, in _act return await self._act_sp() File "/app/metagpt/metagpt/roles/engineer.py", line 128, in _act_sp code_rsp = await WriteCode().run( File "/app/metagpt/metagpt/actions/write_code.py", line 69, in run code_rsp = await self._aask(prompt) File "/app/metagpt/metagpt/actions/action.py", line 47, in _aask return await self.llm.aask(prompt, system_msgs) File "/app/metagpt/metagpt/provider/base_gpt_api.py", line 44, in aask rsp = await self.acompletion_text(message, stream=True) File "/app/metagpt/metagpt/provider/openai_api.py", line 27, in wrapper return await f(*args, **kwargs) File "/app/metagpt/metagpt/provider/openai_api.py", line 213, in acompletion_text return await self._achat_completion_stream(messages) File "/app/metagpt/metagpt/provider/openai_api.py", line 146, in _achat_completion_stream response = await openai.ChatCompletion.acreate( File "/usr/local/lib/python3.9/site-packages/openai/api_resources/chat_completion.py", line 45, in acreate return await super().acreate(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 217, in acreate response, _, api_key = await requestor.arequest( File "/usr/local/lib/python3.9/site-packages/openai/api_requestor.py", line 382, in arequest resp, got_stream = await self._interpret_async_response(result, stream) File "/usr/local/lib/python3.9/site-packages/openai/api_requestor.py", line 726, in _interpret_async_response self._interpret_response_line( File "/usr/local/lib/python3.9/site-packages/openai/api_requestor.py", line 763, in _interpret_response_line raise self.handle_error_response( openai.error.APIError: The message you submitted was too long, please reload the conversation and submit something shorter. {"error":{"message":"The message you submitted was too long, please reload the conversation and submit something shorter.","type":"invalid_request_error","param":"sk-6FL4nMVecP3FSRDLVZcZ7mr********************","code":"context_length_exceeded"}} 413 {'error': {'message': 'The message you submitted was too long, please reload the conversation and submit something shorter.', 'type': 'invalid_request_error', 'param': 'sk-6FL4nMVecP3FSRDLVZcZ7mr********************', 'code': 'context_length_exceeded'}} <CIMultiDictProxy('Date': 'Thu, 17 Aug 2023 12:46:33 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '245', 'Connection': 'keep-alive', 'CF-Cache-Status': 'DYNAMIC', 'Report-To': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=JjfZ1%2BB0E8wMGR1kKgLjCRvodL11jXX1oH8RdmDQRveWs0MV1ZPLJXyk4L59nPjqrKoOlKqrcjK18BJXfRxiRWMx%2F1%2B0wIL2XcJ2PqL1w0%3D"}],"group":"cf-nel","max_age":604800}', 'NEL': '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains; preload', 'X-Content-Type-Options': 'nosniff', 'Server': 'cloudflare', 'CF-RAY': '7f82053e1e872b7a-LAX', 'alt-svc': 'h3=":443"; ma=86400')>```
have you got any solution? I use a reverse ChatGPT api, got same error