Compare commits
1 Commits
main
...
95715dcae7
| Author | SHA1 | Date | |
|---|---|---|---|
| 95715dcae7 |
11
.env
Normal file
11
.env
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
RAG_DB_DSN=postgresql://rag:rag_secret@localhost:5432/rag
|
||||||
|
RAG_REPO_PATH=/Users/alex/Dev_projects_v2/documentation/
|
||||||
|
|
||||||
|
GIGACHAT_CREDENTIALS=MGMyOGExMzctZDY1YS00OGNkLTk3NGYtYzFkZWVjOTEzM2RkOjFjOTc0YjFlLWNlMDUtNDM4Zi04ZDA2LWZkODA5MjRhZTY3NA==
|
||||||
|
GIGACHAT_EMBEDDINGS_MODEL=Embeddings
|
||||||
|
GIGACHAT_VERIFY_SSL=false
|
||||||
|
|
||||||
|
RAG_CHUNK_SIZE_LINES=20
|
||||||
|
RAG_CHUNK_SIZE=300
|
||||||
|
|
||||||
|
RAG_EMBEDDINGS_DIM=1024
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1 @@
|
|||||||
src/rag_agent/.env
|
src/rag_agent/.env
|
||||||
.env
|
|
||||||
docker/ssh
|
|
||||||
docker/postgres_data
|
|
||||||
16
README.md
16
README.md
@@ -123,21 +123,7 @@ Scripts: `scripts/create_db.py` (Python, uses `ensure_schema` and `RAG_*` env),
|
|||||||
|
|
||||||
If `GIGACHAT_CREDENTIALS` is set (e.g. in `.env` for local runs), embeddings use GigaChat API; otherwise the stub client is used. Optional env: `GIGACHAT_EMBEDDINGS_MODEL` (default `Embeddings`), `GIGACHAT_VERIFY_SSL` (`true`/`false`). Ensure `RAG_EMBEDDINGS_DIM` matches the model output (see GigaChat docs).
|
If `GIGACHAT_CREDENTIALS` is set (e.g. in `.env` for local runs), embeddings use GigaChat API; otherwise the stub client is used. Optional env: `GIGACHAT_EMBEDDINGS_MODEL` (default `Embeddings`), `GIGACHAT_VERIFY_SSL` (`true`/`false`). Ensure `RAG_EMBEDDINGS_DIM` matches the model output (see GigaChat docs).
|
||||||
|
|
||||||
## Agent (GigaChat)
|
|
||||||
|
|
||||||
Ответы на вопросы формирует агент на базе GigaChat: поиск по базе знаний (RAG) + генерация текста. Если задана переменная `GIGACHAT_CREDENTIALS`, используется `GigaChatLLMClient` в `src/rag_agent/agent/pipeline.py`; иначе — заглушка. Модель чата задаётся через `RAG_LLM_MODEL` (по умолчанию `GigaChat`).
|
|
||||||
|
|
||||||
## Telegram-бот
|
|
||||||
|
|
||||||
Общение с пользователем через бота в Telegram: бот отвечает на текстовые сообщения, используя знания из базы (RAG + GigaChat).
|
|
||||||
|
|
||||||
1. Создайте бота через [@BotFather](https://t.me/BotFather) и получите токен.
|
|
||||||
2. Добавьте в `.env`: `TELEGRAM_BOT_TOKEN=<токен>`.
|
|
||||||
3. Запуск: `rag-agent bot` (или `python -m rag_agent.telegram_bot`).
|
|
||||||
4. Через Docker: `docker compose up -d` поднимает БД, вебхук-сервер и бота в отдельных контейнерах; в `.env` должен быть задан `TELEGRAM_BOT_TOKEN`.
|
|
||||||
|
|
||||||
Требуются: `RAG_DB_DSN`, `RAG_REPO_PATH`, `GIGACHAT_CREDENTIALS`, `TELEGRAM_BOT_TOKEN`. Расширенное логирование (входящие сообщения, число эмбеддингов, число чанков из БД, ответ LLM): `RAG_BOT_VERBOSE_LOGGING=true|false` (по умолчанию `true` для отладки).
|
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
- LLM client is still a stub; replace it in `src/rag_agent/agent/pipeline.py` for real answers.
|
||||||
- This project requires Postgres with the `pgvector` extension.
|
- This project requires Postgres with the `pgvector` extension.
|
||||||
|
|||||||
@@ -58,31 +58,6 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- rag_net
|
- rag_net
|
||||||
|
|
||||||
bot:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
image: rag-agent:latest
|
|
||||||
container_name: rag-bot
|
|
||||||
restart: unless-stopped
|
|
||||||
depends_on:
|
|
||||||
postgres:
|
|
||||||
condition: service_healthy
|
|
||||||
environment:
|
|
||||||
RAG_DB_DSN: "postgresql://${POSTGRES_USER:-rag}:${POSTGRES_PASSWORD:-rag_secret}@postgres:5432/${POSTGRES_DB:-rag}"
|
|
||||||
RAG_REPO_PATH: "/data"
|
|
||||||
RAG_EMBEDDINGS_DIM: ${RAG_EMBEDDINGS_DIM:-1024}
|
|
||||||
GIGACHAT_CREDENTIALS: ${GIGACHAT_CREDENTIALS:-}
|
|
||||||
GIGACHAT_EMBEDDINGS_MODEL: ${GIGACHAT_EMBEDDINGS_MODEL:-Embeddings}
|
|
||||||
TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN:-}
|
|
||||||
RAG_BOT_VERBOSE_LOGGING: ${RAG_BOT_VERBOSE_LOGGING:-true}
|
|
||||||
volumes:
|
|
||||||
- ${RAG_REPO_HOST:-${RAG_REPO_PATH:-./data}}:/data
|
|
||||||
entrypoint: ["rag-agent"]
|
|
||||||
command: ["bot"]
|
|
||||||
networks:
|
|
||||||
- rag_net
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
rag_net:
|
rag_net:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|||||||
1
docker/postgres_test_data/18/docker/PG_VERSION
Normal file
1
docker/postgres_test_data/18/docker/PG_VERSION
Normal file
@@ -0,0 +1 @@
|
|||||||
|
18
|
||||||
BIN
docker/postgres_test_data/18/docker/base/1/112
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/112
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/113
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/113
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/1247
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/1247
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/1247_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/1247_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/1247_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/1247_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/1249
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/1249
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/1249_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/1249_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/1249_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/1249_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/1255
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/1255
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/1255_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/1255_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/1255_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/1255_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/1259
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/1259
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/1259_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/1259_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/1259_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/1259_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/13476
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13476
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/13476_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13476_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/13476_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13476_vm
Normal file
Binary file not shown.
0
docker/postgres_test_data/18/docker/base/1/13479
Normal file
0
docker/postgres_test_data/18/docker/base/1/13479
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13480
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13480
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/13481
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13481
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/13481_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13481_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/13481_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13481_vm
Normal file
Binary file not shown.
0
docker/postgres_test_data/18/docker/base/1/13484
Normal file
0
docker/postgres_test_data/18/docker/base/1/13484
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13485
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13485
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/13486
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13486
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/13486_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13486_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/13486_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13486_vm
Normal file
Binary file not shown.
0
docker/postgres_test_data/18/docker/base/1/13489
Normal file
0
docker/postgres_test_data/18/docker/base/1/13489
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13490
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13490
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/13491
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13491
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/13491_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13491_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/13491_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13491_vm
Normal file
Binary file not shown.
0
docker/postgres_test_data/18/docker/base/1/13494
Normal file
0
docker/postgres_test_data/18/docker/base/1/13494
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13495
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/13495
Normal file
Binary file not shown.
0
docker/postgres_test_data/18/docker/base/1/1417
Normal file
0
docker/postgres_test_data/18/docker/base/1/1417
Normal file
0
docker/postgres_test_data/18/docker/base/1/1418
Normal file
0
docker/postgres_test_data/18/docker/base/1/1418
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/174
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/174
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/175
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/175
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2187
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2187
Normal file
Binary file not shown.
0
docker/postgres_test_data/18/docker/base/1/2224
Normal file
0
docker/postgres_test_data/18/docker/base/1/2224
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2228
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2228
Normal file
Binary file not shown.
0
docker/postgres_test_data/18/docker/base/1/2328
Normal file
0
docker/postgres_test_data/18/docker/base/1/2328
Normal file
0
docker/postgres_test_data/18/docker/base/1/2336
Normal file
0
docker/postgres_test_data/18/docker/base/1/2336
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2337
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2337
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2579
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2579
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2600
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2600
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2600_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2600_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2600_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2600_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2601
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2601
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2601_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2601_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2601_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2601_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2602
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2602
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2602_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2602_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2602_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2602_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2603
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2603
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2603_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2603_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2603_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2603_vm
Normal file
Binary file not shown.
0
docker/postgres_test_data/18/docker/base/1/2604
Normal file
0
docker/postgres_test_data/18/docker/base/1/2604
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2605
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2605
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2605_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2605_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2605_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2605_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2606
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2606
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2606_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2606_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2606_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2606_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2607
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2607
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2607_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2607_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2607_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2607_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2608
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2608
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2608_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2608_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2608_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2608_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2609
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2609
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2609_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2609_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2609_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2609_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2610
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2610
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2610_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2610_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2610_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2610_vm
Normal file
Binary file not shown.
0
docker/postgres_test_data/18/docker/base/1/2611
Normal file
0
docker/postgres_test_data/18/docker/base/1/2611
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2612
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2612
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2612_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2612_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2612_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2612_vm
Normal file
Binary file not shown.
0
docker/postgres_test_data/18/docker/base/1/2613
Normal file
0
docker/postgres_test_data/18/docker/base/1/2613
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2615
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2615
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2615_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2615_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2615_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2615_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2616
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2616
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2616_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2616_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2616_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2616_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2617
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2617
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2617_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2617_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2617_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2617_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2618
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2618
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2618_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2618_fsm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2618_vm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2618_vm
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2619
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2619
Normal file
Binary file not shown.
BIN
docker/postgres_test_data/18/docker/base/1/2619_fsm
Normal file
BIN
docker/postgres_test_data/18/docker/base/1/2619_fsm
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user