marvin.thread
Thread management for conversations.
This module provides the Thread class for managing conversation context.
Classes
LLMCall
get_messages
Get the messages for this LLM call.get_messages_async
Get the messages for this LLM call.
LLMCallMessages
Message
Thread
-
add_agent_message
Add an agent message to the thread. -
add_agent_message_async
Add an agent message to the thread. -
add_info_message
Add an info message to the thread. -
add_info_message_async
Add an info message to the thread. -
add_messages
Add multiple messages to the thread. Args: messages: List of messages to add (UserMessage, AssistantMessage, etc.) llm_call_id: Optional ID of the LLM call that generated these messages -
add_messages_async
Add multiple messages to the thread. Args: messages: List of messages to add (UserMessage, AssistantMessage, etc.) llm_call_id: Optional ID of the LLM call that generated these messages -
add_system_message
Add a system message to the thread. -
add_system_message_async
Add a system message to the thread. -
add_user_message
Add a user message to the thread. -
add_user_message_async
Add a user message to the thread. -
get_current
Get the current thread from context. -
get_llm_calls
Get LLM calls for this thread. Args: before: Only return calls before this timestamp after: Only return calls after this timestamp limit: Maximum number of calls to return Returns: List of LLM calls in chronological order -
get_llm_calls_async
Get LLM calls for this thread. Args: before: Only return calls before this timestamp after: Only return calls after this timestamp limit: Maximum number of calls to return Returns: List of LLM calls in chronological order -
get_messages
Get all messages in this thread. Args: before: Only return messages before this timestamp after: Only return messages after this timestamp limit: Maximum number of messages to return include_system_messages: Whether to include system messages Returns: List of messages in chronological order -
get_messages_async
Get all messages in this thread. Args: before: Only return messages before this timestamp after: Only return messages after this timestamp limit: Maximum number of messages to return include_system_messages: Whether to include system messages Returns: List of messages in chronological order -
get_usage
Get the usage for this thread. Args: before: Only include usage before this timestamp after: Only include usage after this timestamp Returns: Total usage for the specified time range -
get_usage_async
Get the usage for this thread. Args: before: Only include usage before this timestamp after: Only include usage after this timestamp Returns: Total usage for the specified time range
Functions
get_current_thread
get_last_thread
get_thread
Parent Module:
marvin