1. When company_matcher returns [], keep full company list as fallback instead of leaving AI with zero data
2. Add explicit "no results" instruction in prompt to prevent hallucinated company names
3. Hide cost badge chip from non-admin users (IS_ADMIN gate)
4. Add 60s AbortController timeout on streaming fetch to prevent hung connections
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
AI writes hallucinated company names at start of bullet points without
any prefix word. New pattern catches "* CompanyName to/–/specjalizuje"
and removes the fake name if it's not in the database.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
AI bypasses link/bold validation by mentioning companies as plain text
like "firma Baumar" or "również Pro-Bud". New regex catches these patterns
and removes them if the company name isn't in the database.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The actual Flask route is /company/<slug>, not /firma/<slug>.
All link generation, validation, and prompt instructions now use /company/.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Three layers of defense:
1. PROMPT: explicit whitelist of allowed company names + slugs
2. VALIDATOR: link slug verification (existing)
3. VALIDATOR: bold text scan — removes **FakeName** if not in DB
AI can no longer mention companies as plain/bold text to bypass link validation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- AI generates "inpi-sp-z-o-o" but real slug is "inpi" → now auto-corrected
- Fuzzy prefix matching on slugs (handles legal form suffixes)
- Name-based resolution as fallback (match link text to company name)
- Hallucinated companies: keep text, remove link (instead of deleting entirely)
- Better cleanup of artifacts ("oraz –", empty bullets)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prompt rules don't work — AI ignores them and invents company names.
Added _validate_company_references() post-processor that:
- Loads all valid company slugs from DB
- Scans every /firma/ link in AI response
- REMOVES links to companies that don't exist
- Cleans up empty list items left by removals
- Applied to BOTH send_message() and send_message_stream()
This is the ONLY reliable way to prevent hallucinated companies.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- NordaGPT icon (nordagpt-icon.svg) as AI avatar instead of "AI" text
- User profile photo as avatar (falls back to initial letter)
- CRITICAL: added strict rule to never hallucinate company names
- Only mention companies that exist in the provided database
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Wire Smart Router and Context Builder into send_message(): queries are now classified,
only needed data is loaded via build_selective_context(), and model/thinking level
are determined by the router. Falls back to full context if router is unavailable.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Added description_full, core_values, services_offered, and
technologies_used to the AI context builder. Previously only
description_short and founding_history were used by NordaGPT.
Added "Wykorzystywany przez NordaGPT" hints to all relevant fields
in the company edit form so users know their content feeds the AI.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add year range validation (2020-2100) on /kalendarz/ to prevent ValueError crash
- Exempt notification/message unread-count endpoints from rate limiting (shared IP via NAT)
- Replace deprecated google.generativeai SDK with google-genai in nordabiz_chat.py
- Remove dead news_service import that logged warnings on every worker startup
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MANAGER/EMPLOYEE/VIEWER are portal permission levels, not job titles.
Rename field to portal_role with labels: administrator profilu, pracownik,
obserwator — so chatbot doesn't misinterpret them as company positions.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove is_verified filter so chatbot sees all active users assigned to a
company. Add 'verified' field so AI can inform about account status.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extends chatbot to include verified portal users alongside KRS/CEIDG data,
so NordaGPT can answer questions about company representatives who registered
on the portal but aren't listed in official registries.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Since NordaGPT access is now restricted to MEMBER role at the route
level (blueprints/chat/routes.py), the per-field filtering of phone
and email in nordabiz_chat.py is redundant.
Simplifies the code by removing:
- User import and loading in send_message()
- can_view_contacts parameter passing through the call chain
- Conditional phone/email inclusion in _company_to_compact_dict()
- Dynamic system prompt about contact data availability
Access control is now enforced at a single point (route decorator).
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add role-based access control to AI chat context
- Phone/email only visible to users with MEMBER role or higher
- Load User object in send_message() to check can_view_contacts()
- Pass permission through _build_conversation_context() to _company_to_compact_dict()
- Update AI system prompt to inform about contact data availability
- Non-members are directed to company profiles for contact details
This fixes a security gap where contact data was exposed to all users
regardless of their membership status in the organization.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Dodano sekcję DANE WRAŻLIWE do system prompt
- AI odmówi odpowiedzi na pytania o PESEL, dowody, paszporty, karty
- Instrukcja: 'Przepraszam, nie mogę podawać informacji o numerach PESEL'
- Zapobiega halucynacjom AI łączącym zamaskowane dane z osobami z bazy
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Zmiana domyślnego modelu w dokumentacji i kodzie:
- gemini-2.5-flash → gemini-3-flash-preview
- gemini-2.5-pro → gemini-3-pro-preview
Zaktualizowane pliki:
- README.md - opis technologii
- docs/architecture/*.md - diagramy i przepływy
- nordabiz_chat.py - fallback model name
- zopk_news_service.py - model dla AI evaluation
- templates/admin/zopk_dashboard.html - wyświetlany model
Zachowano mapowania legacy modeli dla kompatybilności wstecznej.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
UI:
- Dropdown wyboru modelu: Flash (szybki, $0.05) vs Pro (analiza, $0.20)
- Wyświetlanie kosztu miesięcznego w headerze
- Badge odpowiedzi pokazuje: model, czas, koszt
Backend:
- Endpoint /api/chat/settings obsługuje model i monthly_cost
- NordaBizChatEngine przyjmuje parametr model
- Koszt zapisywany w tech_info odpowiedzi
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Tryb głęboki: wymaga rozbudowanej analizy, list, kontekstu
- Tryb szybki: zwięzłe odpowiedzi z linkami
- Dodano przykład odpowiedzi w trybie głębokim
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Naprawiono URL w kontekście (był /forum/topic/X, prawidłowy /forum/X)
- Dodano instrukcje o linkach do forum, B2B, news w system prompt
- Model MUSI używać URL z pola "url" przy odpowiedziach o forum
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Forum: treść tematów, autorzy, odpowiedzi, linki, popularność
- B2B: pełne opisy ogłoszeń, budżet, autor
- News: opis, AI streszczenie, słowa kluczowe, linki
Automatyczne wykrywanie i maskowanie danych wrażliwych w czacie:
- PESEL (walidacja sumy kontrolnej)
- Numery kart kredytowych (algorytm Luhn)
- IBAN (konta bankowe)
- Hasła (detekcja kontekstowa)
- Dowody osobiste i paszporty
NIE wykrywa (zgodnie z wymogami):
- NIP (publiczne dane biznesowe)
- Adresy email (celowo podawane)
API dla adminów: POST /api/admin/test-sanitization
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
ZMIANY BEZPIECZEŃSTWA:
1. Defense in depth w NordaBizChatEngine:
- send_message() - wymaga user_id i weryfikuje właściciela rozmowy
- get_conversation_history() - opcjonalna walidacja user_id
- Logowanie prób nieautoryzowanego dostępu
2. Anonimizacja w panelu admina:
- Usunięto wyświetlanie treści zapytań użytkowników
- Zastąpiono statystykami: długość, kategoria tematyczna
- Zachowano AI responses (publiczne dane firm)
3. Ochrona prywatności:
- Użytkownicy NIE mogą zobaczyć zapytań innych użytkowników
- Admini widzą tylko zanonimizowane statystyki
- Audit logging dla prób nieautoryzowanego dostępu
Odblokowuje zadanie #10 (Baza wiedzy Norda GPT).
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- DB stores names in UPPERCASE (e.g. 'MICHAŁ BOGDAN ROSZMAN')
- AI generates Title Case (e.g. 'Michał Bogdan Roszman')
- Post-processing now converts to title() before matching
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Call _postprocess_links() on AI response before returning
- Ensures companies and people are linked even when AI doesn't format them
- Fixes inconsistent link generation by Gemini AI
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Dodano person_id i profile URL do kontekstu osób w chatbocie
- Zaktualizowano system prompt: OBOWIĄZKOWE linki dla firm i osób
- Dodano CSS dla linków do osób (zielony badge)
- Rozszerzono JavaScript o wykrywanie linków /osoba/
Kolory badge:
- 🏢 Firmy: pomarańczowy (#c2410c)
- 👤 Osoby: zielony (#047857)
- 🔗 Zewnętrzne: niebieski (#1d4ed8)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Backend (nordabiz_chat.py):
- Dodano instrukcję w system prompt wymagającą linków markdown
- Nazwy firm: [Firma](URL) - klikalne linki do profilu
- Nazwy osób: **Imię Nazwisko** (link do firmy)
Frontend (chat.html):
- Nowe style dla linków w wiadomościach
- Fioletowy kolor (#7c3aed) dla linków AI
- Hover effect z podkreśleniem
- Oddzielne style dla linków w wiadomościach użytkownika
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Dodano brakujące słowa kluczowe do _is_zopk_query():
- "kaszubia", "kaszub", "projekt kaszubia"
- "kamienie milowe", "roadmapa", "timeline", "harmonogram"
- "inwestycje pomorze", "inwestycje pomorskie", "rozwój pomorza"
Dzięki temu pytania takie jak "co wiesz o projekcie Kaszubia?"
będą rozpoznawane jako pytania ZOPK i chat będzie używał
bazy wiedzy.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Priorytet 1 - Panel admina bazy wiedzy ZOPK:
- /admin/zopk/knowledge - dashboard ze statystykami
- /admin/zopk/knowledge/chunks - lista chunks z filtrowaniem
- /admin/zopk/knowledge/facts - lista faktów z typami
- /admin/zopk/knowledge/entities - lista encji z mentions
- CRUD operacje: weryfikacja, usuwanie
Priorytet 2 - Poprawa jakości odpowiedzi NordaGPT:
- Linki markdown do źródeł w kontekście ZOPK
- Ulepszone formatowanie (bold, listy, nagłówki)
- Sekcja "Źródła" na końcu odpowiedzi
- Instrukcje w system prompt dla lepszej prezentacji
Priorytet 3 - Timeline ZOPK:
- Model ZOPKMilestone w database.py
- Migracja 016_zopk_milestones.sql z sample data
- Sekcja "Roadmapa ZOPK" na stronie /zopk
- Pionowa oś czasu z markerami lat
- Statusy: completed, in_progress, planned, delayed
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Dodano:
- Odmiany 'jądrowa/jądrowej/jądrowe/jądrowy'
- 'atomowa' i odmiany
- Konkretne nazwy: westinghouse, bechtel, arabelle, turbiny
- Więcej form offshore wind
- Rozszerzono infrastructure i energy keywords
Dzięki temu pytania jak 'turbiny dla elektrowni jądrowej'
będą poprawnie rozpoznawane jako ZOPK
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add explicit instruction to give EXACT number requested
- Change list format to single-line items (prevents numbering reset)
- Show correct vs incorrect format examples in prompt
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add comprehensive formatting instructions to AI system prompt
- Update linkifyText() and linkifyNordaGPT() to parse markdown:
- **bold** to <strong>
- Newlines to <br>
- Numbered lists (1. 2. 3.) to <ol>
- Bullet lists (- *) to <ul>
- Add CSS styles for AI response lists
- Fix NordaGPT minimize: banner now pulses and shows active state
- Banner button changes to "Wznów chat" when minimized
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Import CompanyWebsiteAnalysis model
- Query PageSpeed scores: SEO, performance, accessibility, best practices
- Add SEO audits description to system prompt
- Include website URLs and profile links
- AI can now answer questions about website SEO scores
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- GBP audits: added maps_url (Google Maps) and profile_url
- Social Media: added url field for each platform
- Companies: added profile link to nordabiznes.pl
- Updated AI instructions to always include links in responses
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Import Person, CompanyPerson, CompanySocialMedia, GBPAudit models
- Add company people (zarząd, wspólnicy, prokurenci) grouped by company
- Add social media profiles (platform + followers) grouped by company
- Add latest GBP audit scores (completeness, reviews, rating)
- Update system prompt with Stage 3 data descriptions
- Add new prompts for people lookup and GBP audit queries
- Update suggestion chips: "Kto jest prezesem?", "Google opinie?", "Fanów FB?"
AI chat now has access to:
- 80 companies + services + competencies
- Recommendations, News (Stage 1)
- Calendar events, B2B classifieds, Forum topics (Stage 2)
- KRS people, Social Media, GBP audits (Stage 3)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>