Add RAG basic implementation
This commit is contained in:
@@ -121,3 +121,37 @@ estimate (default by the client's region in `[pricing.vat]`: Russian client 22%,
|
||||
stored with the version; changing it creates a new version without recalculation. Market benchmarks
|
||||
carry `includes_vat`/`vat_rate` and are converted to prices without VAT before the check. See
|
||||
`docs/adr/0002-vat-layer.md`.
|
||||
|
||||
## Reference tasks (RAG)
|
||||
|
||||
Similar past work can anchor the estimate of every task. It is off by default; load a corpus first.
|
||||
|
||||
```bash
|
||||
# refs.csv (UTF-8, header row): project,title,description,role,hours,hours_kind,source
|
||||
# role: analyst|backend|frontend|qa|devops|designer (may be empty); hours_kind: actual|estimate
|
||||
python -m estimator rag import refs.csv --dry-run # validate only
|
||||
python -m estimator rag import refs.csv # load and embed
|
||||
python -m estimator rag stats # size and state of the corpus
|
||||
python -m estimator rag search "integration with a CRM" --role backend
|
||||
export EST_RAG__ENABLED=true # then switch retrieval on
|
||||
```
|
||||
|
||||
PostgreSQL uses pgvector with an HNSW index (the migration runs `CREATE EXTENSION vector`, so the
|
||||
extension must be installed on the server); SQLite searches in Python, which is fine for development.
|
||||
Embeddings come from an OpenAI-compatible `/embeddings` endpoint (`EST_RAG__API_KEY`, or the OpenAI key of
|
||||
the llm section); `EST_RAG__PROVIDER=hash` is a weak offline embedder for development and tests.
|
||||
The vector size is fixed at 1536 by the schema. Details and limits: `docs/adr/0003-rag-reference-tasks.md`.
|
||||
|
||||
## Docker
|
||||
|
||||
```bash
|
||||
cp .env.example .env # POSTGRES_PASSWORD, LLM key(s), EST_API__KEYS
|
||||
docker compose up -d --build # db -> migrate (applies the schema, then exits) -> app
|
||||
curl http://localhost:8000/health
|
||||
```
|
||||
|
||||
Start order: the database becomes healthy, the one-shot `migrate` service applies the migrations, and
|
||||
only if it succeeds does `app` start. `MIGRATE_ON_START=true` does the same inside one container.
|
||||
Backups, updates, creating UI users, loading the RAG corpus and running behind a reverse proxy:
|
||||
`docs/deployment.md`. The image runs as a non-root user and uses `EST_ENV=prod` (secure session cookies).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user