fastrag.query.chat.schema#
The tables behind PostgresChatStore.
The same columns, the same CHECK constraints, the same message_role /
finish_reason / error_code enumerations, the same indexes as the
original serving schema — but as a
self-managed schema rather than an Alembic-managed ORM Base:
PostgresChatStore creates its schema, its three tables, and its three
Postgres ENUM types on __aenter__ if they are absent (the same
pattern fastrag.ingestion.cache.schema already established for the
ingestion cache). It therefore declares its own MetaData rather than
attaching to any shared declarative Base — no Alembic, no shared
Base, per this task’s own constraints.
Every PostgresChatStore instance calls
build_schema() with its own target schema name at construction time
(pure Python object construction, no I/O), so the same table shapes can live
in as many Postgres schemas as the caller wants — this is what lets the test
suite give every test its own isolated schema.
Module Attributes
Schema name used when a |
Functions
|
Build the chat table definitions targeting Postgres schema |
Classes
|
The three chat tables, bound to one target Postgres schema. |
- fastrag.query.chat.schema.DEFAULT_SCHEMA = 'fastrag_chat'#
Schema name used when a
PostgresChatStorecaller does not pick one.
- class fastrag.query.chat.schema.ChatSchema(metadata, sessions, chats, messages)[source]#
Bases:
objectThe three chat tables, bound to one target Postgres schema.
- fastrag.query.chat.schema.build_schema(schema='fastrag_chat')[source]#
Build the chat table definitions targeting Postgres schema
schema.Pure metadata construction: no connection is opened and no statement is sent.
PostgresChatStore.__aenter__is what actually createsschema, these tables, and the threeENUMtypes in the database, if absent.- Parameters:
schema (str)
- Return type: