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 gemini 2.5 to google vertex (#1590)

Sarah Wooders68b1ff85b1ed
diff --git a/letta/llm_api/google_ai_client.py b/letta/llm_api/google_ai_client.py
index cf6818bc5..730f9b9e4 100644
--- a/letta/llm_api/google_ai_client.py
+++ b/letta/llm_api/google_ai_client.py
@@ -2,6 +2,7 @@ import uuid
from typing import List, Optional, Tuple
import requests
+from google.genai.types import FunctionCallingConfig, FunctionCallingConfigMode, ToolConfig
from letta.constants import NON_USER_MSG_PREFIX
from letta.helpers.datetime_helpers import get_utc_time
@@ -50,7 +51,7 @@ class GoogleAIClient(LLMClientBase):
[m.to_google_ai_dict() for m in messages],
)
- return {
+ request_data = {
"contents": contents,
"tools": tools,
"generation_config": {
@@ -59,6 +60,16 @@ class GoogleAIClient(LLMClientBase):
},
}
+ # write tool config
+ tool_config = ToolConfig(
+ function_calling_config=FunctionCallingConfig(
+ # ANY mode forces the model to predict only function calls
+ mode=FunctionCallingConfigMode.ANY,
+ )
+ )
+ request_data["tool_config"] = tool_config.model_dump()
+ return request_data
+
def convert_response_to_chat_completion(
self,
response_data: dict,
diff --git a/letta/llm_api/google_constants.py b/letta/llm_api/google_constants.py
index f7a11fc7a..5215f69cb 100644
--- a/letta/llm_api/google_constants.py
+++ b/letta/llm_api/google_constants.py
@@ -1,4 +1,5 @@
GOOGLE_MODEL_TO_CONTEXT_LENGTH = {
+ "gemini-2.5-pro-exp-03-25": 1048576,
"gemini-2.0-flash-001": 1048576,
"gemini-2.0-pro-exp-02-05": 2097152,
"gemini-2.0-flash-lite-preview-02-05": 1048576,
@@ -9,4 +10,6 @@ GOOGLE_MODEL_TO_CONTEXT_LENGTH = {
"gemini-1.0-pro-vision": 16384,
}
+GOOGLE_MODEL_TO_OUTPUT_LENGTH = {"gemini-2.0-flash-001": 8192, "gemini-2.5-pro-exp-03-25": 65536}
+
GOOGLE_EMBEDING_MODEL_TO_DIM = {"text-embedding-005": 768, "text-multilingual-embedding-002": 768}