Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: configure retries on anthropic client (#2254)
cthomas9542dd2fd983
diff --git a/letta/llm_api/anthropic_client.py b/letta/llm_api/anthropic_client.pyindex ca010d689..d56bb87f7 100644--- a/letta/llm_api/anthropic_client.py+++ b/letta/llm_api/anthropic_client.py@@ -35,6 +35,7 @@ from letta.schemas.openai.chat_completion_response import ChatCompletionResponsefrom letta.schemas.openai.chat_completion_response import Message as ChoiceMessagefrom letta.schemas.openai.chat_completion_response import ToolCall, UsageStatisticsfrom letta.services.provider_manager import ProviderManager+from letta.settings import model_settingsfrom letta.tracing import trace_methodDUMMY_FIRST_USER_MESSAGE = "User initializing bootup sequence."@@ -120,8 +121,16 @@ class AnthropicClient(LLMClientBase):override_key = ProviderManager().get_override_key(llm_config.provider_name, actor=self.actor)if async_client:- return anthropic.AsyncAnthropic(api_key=override_key) if override_key else anthropic.AsyncAnthropic()- return anthropic.Anthropic(api_key=override_key) if override_key else anthropic.Anthropic()+ return (+ anthropic.AsyncAnthropic(api_key=override_key, max_retries=model_settings.anthropic_max_retries)+ if override_key+ else anthropic.AsyncAnthropic(max_retries=model_settings.anthropic_max_retries)+ )+ return (+ anthropic.Anthropic(api_key=override_key, max_retries=model_settings.anthropic_max_retries)+ if override_key+ else anthropic.Anthropic(max_retries=model_settings.anthropic_max_retries)+ )@trace_methoddef build_request_data(diff --git a/letta/settings.py b/letta/settings.pyindex a638a5948..19c4adc98 100644--- a/letta/settings.py+++ b/letta/settings.py@@ -95,6 +95,7 @@ class ModelSettings(BaseSettings):# anthropicanthropic_api_key: Optional[str] = None+ anthropic_max_retries: int = 3# ollamaollama_base_url: Optional[str] = None