Google deprecated text-embedding-004 on v1beta API (returns 404 NOT_FOUND).
Migrated to gemini-embedding-001 with output_dimensionality=768 to maintain
compatibility with 412 existing embeddings in the database.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. Switch to Gemini Structured Output (response_schema) for audit AI analysis
- Enforces valid JSON from API, ~95% → ~99% reliability
- Fallback to manual cleaning if structured output fails
2. Add JSON parse failure rate metric - logs to AIUsageLog for monitoring
3. Add Gemini 3 Pro preview model monitoring warning at service init
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add per-call model override parameter to generate_text()
- GBP audit, SEO/social audit analysis, and audit content generation
now use gemini-3-pro-preview for highest quality reasoning
- Chat and other features remain on 3-flash (cheaper, faster)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Switch primary model from flash-lite (2.5) to 3-flash (Gemini 3 Flash Preview)
for better reasoning and thinking mode across all AI features
- Add _is_retryable() method to handle 503 UNAVAILABLE (server overload)
in addition to existing 429 rate limit fallback
- Fallback chain: 3-flash → 2.5-flash-lite → 2.5-flash
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Switch primary model to flash-lite (1000 RPD) with automatic fallback
to 3-flash-preview (20 RPD) and flash (20 RPD) on RESOURCE_EXHAUSTED,
giving 1040 req/day on free tier instead of 20.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- HIGH: Fix SQL injection in ZOPK knowledge service (3 functions) — replace f-strings with parameterized queries
- MEDIUM: Sanitize tsquery/LIKE input in SearchService to prevent injection
- MEDIUM: Add @login_required + @role_required(ADMIN) to /health/full endpoint
- MEDIUM: Add @role_required(ADMIN) to ZOPK knowledge search API
- MEDIUM: Add bleach HTML sanitization on write for announcements, events, board proceedings (stored XSS via |safe)
- MEDIUM: Remove partial API key from Gemini service logs
- MEDIUM: Remove @csrf.exempt from chat endpoints, add X-CSRFToken headers in JS
- MEDIUM: Add missing CSRF tokens to 3 POST forms (data_request, benefits_form, benefits_list)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- GOOGLE_GEMINI_API_KEY_FREE: klucz Free tier dla Flash (darmowy)
- GOOGLE_GEMINI_API_KEY: klucz Paid tier dla Pro (płatny)
- GeminiService automatycznie wybiera klucz na podstawie modelu
- Flash pricing ustawiony na $0.00 (Free tier)
- UI pokazuje Flash jako "Darmowy"
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Changed AI model from Gemini 2.5 Flash-Lite to Gemini 3 Flash Preview
- Added Gemini 3 models (3-flash, 3-pro) to GEMINI_MODELS config
- Updated GEMINI_PRICING with current 2026 prices
- Updated chat UI: badge, model info modal, specs, timeline
- Benefits: 7x better reasoning, thinking mode, 78% SWE-bench
Cost estimate: ~$40/month at 1000x current usage (Tier 1)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Problem: Gemini blokował treści o energetyce jako 'dangerous content'
Rozwiązanie: Przekazywanie safety_settings do API z BLOCK_NONE
Uwaga: FREE tier może nadal mieć ograniczenia
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add AIUsageLog, AIUsageDaily, AIRateLimit models to database.py
- Update gemini_service.py to log to new AIUsageLog table
- Create /admin/ai-usage dashboard with stats and charts
- Show daily/weekly/monthly requests, tokens, costs
- Track usage by type (chat, news_evaluation, etc.)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>