marvin.database
This module provides utilities for managing database sessions and migrations.
Classes
Base
DBLLMCall
-
createCreate a new LLM call record. Args: thread_id: ID of the thread this call belongs to usage: RunUsage information from the model session: Optional database session. If not provided, a new one will be created. Returns: The created DBLLMCall instance
DBLLMCallMessage
DBMessage
from_messageto_message
DBThread
-
createCreate a new thread record. Args: session: Database session to use id: Optional ID to use for the thread. If not provided, a UUID will be generated. parent_thread_id: Optional ID of the parent thread Returns: The created DBThread instance
UsageType
process_bind_paramConvert RunUsage to JSON before storing in DB.process_result_valueConvert JSON back to RunUsage when loading from DB.
Functions
create_db_and_tables
ensure_db_tables_exist
get_async_engine
get_async_session
init_database_if_necessary
is_sqlite
serialize_message
ctx field in the RetryPromptPart is optionally dict[str, Any], which is not always serializable.
set_async_engine
utc_now
Parent Module:
marvin