Commit Graph

19 Commits

Author SHA1 Message Date
5030b71beb chore: update Author to Maciej Pienczyn, InPi sp. z o.o. across all files
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 08:20:47 +02:00
a816d8adf7 Fix AI cost calculation — derive thinking tokens and correct pricing
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
- Thinking tokens were not counted (SDK field doesn't exist), now derived
  from total_token_count - prompt - candidates
- Remove separate thinking price rate — Google bills thinking at output rate
- Update GEMINI_PRICING to match Google pricing page (verified 2026-03-25)
- Net effect: ~2% cost increase per query (previously undercharging)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 14:05:43 +01:00
6c6f8054d2 chore: remove deprecated google-generativeai SDK and gemini-2.0-flash model
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
- Remove google-generativeai==0.8.6 from requirements.txt (no longer imported)
- Remove gemini-2.0-flash alias and pricing (deprecated March 31)
- Update test evaluator to use 3-flash instead of flash-2.0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 20:10:12 +01:00
3bc69f9455 feat: update Gemini models — migrate 3-pro to 3.1-pro, add 3.1-flash-lite, remove old SDK
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
- Replace gemini-3-pro-preview with gemini-3.1-pro-preview (old deprecated March 9)
- Add gemini-3.1-flash-lite-preview as quality fallback in chain
- Remove last google.generativeai import from zopk_knowledge_service.py
- Update pricing, thinking models, and preview models sets
- Keep '3-pro' alias for backward compatibility across codebase

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 19:45:33 +01:00
df8736297d fix(zopk): Update embedding model from text-embedding-004 to gemini-embedding-001
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
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>
2026-02-09 16:10:46 +01:00
81fea37666 feat(audit): Add Gemini Structured Output API + JSON parse failure tracking
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
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>
2026-02-08 10:55:35 +01:00
a6d7fc343e feat(ai): Use Gemini 3 Pro for audit analyses (GBP, SEO, social media)
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
- 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>
2026-02-07 17:39:44 +01:00
3d26ea6119 feat(ai): Upgrade to Gemini 3 Flash + add 503 fallback resilience
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
- 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>
2026-02-07 17:36:54 +01:00
14a8e8a3e9 feat(chat): Switch to Paid Tier 1 + Gemini 3 Flash/Pro for NordaGPT
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
- Always use GOOGLE_GEMINI_API_KEY (paid tier) instead of free tier
- Default chat model: Gemini 3 Flash (thinking mode, 10K RPD)
- Premium option: Gemini 3 Pro (250 RPD, best reasoning)
- Removed Flash Lite (2.5) from chat UI — only Gemini 3 generation
- Updated fallback chain for paid tier limits
- Updated pricing: 3-flash $0.50/$3.00 (was $0.00 on free tier)
- Added "Spróbuj Pro" upgrade hint after Flash responses
- Updated model info modal with paid tier pricing/limits

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 16:34:30 +01:00
5bd1b149c7 feat(ai): Add Gemini model fallback chain for 429 rate limit resilience
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
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>
2026-02-07 14:35:22 +01:00
e718d96a7d fix(security): Resolve 1 HIGH and 7 MEDIUM vulnerabilities from code review
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
- 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>
2026-02-06 05:25:18 +01:00
1b2ba66ead feat(chat): Dwa klucze API - Free tier dla Flash, Paid dla Pro
- 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>
2026-01-29 11:19:59 +01:00
31350d6428 fix: Add thinking_level to API logs for debugging 2026-01-29 10:30:00 +01:00
30729ef83e feat(ai): Thinking Mode dla NordaGPT
- Nowy SDK google-genai z obsługą thinking mode
- Przełącznik poziomu rozumowania w UI chatu (3 poziomy)
- Błyskawiczny (minimal) - szybkie odpowiedzi
- Szybki (low) - zrównoważony
- Głęboki (high) - maksymalna analiza
- Endpoint /api/chat/settings do zapisywania preferencji
- Dokumentacja dla NotebookLM (prezentacja)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 10:20:58 +01:00
e0df7f2adf feat(ai): Upgrade NordaGPT to Gemini 3 Flash Preview
- 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>
2026-01-29 08:38:02 +01:00
1136e9d40b fix(gemini): Przekazywanie safety_settings z BLOCK_NONE
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>
2026-01-16 20:43:33 +01:00
1b4cd31c41 feat(zopk): Knowledge Base + NordaGPT integration (FAZY 0-3)
FAZA 0 - Web Scraping:
- Migracja 015: pola full_content, scrape_status w zopk_news
- zopk_content_scraper.py: scraper z rate limiting i selektorami

FAZA 1 - Knowledge Extraction:
- zopk_knowledge_service.py: chunking, facts, entities extraction
- Endpointy /admin/zopk/knowledge/extract

FAZA 2 - Embeddings:
- gemini_service.py: generate_embedding(), generate_embeddings_batch()
- Model text-embedding-004 (768 dimensions)

FAZA 3 - NordaGPT Integration:
- nordabiz_chat.py: _is_zopk_query(), _get_zopk_knowledge_context()
- System prompt z bazą wiedzy ZOPK
- Semantic search w kontekście chatu

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 20:15:30 +01:00
bfe1cd897c feat: Add AI usage monitoring dashboard
- 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>
2026-01-11 08:21:07 +01:00
02fc67bf40 Initial commit 2026-01-01 14:01:49 +01:00