Files
agent/tests/pipeline_setup/suite_02_pipeline/cli/index_repo.py
T
2026-03-12 16:55:23 +03:00

37 lines
1.5 KiB
Python

"""Скрипт индексации репозитория: создаёт RAG-сессию и индексирует указанную директорию.
Используется для подготовки репозитория перед запуском тестовых пайплайнов с retrieval или full_chain.
Запуск из корня проекта (agent):
python -m tests.pipeline_setup.suite_02_pipeline.cli.index_repo --repo-path /path/to/repo [--project-id ID]
Параметры:
--repo-path (обязательный) Путь к корню индексируемого репозитория.
--project-id (опционально) Идентификатор проекта для созданной rag_session; по умолчанию — имя директории репо.
"""
from __future__ import annotations
import sys
from pathlib import Path
# Обеспечиваем импорт из корня проекта
_agent_root = Path(__file__).resolve().parents[4]
if str(_agent_root) not in sys.path:
sys.path.insert(0, str(_agent_root))
# Добавляем src в путь для app
_src = _agent_root / "src"
if _src.exists() and str(_src) not in sys.path:
sys.path.insert(0, str(_src))
def main() -> int:
argv = ["reindex", *sys.argv[1:]]
from tests.pipeline_setup.suite_02_pipeline.pipeline_intent_rag.cli import main as cli_main
return cli_main(argv)
if __name__ == "__main__":
raise SystemExit(main())