AI Engine Architecture
Overview
Vartovii includes a built-in AI assistant powered by Google Vertex AI (Gemini).
System Architecture
backend/ai/
├── config.py # Model & region configuration
├── client.py # GeminiClient singleton
├── services/
│ ├── chat_service.py # Chat assistant (RAG + Tools)
│ ├── report_service.py # PDF Report generation
│ └── sentiment_service.py # Review analysis
└── tools/
├── crypto_tools.py # Blockchain data
└── search_tools.py # Google Grounding
Models Strategy
| Task | Model | Reason |
|---|---|---|
| Chat Assistant | gemini-3-flash-preview | Low latency, high throughput (with 2.5 fallback) |
| Smart Reports | gemini-3.1-pro-preview | Complex reasoning, large context (with 2.5 fallback) |
| Sentiment | gemini-3-flash-preview | Cost efficiency for bulk processing |
| Visuals | Imagen 3 | Generating social media assets |
API Endpoints
AI Chat
POST /api/ai/chat
- Payload:
{"message": "Analyze BMW", "language": "ua"} - Features: Function Calling, RAG (Vector Search), Context Retention.
Smart Reports
POST /api/reports/generate
- Payload:
{"company_slug": "bmw"} - Output: PDF Download URL.
RAG & Knowledge Base
The AI Engine is grounded in real-time data from:
- PostgreSQL: Trust Scores, Financials, Reviews.
- Vector Store: Indexed internal documentation (Knowledge Base).
- Google Search: Live web grounding for recent events.
Configuration
Managed via backend/ai/config.py and environment variables:
PROJECT_ID: sentry-analytics-prodREGION: europe-west4 (for data residency)