Skip to content

Repository

logger = logging.getLogger(__name__) module-attribute

AbstractConversationRepository

Bases: RepositoryBase[ConversationMetadataSchema, ConvID], ABC

UID = ConvID class-attribute instance-attribute

add_pending_assistant_run_no_update(conv_schema, new_assistant_run) abstractmethod async

Add the new_assistant_run to the pending_assistant_runs of the conversation.

complete_assistant_run(conv_schema, assistant_run, sub_assistant_state_datas) abstractmethod async

Move assistant from pending to completed and update conversation with new messages.

  • Moves the assistant run from pending to assistant_runs
  • Increments the next_run_index
  • Adds the new messages to the message_history

list(user_pk_id, limit=50, with_messages=False) abstractmethod async

List the latest conversations for a user.

mark_deleted(unique_id) async

update_version_only(schema) async

Only increment the version of the conversation, but don't make any other changes.

Used for e.g. attaching new AssistantRuns where the AssistantRun requires a foreign key to the conversation to be created, so the conversation has to be "updated" first.

ConvID

Bases: UniqueIDBase[ConversationMetadataSchema]

uid instance-attribute

__post_init__()

equal_excluding_version_and_deletion(other)

from_schema(schema, exact_version=False) classmethod

SQLConversationRepository

Bases: SQLRepositoryMixin[ConvID], AbstractConversationRepository

model_class = ConversationMetadataModel class-attribute instance-attribute

add_pending_assistant_run_no_update(conv_schema, new_assistant_run) async

complete_assistant_run(conv_schema, assistant_run, sub_assistant_state_datas) async

list(user_pk_id, limit=50, with_messages=False) async