marvin.thread
Thread management for conversations.
This module provides the Thread class for managing conversation context.
Classes
LLMCall
get_messagesGet the messages for this LLM call.get_messages_asyncGet the messages for this LLM call.
LLMCallMessages
Message
Thread
-
add_agent_messageAdd an agent message to the thread. -
add_agent_message_asyncAdd an agent message to the thread. -
add_info_messageAdd an info message to the thread. -
add_info_message_asyncAdd an info message to the thread. -
add_messagesAdd 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_asyncAdd 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_messageAdd a system message to the thread. -
add_system_message_asyncAdd a system message to the thread. -
add_user_messageAdd a user message to the thread. -
add_user_message_asyncAdd a user message to the thread. -
get_currentGet the current thread from context. -
get_llm_callsGet 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_asyncGet 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_messagesGet 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_asyncGet 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_usageGet 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_asyncGet 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