Download seed_kb.py from nvikou/ReplyFlow: direct link, hf CLI and curl.
- Browser
- Download file 831 Bytes
-
https://huggingface.co/spaces/nvikou/ReplyFlow/resolve/main/seed_kb.py
- Command line
-
hf download hf://spaces/nvikou/ReplyFlow/seed_kb.py
-
curl -L -o seed_kb.py https://huggingface.co/spaces/nvikou/ReplyFlow/resolve/main/seed_kb.py
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()) | |