Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

feat: Add hardcoded list for Gemini (#2301)

Matthew Zhouc634b3f6e3fc
diff --git a/letta/constants.py b/letta/constants.py
index 7b3392ee7..1a13c6685 100644
--- a/letta/constants.py
+++ b/letta/constants.py
@@ -190,6 +190,45 @@ LLM_MAX_TOKENS = {
"gpt-3.5-turbo-0613": 4096, # legacy
"gpt-3.5-turbo-16k-0613": 16385, # legacy
"gpt-3.5-turbo-0301": 4096, # legacy
+ "gemini-1.0-pro-vision-latest": 12288,
+ "gemini-pro-vision": 12288,
+ "gemini-1.5-pro-latest": 2000000,
+ "gemini-1.5-pro-001": 2000000,
+ "gemini-1.5-pro-002": 2000000,
+ "gemini-1.5-pro": 2000000,
+ "gemini-1.5-flash-latest": 1000000,
+ "gemini-1.5-flash-001": 1000000,
+ "gemini-1.5-flash-001-tuning": 16384,
+ "gemini-1.5-flash": 1000000,
+ "gemini-1.5-flash-002": 1000000,
+ "gemini-1.5-flash-8b": 1000000,
+ "gemini-1.5-flash-8b-001": 1000000,
+ "gemini-1.5-flash-8b-latest": 1000000,
+ "gemini-1.5-flash-8b-exp-0827": 1000000,
+ "gemini-1.5-flash-8b-exp-0924": 1000000,
+ "gemini-2.5-pro-exp-03-25": 1048576,
+ "gemini-2.5-pro-preview-03-25": 1048576,
+ "gemini-2.5-flash-preview-04-17": 1048576,
+ "gemini-2.5-flash-preview-05-20": 1048576,
+ "gemini-2.5-flash-preview-04-17-thinking": 1048576,
+ "gemini-2.5-pro-preview-05-06": 1048576,
+ "gemini-2.0-flash-exp": 1048576,
+ "gemini-2.0-flash": 1048576,
+ "gemini-2.0-flash-001": 1048576,
+ "gemini-2.0-flash-exp-image-generation": 1048576,
+ "gemini-2.0-flash-lite-001": 1048576,
+ "gemini-2.0-flash-lite": 1048576,
+ "gemini-2.0-flash-preview-image-generation": 32768,
+ "gemini-2.0-flash-lite-preview-02-05": 1048576,
+ "gemini-2.0-flash-lite-preview": 1048576,
+ "gemini-2.0-pro-exp": 1048576,
+ "gemini-2.0-pro-exp-02-05": 1048576,
+ "gemini-exp-1206": 1048576,
+ "gemini-2.0-flash-thinking-exp-01-21": 1048576,
+ "gemini-2.0-flash-thinking-exp": 1048576,
+ "gemini-2.0-flash-thinking-exp-1219": 1048576,
+ "gemini-2.5-flash-preview-tts": 32768,
+ "gemini-2.5-pro-preview-tts": 65536,
}
# The error message that Letta will receive
# MESSAGE_SUMMARY_WARNING_STR = f"Warning: the conversation history will soon reach its maximum length and be trimmed. Make sure to save any important information from the conversation to your memory before it is removed."
diff --git a/letta/schemas/providers.py b/letta/schemas/providers.py
index 651f9b213..9f17737a4 100644
--- a/letta/schemas/providers.py
+++ b/letta/schemas/providers.py
@@ -1169,6 +1169,7 @@ class GoogleAIProvider(Provider):
provider_category=self.provider_category,
)
)
+
return configs
async def list_llm_models_async(self):
@@ -1243,12 +1244,18 @@ class GoogleAIProvider(Provider):
def get_model_context_window(self, model_name: str) -> Optional[int]:
from letta.llm_api.google_ai_client import google_ai_get_model_context_window
- return google_ai_get_model_context_window(self.base_url, self.api_key, model_name)
+ if model_name in LLM_MAX_TOKENS:
+ return LLM_MAX_TOKENS[model_name]
+ else:
+ return google_ai_get_model_context_window(self.base_url, self.api_key, model_name)
async def get_model_context_window_async(self, model_name: str) -> Optional[int]:
from letta.llm_api.google_ai_client import google_ai_get_model_context_window_async
- return await google_ai_get_model_context_window_async(self.base_url, self.api_key, model_name)
+ if model_name in LLM_MAX_TOKENS:
+ return LLM_MAX_TOKENS[model_name]
+ else:
+ return await google_ai_get_model_context_window_async(self.base_url, self.api_key, model_name)
class GoogleVertexProvider(Provider):