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.

fix: Remove hard failure on bad `stream_tokens` input (#2115)

Matthew Zhou122faa78ea58
diff --git a/letta/server/rest_api/routers/v1/agents.py b/letta/server/rest_api/routers/v1/agents.py
index 470c456bb..b04fd9091 100644
--- a/letta/server/rest_api/routers/v1/agents.py
+++ b/letta/server/rest_api/routers/v1/agents.py
@@ -1,4 +1,5 @@
import asyncio
+import warnings
from datetime import datetime
from typing import Dict, List, Optional, Union
@@ -553,11 +554,11 @@ async def send_message_to_agent(
# Disable token streaming if not OpenAI
# TODO: cleanup this logic
llm_config = letta_agent.agent_state.llm_config
- if stream_steps and (llm_config.model_endpoint_type != "openai" or "inference.memgpt.ai" in llm_config.model_endpoint):
- raise HTTPException(
- status_code=400,
- detail=f"Token streaming is only supported for models with type 'openai' or `inference.memgpt.ai` in the model_endpoint: agent has endpoint type {llm_config.model_endpoint_type} and {llm_config.model_endpoint}.",
+ if stream_tokens and (llm_config.model_endpoint_type != "openai" or "inference.memgpt.ai" in llm_config.model_endpoint):
+ warnings.warn(
+ "Token streaming is only supported for models with type 'openai' or `inference.memgpt.ai` in the model_endpoint: agent has endpoint type {llm_config.model_endpoint_type} and {llm_config.model_endpoint}. Setting stream_tokens to False."
)
+ stream_tokens = False
# Create a new interface per request
letta_agent.interface = StreamingServerInterface()