-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix llm client retry #102
Fix llm client retry #102
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Reviewed everything up to a053889 in 24 seconds
More details
- Looked at
187
lines of code in6
files - Skipped
0
files when reviewing. - Skipped posting
5
drafted comments based on config settings.
1. graphiti_core/llm_client/anthropic_client.py:43
- Draft comment:
Themax_retries
parameter inAsyncAnthropic
is set to 1, which might conflict with the retry logic inLLMClient
. Consider aligning these settings to avoid unexpected behavior. - Reason this comment was not posted:
Confidence changes required:80%
The retry logic in theLLMClient
class is set to retry up to 4 times with exponential backoff. However, themax_retries
parameter in theAsyncAnthropic
client is set to 1, which might conflict with the retry logic inLLMClient
. This could lead to unexpected behavior if theAsyncAnthropic
client does not allow retries beyond itsmax_retries
setting.
2. graphiti_core/llm_client/client.py:37
- Draft comment:
Consider extendingis_server_or_retry_error
to handle other retryable errors like network timeouts or connection errors for more robust retry logic. - Reason this comment was not posted:
Confidence changes required:70%
Theis_server_or_retry_error
function checks forRateLimitError
and HTTP 5xx errors. However, it does not handle other potential retryable errors like network timeouts or connection errors, which could also benefit from retry logic.
3. graphiti_core/llm_client/anthropic_client.py:66
- Draft comment:
Consider handlingJSONDecodeError
in_generate_response
to manage cases where the response is not valid JSON. - Reason this comment was not posted:
Confidence changes required:70%
Thejson.loads
call in_generate_response
methods assumes the response is always valid JSON. If the response is malformed, this will raise aJSONDecodeError
, which is not currently handled.
4. graphiti_core/llm_client/groq_client.py:63
- Draft comment:
Consider handlingJSONDecodeError
in_generate_response
to manage cases where the response is not valid JSON. - Reason this comment was not posted:
Confidence changes required:70%
The same issue withjson.loads
exists in thegroq_client.py
file, where the response is assumed to be valid JSON without handling potentialJSONDecodeError
.
5. graphiti_core/llm_client/openai_client.py:63
- Draft comment:
Consider handlingJSONDecodeError
in_generate_response
to manage cases where the response is not valid JSON. - Reason this comment was not posted:
Confidence changes required:70%
The same issue withjson.loads
exists in theopenai_client.py
file, where the response is assumed to be valid JSON without handling potentialJSONDecodeError
.
Workflow ID: wflow_Mra9qL90kfp8c7nb
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Incremental review on 461780c in 18 seconds
More details
- Looked at
13
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. graphiti_core/llm_client/client.py:66
- Draft comment:
Theafter
parameter in theretry
decorator should directly assign the lambda function without the conditional expression. The current implementation may lead to unexpected behavior ifretry_state.attempt_number
is 1. Consider simplifying the assignment. - Reason this comment was not posted:
Confidence changes required:80%
The lambda function in theafter
parameter of theretry
decorator should be directly assigned without the conditional expression. This ensures that the warning is logged only when necessary, avoiding potential issues whenretry_state.attempt_number
is 1.
Workflow ID: wflow_H9J6qn3oHBSbqyDm
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
Summary:
This PR introduces
RateLimitError
and updates LLM client retry logic to handle rate limit errors using exponential backoff.Key points:
RateLimitError
ingraphiti_core/llm_client/errors.py
.graphiti_core/llm_client/__init__.py
to exportRateLimitError
.graphiti_core/llm_client/client.py
to retry onRateLimitError
usingtenacity
with exponential backoff.graphiti_core/llm_client/anthropic_client.py
,groq_client.py
, andopenai_client.py
to raiseRateLimitError
on rate limit exceptions.Generated with ❤️ by ellipsis.dev