Compare commits
6 Commits
95715dcae7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 146421960c | |||
| 304e4dae6d | |||
| dce020d637 | |||
| 15f8a57d3a | |||
| a990e704d9 | |||
| c8980abe2b |
11
.env
11
.env
@@ -1,11 +0,0 @@
|
|||||||
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 +1,4 @@
|
|||||||
src/rag_agent/.env
|
src/rag_agent/.env
|
||||||
|
.env
|
||||||
|
docker/ssh
|
||||||
|
docker/postgres_data
|
||||||
16
README.md
16
README.md
@@ -123,7 +123,21 @@ 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,6 +58,31 @@ 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 +0,0 @@
|
|||||||
18
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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