Skip to content

marvin.beta.assistants.threads

Tip

All async methods that have an _async suffix have sync equivalents that can be called with out the suffix e.g. run() and await run_async().

Thread

The Thread class represents a conversation thread with an assistant.

Attributes:

Name Type Description
id Optional[str]

The unique identifier of the thread. None if the thread hasn't been created yet.

metadata dict

Additional data about the thread.

add_async async

Add a user message to the thread.

create_async async

Creates a thread.

get_messages_async async

Asynchronously retrieves messages from the thread.

Parameters:

Name Type Description Default
limit int

The maximum number of messages to return.

None
before_message str

The ID of the message to start the list from, retrieving messages sent before this one.

None
after_message str

The ID of the message to start the list from, retrieving messages sent after this one.

None

Returns: list[Union[Message, dict]]: A list of messages from the thread

run_async async

Creates and returns a Run of this thread with the provided assistant.

Parameters:

Name Type Description Default
assistant Assistant

The assistant to run the thread with.

required
run_kwargs

Additional keyword arguments to pass to the Run constructor.

{}