marvin.database
Database management for persistence.
This module provides utilities for managing database sessions and migrations.
Constants
ALEMBIC_DIR
ALEMBIC_INI
MARVIN_DIR
Classes
Base
DBLLMCall
-
create
Create a new LLM call record. Args: thread_id: ID of the thread this call belongs to usage: Usage 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_message
to_message
DBThread
-
create
Create 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_param
Convert Usage to JSON before storing in DB.process_result_value
Convert JSON back to Usage 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