ReplyFlow / seed_kb.py
nvikou's picture
Fix HF startup: JSON store, local seed, non-blocking lifespan
a6e51ba verified
Raw History Blame Contribute Delete
831 Bytes
"""Seed knowledge base with local embeddings (HF-safe)."""
from __future__ import annotations
import asyncio
import logging
from pathlib import Path
from app.services.rag import get_knowledge_store, ingest_directory
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("seed")
async def main() -> None:
"""Ingest demo FAQ into JSON vector store."""
kb = Path("data/knowledge")
Path("data/chroma").mkdir(parents=True, exist_ok=True)
Path("data/db").mkdir(parents=True, exist_ok=True)
store = get_knowledge_store()
if store.chunk_count > 0:
logger.info("Already seeded (%s chunks)", store.chunk_count)
return
count = await ingest_directory(kb)
logger.info("Seeded %s chunks", count)
if __name__ == "__main__":
asyncio.run(main())