Files
2026-11-09 08:43:30 +03:00

36 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import asyncio
from estimator.config.sections import DatabaseCfg
from estimator.infra.db import SqlReferenceStore, make_engine, make_session_factory
from estimator.infra.embeddings import HashEmbedder
from estimator.services.references import ReferenceService
CORPUS = [
{"project": "P1", "title": "Интеграция с amoCRM", "description": "сделки и контакты", "role": "backend", "hours": "21", "hours_kind": "actual"},
{"project": "P2", "title": "Интеграция Bitrix24", "description": "лиды и сделки", "role": "backend", "hours": "25", "hours_kind": "estimate"},
{"project": "P1", "title": "Тестирование сценариев бота", "description": "", "role": "qa", "hours": "18", "hours_kind": "actual"},
{"project": "P3", "title": "Разработка логотипа", "description": "", "role": "designer", "hours": "6", "hours_kind": "actual"},
]
def load_corpus(dsn: str, rows=None):
"""Import reference tasks into the test database with the offline hash embedder."""
async def go():
engine = make_engine(DatabaseCfg(dsn=dsn))
try:
store = SqlReferenceStore(make_session_factory(engine), engine.dialect.name)
return await ReferenceService(store, HashEmbedder()).import_rows(rows or CORPUS, actor="test")
finally:
await engine.dispose()
return asyncio.run(go())
RAG_ENV = {
"EST_RAG__ENABLED": "true",
"EST_RAG__PROVIDER": "hash",
"EST_RAG__MIN_SIMILARITY": "0.3",
"EST_RAG__TOP_K": "2",
}