Files
Mutual_Fund/rag/events.py
T

20 lines
619 B
Python

"""Knowledge-base events published by the operations workflow."""
from __future__ import annotations
KNOWLEDGE_UPDATE_EVENT = "event:knowledge_update"
async def publish_knowledge_update(
publisher, *, doc_id: str, collection_name: str, chunk_count: int, action: str | None = None
) -> None:
"""Publish only after the caller's atomic Milvus write has succeeded."""
payload = {
"doc_id": doc_id,
"collection_name": collection_name,
"chunk_count": chunk_count,
}
if action is not None:
payload["action"] = action
await publisher(KNOWLEDGE_UPDATE_EVENT, payload)