Skip to content

Stores

class Store(Protocol)

Persistence backend for threads, messages and uploaded-file metadata.

Implement this protocol to plug in your own database; pass an instance as App(persist=...). All methods are coroutines.

async def create_thread(user_id: str, *, title: str = DEFAULT_TITLE) -> dict[str, Any]

Create and return a new thread record.

async def get_thread(thread_id: str) -> Optional[dict[str, Any]]

Return a thread record (without messages) or None.

async def list_threads(user_id: str, *, limit: int = 200) -> list[dict[str, Any]]

Return the user’s threads, most recently updated first.

async def update_thread(thread_id: str, **fields: Any) -> Optional[dict[str, Any]]

Update title, title_locked, session and/or updated_at.

async def delete_thread(thread_id: str) -> bool

Delete a thread and its messages. Returns whether it existed.

async def get_messages(thread_id: str) -> list[dict[str, Any]]

Return a thread’s messages in insertion order.

async def get_message(thread_id: str, message_id: str) -> Optional[dict[str, Any]]

Return one message or None.

async def put_message(thread_id: str, message: dict[str, Any]) -> None

Insert or replace a message (by id); replacing keeps its position.

async def delete_messages_after(
thread_id: str,
message_id: str,
*,
inclusive: bool = False,
) -> int

Delete messages after message_id (and it, if inclusive). Returns the count.

async def put_file(record: dict[str, Any]) -> None

Save uploaded-file metadata.

async def get_file(file_id: str) -> Optional[dict[str, Any]]

Return uploaded-file metadata or None.

async def close() -> None

Release resources.

class SQLiteStore(path: Union[str, Path])

A dyui.store.Store backed by a SQLite file.

Parameters

Name Type Description
path Union[str, Path] Database file path (parent directories are created on first use).
async def create_thread(user_id: str, *, title: str = DEFAULT_TITLE) -> dict[str, Any]
async def get_thread(thread_id: str) -> Optional[dict[str, Any]]
async def list_threads(user_id: str, *, limit: int = 200) -> list[dict[str, Any]]
async def update_thread(thread_id: str, **fields: Any) -> Optional[dict[str, Any]]
async def delete_thread(thread_id: str) -> bool
async def get_messages(thread_id: str) -> list[dict[str, Any]]
async def get_message(thread_id: str, message_id: str) -> Optional[dict[str, Any]]
async def put_message(thread_id: str, message: dict[str, Any]) -> None
async def delete_messages_after(
thread_id: str,
message_id: str,
*,
inclusive: bool = False,
) -> int
async def put_file(record: dict[str, Any]) -> None
async def get_file(file_id: str) -> Optional[dict[str, Any]]
async def close() -> None
class MemoryStore

A dyui.store.Store that keeps everything in process memory.

Records are deep-copied on the way in and out, so callers can’t mutate stored state by accident.

async def create_thread(user_id: str, *, title: str = DEFAULT_TITLE) -> dict[str, Any]
async def get_thread(thread_id: str) -> Optional[dict[str, Any]]
async def list_threads(user_id: str, *, limit: int = 200) -> list[dict[str, Any]]
async def update_thread(thread_id: str, **fields: Any) -> Optional[dict[str, Any]]
async def delete_thread(thread_id: str) -> bool
async def get_messages(thread_id: str) -> list[dict[str, Any]]
async def get_message(thread_id: str, message_id: str) -> Optional[dict[str, Any]]
async def put_message(thread_id: str, message: dict[str, Any]) -> None
async def delete_messages_after(
thread_id: str,
message_id: str,
*,
inclusive: bool = False,
) -> int
async def put_file(record: dict[str, Any]) -> None
async def get_file(file_id: str) -> Optional[dict[str, Any]]
async def close() -> None

DyUI Docs assistant

Answers come from the DyUI docs. gpt-oss-120b via Groq. Press Escape or the close button to return to the page.