π€ 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 | Model | Why |
|---|---|---|
| Chat | gemini-3-flash-preview | Fast responses (primary) |
| Reports | gemini-3.1-pro-preview | High quality (primary) |
| Sentiment | gemini-3-flash-preview | Cost-effective (primary) |
| Fallbacks | gemini-2.5-* | Automatic safety chain |
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=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