Zum Hauptinhalt springen

πŸ€– 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​

TaskModelWhy
Chatgemini-3-flash-previewFast responses (primary)
Reportsgemini-3.1-pro-previewHigh quality (primary)
Sentimentgemini-3-flash-previewCost-effective (primary)
Fallbacksgemini-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