feat: parse assistant message to AssistantMessage by default (#528)

This commit is contained in:
Sarah Wooders
2025-01-08 15:00:32 -08:00
committed by GitHub
parent 26a6cbc546
commit 096791aae1
2 changed files with 7 additions and 1 deletions

View File

@@ -11,6 +11,10 @@ class LettaRequest(BaseModel):
# Flags to support the use of AssistantMessage message types
use_assistant_message: bool = Field(
default=True,
description="Whether the server should parse specific tool call arguments (default `send_message`) as `AssistantMessage` objects.",
)
assistant_message_tool_name: str = Field(
default=DEFAULT_MESSAGE_TOOL,
description="The name of the designated message tool.",

View File

@@ -493,6 +493,7 @@ async def send_message(
stream_steps=False,
stream_tokens=False,
# Support for AssistantMessage
use_assistant_message=request.use_assistant_message,
assistant_message_tool_name=request.assistant_message_tool_name,
assistant_message_tool_kwarg=request.assistant_message_tool_kwarg,
)
@@ -638,6 +639,7 @@ async def send_message_to_agent(
chat_completion_mode: bool = False,
timestamp: Optional[datetime] = None,
# Support for AssistantMessage
use_assistant_message: bool = True,
assistant_message_tool_name: str = DEFAULT_MESSAGE_TOOL,
assistant_message_tool_kwarg: str = DEFAULT_MESSAGE_TOOL_KWARG,
) -> Union[StreamingResponse, LettaResponse]:
@@ -668,7 +670,7 @@ async def send_message_to_agent(
stream_tokens = False
# Create a new interface per request
letta_agent.interface = StreamingServerInterface()
letta_agent.interface = StreamingServerInterface(use_assistant_message)
streaming_interface = letta_agent.interface
if not isinstance(streaming_interface, StreamingServerInterface):
raise ValueError(f"Agent has wrong type of interface: {type(streaming_interface)}")