Files
Ai/knowledge_base/management/commands/build_knowledge_base.py
T
sajad-dev 197f70ee12 Add Qdrant and ChromaDB support to the project
- Added Qdrant service to both docker-compose files for production and development.
- Updated environment variables in .env.example and settings.py to include Qdrant configuration.
- Included necessary dependencies for Qdrant and ChromaDB in requirements.txt.
- Updated .gitignore to exclude ChromaDB data files.
2026-02-27 19:37:02 +03:30

48 lines
1.5 KiB
Python

"""
دستور CLI برای ساخت index پایگاه دانش.
"""
from pathlib import Path
from django.core.management.base import BaseCommand
from knowledge_base.rag_settings import RAGConfig
from knowledge_base.indexer import build_index
class Command(BaseCommand):
help = "ساخت/بازسازی پایگاه دانش RAG از sensor_data، soil_data و فایل لحن"
def add_arguments(self, parser):
parser.add_argument(
"--config",
type=str,
default="config/rag_config.yaml",
help="مسیر فایل config یامل (پیش‌فرض: config/rag_config.yaml)",
)
def handle(self, *args, **options):
config_path = options["config"]
path = Path(config_path)
if not path.is_absolute():
path = Path.cwd() / config_path
if not path.exists():
self.stderr.write(
self.style.ERROR(f"فایل config یافت نشد: {path}")
)
self.stderr.write(
"یک فایل config از روی config/rag_config.yaml بسازید یا از config/rag_config.example.yaml کپی کنید."
)
return
self.stdout.write("در حال بارگذاری config...")
config = RAGConfig.load(path)
self.stdout.write("در حال تولید chunks از soil_data و sensor_data...")
count = build_index(config)
self.stdout.write(
self.style.SUCCESS(f"پایگاه دانش با {count} سند ساخته شد.")
)