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 thinking budget for vertex gemini (#1960)

Matthew Zhoub2627ce22a1c
diff --git a/letta/llm_api/google_vertex_client.py b/letta/llm_api/google_vertex_client.py
index 76a84daf3..177eac8d9 100644
--- a/letta/llm_api/google_vertex_client.py
+++ b/letta/llm_api/google_vertex_client.py
@@ -2,7 +2,7 @@ import uuid
from typing import List, Optional
from google import genai
-from google.genai.types import FunctionCallingConfig, FunctionCallingConfigMode, GenerateContentResponse, ToolConfig
+from google.genai.types import FunctionCallingConfig, FunctionCallingConfigMode, GenerateContentResponse, ThinkingConfig, ToolConfig
from letta.helpers.datetime_helpers import get_utc_time_int
from letta.helpers.json_helpers import json_dumps
@@ -60,6 +60,15 @@ class GoogleVertexClient(GoogleAIClient):
)
request_data["config"]["tool_config"] = tool_config.model_dump()
+ # Add thinking_config
+ # If enable_reasoner is False, set thinking_budget to 0
+ # Otherwise, use the value from max_reasoning_tokens
+ thinking_budget = 0 if not llm_config.enable_reasoner else llm_config.max_reasoning_tokens
+ thinking_config = ThinkingConfig(
+ thinking_budget=thinking_budget,
+ )
+ request_data["config"]["thinking_config"] = thinking_config.model_dump()
+
return request_data
def convert_response_to_chat_completion(