Pluggable conversational AI chatbot for the scrape-and-analyze platform.
This plugin provides a RAG-enabled chatbot that can answer questions based on scraped articles, analyses, and tags from the scrape-and-analyze database.
Status: Early development. See Roadmap for planned features.
# In your scrape-and-analyze directory
uv add chatbot-pluginIn your backend/main.py:
from chatbot_plugin.routers import chat_router
app.include_router(chat_router, prefix="/chat", tags=["chat"])CHATBOT_LLM_PROVIDER=claude
CHATBOT_LLM_MODEL=claude-sonnet-4-6-20250514
CHATBOT_MAX_CONTEXT_ARTICLES=10
CHATBOT_MAX_CONTEXT_TOKENS=8000curl -X POST http://localhost:8000/chat/message \
-H "Content-Type: application/json" \
-d '{"message": "What articles discuss RAG implementation?"}'chatbot-plugin/
├── pyproject.toml # Package definition & dependencies
├── src/
│ └── chatbot_plugin/
│ ├── __init__.py # Package entry point
│ ├── config.py # Pydantic settings (CHATBOT_* env vars)
│ ├── routers.py # FastAPI router endpoints
│ └── service.py # Core chat logic (stub)
└── tests/
└── test_service.py # Unit tests
All settings are read from environment variables with the CHATBOT_ prefix:
| Variable | Default | Description |
|---|---|---|
CHATBOT_LLM_PROVIDER |
claude |
LLM provider: claude, gemini, openrouter |
CHATBOT_LLM_MODEL |
claude-sonnet-4-6-20250514 |
Model name |
CHATBOT_MAX_CONTEXT_ARTICLES |
10 |
Max articles to retrieve for RAG context |
CHATBOT_MAX_CONTEXT_TOKENS |
8000 |
Max tokens in prompt |
Send a message and receive a chatbot reply.
Request:
{
"message": "What articles discuss RAG implementation?",
"user_id": "optional-user-id"
}Response:
{
"reply": "Based on 3 articles, RAG implementation involves...",
"articles_used": 3
}uv run pytest src/tests/ -vuv run pytest src/tests/ --cov=chatbot_plugin --cov-report=html- LLM provider integration (Claude, Gemini) via LangChain
- RAG context retrieval from PostgreSQL (text-based first)
- Streaming responses (SSE)
- Chat history persistence
- Multi-turn conversation support
- Citation/linkback to source articles
- Embedding & hybrid search (BGE-M3 dense + sparse, RRF fusion, pgvector)
- Frontend chat UI component
MIT