Перейти до основного вмісту

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

TaskModelReason
Chat Assistantgemini-3-flash-previewLow latency, high throughput (with 2.5 fallback)
Smart Reportsgemini-3.1-pro-previewComplex reasoning, large context (with 2.5 fallback)
Sentimentgemini-3-flash-previewCost efficiency for bulk processing
VisualsImagen 3Generating 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:

  1. PostgreSQL: Trust Scores, Financials, Reviews.
  2. Vector Store: Indexed internal documentation (Knowledge Base).
  3. Google Search: Live web grounding for recent events.

Configuration

Managed via backend/ai/config.py and environment variables:

  • PROJECT_ID: sentry-analytics-prod
  • REGION: europe-west4 (for data residency)