π€ AI Integration Documentation
Overviewβ
Vartovii includes a built-in AI assistant powered by Google Vertex AI (Gemini).
Architectureβ
backend/ai/
βββ config.py # Model & region configuration
βββ client.py # GeminiClient singleton
βββ services/
β βββ chat_service.py # Chat assistant
β βββ report_service.py # Company reports
β βββ sentiment_service.py # Sentiment analysis
βββ prompts/
βββ chat.py # Knowledge base
βββ report.py # Report templates
βββ sentiment.py # Sentiment prompts
backend/api/
βββ chat.py # FastAPI endpoint /api/ai/chat
Models Usedβ
| Task | Current production profile | Fallback path |
|---|---|---|
| Chat | gemini-3.5-flash | gemini-2.5-flash + 2.0 |
| Reports | gemini-3.1-pro-preview | Gemini 2.5 / 2.0 chain |
| Sentiment | gemini-3.5-flash | gemini-2.5-flash + 2.0 |
| ADK paths | gemini-3.5-flash | gemini-2.5-flash + 2.0 |
Production currently uses GEMINI_MODEL_PROFILE=preview with Gemini 3.x
models. The stable Gemini 2.5 profile remains available as a rollback path when
availability, location policy, or rollout risk requires it.
API Endpointβ
POST /api/ai/chatβ
Request:
{
"message": "Π©ΠΎ ΡΠ°ΠΊΠ΅ Trust Score?",
"language": "ua",
"history": [],
"company": "BMW"
}
Response:
{
"response": "Trust Score β ΡΠ΅...",
"status": "ok"
}
Frontend Widgetβ
Located at: dashboard_app/src/components/ChatWidget.jsx
- Floating button (bottom-right)
- Glass-card chat panel
- Multi-turn conversation history
- Auto language detection
Configurationβ
Required environment variables in backend/.env:
GOOGLE_CLOUD_PROJECT=sentry-analytics-prod
GEMINI_LOCATION=global
RAG_EMBEDDING_LOCATION=europe-west4
SEARCH_LOCATION=global
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json
Usageβ
Start all services:
./scripts/startup.sh
Test chat API:
curl -X POST http://localhost:8000/api/ai/chat \
-H "Content-Type: application/json" \
-d '{"message":"ΠΡΠΈΠ²ΡΡ!","language":"ua"}'
Knowledge Baseβ
The AI knows about:
- Trust Score formula (Company & Crypto)
- Data sources (Kununu, Glassdoor, Reddit, etc.)
- Platform features and pricing
- How to use the platform
- FAQs