rdagent fin_factor error
π Bug Description
To Reproduce
Steps to reproduce the behavior:
- system: ubuntu run: rdagent fin_factor my .env file like this: BACKEND=rdagent.oai.backend.LiteLLMAPIBackend CHAT_MODEL=deepseek/deepseek-chat DEEPSEEK_API_KEY=sk-
using deepseek as backend model
- get this errorοΌ Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
2025-04-14 12:12:27.066 | WARNING | rdagent.oai.backend.base:_try_create_chat_completion_or_embedding:342 - litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
2025-04-14 12:12:27.068 | WARNING | rdagent.oai.backend.base:_try_create_chat_completion_or_embedding:343 - Retrying 10th time...
Implementing: 10%|βββββββββββββββ | 1/10 [04:19<38:58, 259.78s/it]
Workflow Progress: 50%|ββββββββββββββββββββββββββββββββββββββββββββββββ | 2/4 [09:44<09:44, 292.05s/step, loop_index=0, step_index=2, step_name=coding]
Traceback (most recent call last):
File "/home/roger/anaconda3/envs/rdagent/bin/rdagent", line 8, in
Expected Behavior
Screenshot
Environment
rdagent collect_info
2025-04-14 13:01:24.557 | INFO | rdagent.oai.backend.litellm:
Additional Notes
and also many others met this same issue in the wechat group, so guess it's a bug, please fix it
ADDED: 2025-04-14 13:21:00.480 | WARNING | rdagent.oai.backend.base:_try_create_chat_completion_or_embedding:342 - litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable 2025-04-14 13:21:00.483 | WARNING | rdagent.oai.backend.base:try_create_chat_completion_or_embedding:343 - Retrying 1th time... 2025-04-14 13:21:00.485 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:57 - Using emb model text-embedding-3-small 2025-04-14 13:21:00.486 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:58 - Creating embedding for: factor_name: Momentum_5D factor_description: The 5-day price momentum factor calculated as the percentage change in closing price over the past 5 trading days. factor_formulation: \frac{close_t - close{t-5}}{close{t-5}} variables: {'close_t': 'Closing price at day t', 'close{t-5}': 'Closing price 5 days before day t'}
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
2025-04-14 13:21:01.504 | WARNING | rdagent.oai.backend.base:_try_create_chat_completion_or_embedding:342 - litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable 2025-04-14 13:21:01.507 | WARNING | rdagent.oai.backend.base:try_create_chat_completion_or_embedding:343 - Retrying 2th time... 2025-04-14 13:21:01.509 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:57 - Using emb model text-embedding-3-small 2025-04-14 13:21:01.511 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:58 - Creating embedding for: factor_name: Momentum_5D factor_description: The 5-day price momentum factor calculated as the percentage change in closing price over the past 5 trading days. factor_formulation: \frac{close_t - close{t-5}}{close{t-5}} variables: {'close_t': 'Closing price at day t', 'close{t-5}': 'Closing price 5 days before day t'}
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
2025-04-14 13:21:02.531 | WARNING | rdagent.oai.backend.base:_try_create_chat_completion_or_embedding:342 - litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable 2025-04-14 13:21:02.533 | WARNING | rdagent.oai.backend.base:try_create_chat_completion_or_embedding:343 - Retrying 3th time... 2025-04-14 13:21:02.535 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:57 - Using emb model text-embedding-3-small 2025-04-14 13:21:02.537 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:58 - Creating embedding for: factor_name: Momentum_5D factor_description: The 5-day price momentum factor calculated as the percentage change in closing price over the past 5 trading days. factor_formulation: \frac{close_t - close{t-5}}{close{t-5}} variables: {'close_t': 'Closing price at day t', 'close{t-5}': 'Closing price 5 days before day t'}
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
2025-04-14 13:21:03.560 | WARNING | rdagent.oai.backend.base:_try_create_chat_completion_or_embedding:342 - litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable 2025-04-14 13:21:03.562 | WARNING | rdagent.oai.backend.base:try_create_chat_completion_or_embedding:343 - Retrying 4th time... 2025-04-14 13:21:03.563 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:57 - Using emb model text-embedding-3-small 2025-04-14 13:21:03.565 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:58 - Creating embedding for: factor_name: Momentum_5D factor_description: The 5-day price momentum factor calculated as the percentage change in closing price over the past 5 trading days. factor_formulation: \frac{close_t - close{t-5}}{close{t-5}} variables: {'close_t': 'Closing price at day t', 'close{t-5}': 'Closing price 5 days before day t'}
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
2025-04-14 13:21:04.585 | WARNING | rdagent.oai.backend.base:_try_create_chat_completion_or_embedding:342 - litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable 2025-04-14 13:21:04.587 | WARNING | rdagent.oai.backend.base:try_create_chat_completion_or_embedding:343 - Retrying 5th time... 2025-04-14 13:21:04.590 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:57 - Using emb model text-embedding-3-small 2025-04-14 13:21:04.592 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:58 - Creating embedding for: factor_name: Momentum_5D factor_description: The 5-day price momentum factor calculated as the percentage change in closing price over the past 5 trading days. factor_formulation: \frac{close_t - close{t-5}}{close{t-5}} variables: {'close_t': 'Closing price at day t', 'close{t-5}': 'Closing price 5 days before day t'}
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
2025-04-14 13:21:05.609 | WARNING | rdagent.oai.backend.base:_try_create_chat_completion_or_embedding:342 - litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable 2025-04-14 13:21:05.612 | WARNING | rdagent.oai.backend.base:try_create_chat_completion_or_embedding:343 - Retrying 6th time... 2025-04-14 13:21:05.613 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:57 - Using emb model text-embedding-3-small 2025-04-14 13:21:05.615 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:58 - Creating embedding for: factor_name: Momentum_5D factor_description: The 5-day price momentum factor calculated as the percentage change in closing price over the past 5 trading days. factor_formulation: \frac{close_t - close{t-5}}{close{t-5}} variables: {'close_t': 'Closing price at day t', 'close{t-5}': 'Closing price 5 days before day t'}
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
2025-04-14 13:21:06.632 | WARNING | rdagent.oai.backend.base:_try_create_chat_completion_or_embedding:342 - litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable 2025-04-14 13:21:06.633 | WARNING | rdagent.oai.backend.base:try_create_chat_completion_or_embedding:343 - Retrying 7th time... 2025-04-14 13:21:06.635 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:57 - Using emb model text-embedding-3-small 2025-04-14 13:21:06.637 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:58 - Creating embedding for: factor_name: Momentum_5D factor_description: The 5-day price momentum factor calculated as the percentage change in closing price over the past 5 trading days. factor_formulation: \frac{close_t - close{t-5}}{close{t-5}} variables: {'close_t': 'Closing price at day t', 'close{t-5}': 'Closing price 5 days before day t'}
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
2025-04-14 13:21:07.653 | WARNING | rdagent.oai.backend.base:_try_create_chat_completion_or_embedding:342 - litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable 2025-04-14 13:21:07.655 | WARNING | rdagent.oai.backend.base:try_create_chat_completion_or_embedding:343 - Retrying 8th time... 2025-04-14 13:21:07.657 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:57 - Using emb model text-embedding-3-small 2025-04-14 13:21:07.659 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:58 - Creating embedding for: factor_name: Momentum_5D factor_description: The 5-day price momentum factor calculated as the percentage change in closing price over the past 5 trading days. factor_formulation: \frac{close_t - close{t-5}}{close{t-5}} variables: {'close_t': 'Closing price at day t', 'close{t-5}': 'Closing price 5 days before day t'}
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
2025-04-14 13:21:08.676 | WARNING | rdagent.oai.backend.base:_try_create_chat_completion_or_embedding:342 - litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable 2025-04-14 13:21:08.679 | WARNING | rdagent.oai.backend.base:try_create_chat_completion_or_embedding:343 - Retrying 9th time... 2025-04-14 13:21:08.680 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:57 - Using emb model text-embedding-3-small 2025-04-14 13:21:08.682 | INFO | rdagent.oai.backend.litellm:create_embedding_inner_function:58 - Creating embedding for: factor_name: Momentum_5D factor_description: The 5-day price momentum factor calculated as the percentage change in closing price over the past 5 trading days. factor_formulation: \frac{close_t - close{t-5}}{close{t-5}} variables: {'close_t': 'Closing price at day t', 'close{t-5}': 'Closing price 5 days before day t'}
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
2025-04-14 13:21:09.699 | WARNING | rdagent.oai.backend.base:_try_create_chat_completion_or_embedding:342 - litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable 2025-04-14 13:21:09.703 | WARNING | rdagent.oai.backend.base:_try_create_chat_completion_or_embedding:343 - Retrying 10th time...
before the trace, there are these outputs, I use deepseek not openai, why gets an openai exception
The same problem
The same problem
The same problem
@TPLin22 @WinstonLiyt @SunsetWolf please fix this issue
update: maybe it's because the default embedding model is also openai, i'm trying to replace it with a free model, will update soon
The problem is that the response text returned by DeepSeek cannot be processed into json format, so it will keep retrying. By default, RD-Agent writes this non-coded json output without error, so it's normal that it can't process the response returned by DeepSeek. If you want to solve this issue, please pay attention to this code. Or use OpenAI.
The problem is that the response text returned by
DeepSeekcannot be processed into json format, so it will keep retrying. By default,RD-Agentwrites this non-coded json output without error, so it's normal that it can't process the response returned byDeepSeek. If you want to solve this issue, please pay attention to this code. Or useOpenAI.
yes the output by deepseek is a dict list, so before json.loads, it needs some fix, also another problem is the return of a boolean value, deepseek default returns like a True or False which should be replaced to lower case, just wonder why the official repo didn't add the compatibility if the config supports deepseek
is a dict lis
so convert the dict list in deepseek to json dict in rdagent, or conversely?
The problem is that the response text returned by
DeepSeekcannot be processed into json format, so it will keep retrying. By default,RD-Agentwrites this non-coded json output without error, so it's normal that it can't process the response returned byDeepSeek. If you want to solve this issue, please pay attention to this code. Or useOpenAI.
Is that means RDagent is NOT so compatibible with deepseek in LiteLLM?
the code in the link, function _create_chat_completion_auto_continue defaultly set json_mode: bool = False, and is this could be change by simple command rdagent fin_factor? Or how deepseek user to fix this bug.....
@andy071001 And maybe you can edit the issues, use markdown's code block to make the log better highlightedπ
the third seem to be duplicated with https://github.com/microsoft/RD-Agent/issues/506
I used llama/llama3.2 model, and faced a same issue.
Has this problem been solved? Please enlighten me.