-
-
Notifications
You must be signed in to change notification settings - Fork 691
Description
❓ Questions and Help
We sincerely suggest you to carefully read the documentation. After that, if you still feel puzzled, please describe the question clearly under this issue.
当我使用deepseek api作为LLM时,执行rdagent fin_model,上下文超过最大长度时报错,如何解决,如何设置自动截断?
2025-07-27 15:47:00.560 | WARNING | rdagent.oai.backend.base:_try_create_chat_completion_or_embedding:510 - litellm.ContextWindowExceededError: litellm.BadRequestError: ContextWindowExceededError: DeepseekException - {"error":{"message":"This model's maximum context length is 65536 tokens. However, you requested 66581 tokens (66581 in the messages, 0 in the completion). Please reduce the length of the messages or completion.","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}
2025-07-27 15:47:00.560 | WARNING | rdagent.oai.backend.base:_try_create_chat_completion_or_embedding:511 - Retrying 10th time...
Workflow Progress: 25%|████████████████████████████████▎ | 1/4 [1:48:20<5:25:01, 6500.43s/step, loop_index=3, step_index=1, step_name=coding]
Traceback (most recent call last):
File "/home/ezio/anaconda3/envs/RDagent/bin/rdagent", line 8, in
sys.exit(app())
File "/home/ezio/anaconda3/envs/RDagent/lib/python3.10/site-packages/rdagent/app/cli.py", line 55, in app
fire.Fire(
File "/home/ezio/anaconda3/envs/RDagent/lib/python3.10/site-packages/fire/core.py", line 135, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/home/ezio/anaconda3/envs/RDagent/lib/python3.10/site-packages/fire/core.py", line 468, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "/home/ezio/anaconda3/envs/RDagent/lib/python3.10/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "/home/ezio/anaconda3/envs/RDagent/lib/python3.10/site-packages/rdagent/app/qlib_rd_loop/model.py", line 33, in main
asyncio.run(model_loop.run(step_n=step_n, loop_n=loop_n, all_duration=all_duration))
File "/home/ezio/anaconda3/envs/RDagent/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/home/ezio/anaconda3/envs/RDagent/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/ezio/anaconda3/envs/RDagent/lib/python3.10/site-packages/rdagent/utils/workflow/loop.py", line 336, in run
await asyncio.gather(
File "/home/ezio/anaconda3/envs/RDagent/lib/python3.10/site-packages/rdagent/utils/workflow/loop.py", line 285, in kickoff_loop
await self._run_step(li)
File "/home/ezio/anaconda3/envs/RDagent/lib/python3.10/site-packages/rdagent/utils/workflow/loop.py", line 221, in _run_step
result = await func(self.loop_prev_out[li])
File "/home/ezio/anaconda3/envs/RDagent/lib/python3.10/site-packages/rdagent/components/workflow/rd_loop.py", line 59, in direct_exp_gen
hypo = self._propose()
File "/home/ezio/anaconda3/envs/RDagent/lib/python3.10/site-packages/rdagent/components/workflow/rd_loop.py", line 46, in _propose
hypothesis = self.hypothesis_gen.gen(self.trace)
File "/home/ezio/anaconda3/envs/RDagent/lib/python3.10/site-packages/rdagent/components/proposal/init.py", line 53, in gen
resp = APIBackend().build_messages_and_create_chat_completion(
File "/home/ezio/anaconda3/envs/RDagent/lib/python3.10/site-packages/rdagent/oai/backend/base.py", line 400, in build_messages_and_create_chat_completion
resp = self._try_create_chat_completion_or_embedding( # type: ignore[misc]
File "/home/ezio/anaconda3/envs/RDagent/lib/python3.10/site-packages/rdagent/oai/backend/base.py", line 513, in _try_create_chat_completion_or_embedding
raise RuntimeError(error_message)
RuntimeError: Failed to create chat completion after 10 retries.