After authentication, db_params on the active kun.py profile is used for psycopg.connect(**db_params).
The code issues selects and inserts against conversations with columns including id, timestamp, prompt, response.
normalize_text applies Unicode NFKC before insert.
- Client:
chromadb.Client()(ephemeral in-process in the reference build). - Global collection:
conversations. - IDs: stringified PostgreSQL
id. - Document payload: concatenation
prompt: {text} response: {text}.
If the collection is empty but SQL has rows, create_vector_db embeds historical rows using the configured embedding model.
create_queries(prompt)— Asks the configured chat model for a Python-parseable list of search strings; ast.literal_eval parses with fallback.retrieve_embeddings— Embeds each query, queries Chroma, appliesclassify_embeddinggating.- Accepted snippets become a
Retrieved memory:system message;stream_responseruns on the recall text.
Deletes the latest SQL row (max id) and matching Chroma id; trims two tail messages from RAM convo.
Stores the text as a user message with assistant reply Memory specimen successfully implanted. so the pair embeds like normal dialogue.
Used on the conversational path: scans the entire table for case-insensitive substring matches in prompt or response. Cost grows with table size.
Room maintains a separate Chroma collection (room_<slug>). It is orthogonal to the global mnemonic unless you merge exports manually.
Session exports and a longer-lived room product surface may also align with arpahls/rooms if you outgrow the bundled room.py workflow.
- Dump PostgreSQL regularly (
pg_dump). - Treat SQL as source of truth; re-embed into Chroma if the in-process collection is lost.