fix(nordagpt): use /company/ URLs instead of /firma/ — fixes all 404 links
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
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
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>
This commit is contained in:
parent
855856dc99
commit
337f229a05
@ -177,7 +177,7 @@ class NordaBizChatEngine:
|
||||
for slug, name in valid_companies.items():
|
||||
name_to_slug[name.lower()] = slug
|
||||
|
||||
# 1. Validate markdown links to /firma/slug — fix or remove
|
||||
# 1. Validate markdown links to /company/slug — fix or remove
|
||||
def replace_link(match):
|
||||
link_text = match.group(1)
|
||||
slug = match.group(2)
|
||||
@ -188,17 +188,17 @@ class NordaBizChatEngine:
|
||||
correct_slug = NordaBizChatEngine._find_correct_slug(slug, valid_slugs, name_to_slug)
|
||||
if correct_slug:
|
||||
logger.info(f"NordaGPT slug corrected: '{slug}' → '{correct_slug}'")
|
||||
return f'[{link_text}](/firma/{correct_slug})'
|
||||
return f'[{link_text}](/company/{correct_slug})'
|
||||
# Try matching by link text (company name)
|
||||
name_slug = name_to_slug.get(link_text.lower().strip())
|
||||
if name_slug:
|
||||
logger.info(f"NordaGPT slug resolved by name: '{link_text}' → '{name_slug}'")
|
||||
return f'[{link_text}](/firma/{name_slug})'
|
||||
return f'[{link_text}](/company/{name_slug})'
|
||||
# No match — hallucination, keep just the text without link
|
||||
logger.warning(f"NordaGPT hallucination blocked: '{link_text}' (slug: '{slug}') not in DB")
|
||||
return link_text # Keep text, remove link
|
||||
|
||||
text = re.sub(r'\[([^\]]+)\]\(/firma/([a-z0-9-]+)\)', replace_link, text)
|
||||
text = re.sub(r'\[([^\]]+)\]\(/company/([a-z0-9-]+)\)', replace_link, text)
|
||||
|
||||
# 2. Validate pill-style links
|
||||
def replace_pill_link(match):
|
||||
@ -209,11 +209,11 @@ class NordaBizChatEngine:
|
||||
return full_match
|
||||
correct_slug = NordaBizChatEngine._find_correct_slug(slug, valid_slugs, name_to_slug)
|
||||
if correct_slug:
|
||||
return full_match.replace(f'/firma/{slug}', f'/firma/{correct_slug}')
|
||||
return full_match.replace(f'/company/{slug}', f'/company/{correct_slug}')
|
||||
logger.warning(f"NordaGPT hallucination blocked: pill link '{slug}' not in DB")
|
||||
return link_text
|
||||
|
||||
text = re.sub(r'<a[^>]*href=["\']/firma/([a-z0-9-]+)["\'][^>]*>(.*?)</a>', replace_pill_link, text)
|
||||
text = re.sub(r'<a[^>]*href=["\']/company/([a-z0-9-]+)["\'][^>]*>(.*?)</a>', replace_pill_link, text)
|
||||
|
||||
# 3. Remove plain-text mentions of fake companies (bold or plain)
|
||||
# Catch patterns like "**Baumar**" or "Baumar" that appear as company names
|
||||
@ -1134,9 +1134,9 @@ ZASADY PERSONALIZACJI:
|
||||
ABSOLUTNY ZAKAZ HALUCYNACJI FIRM:
|
||||
- NIGDY nie wymyślaj nazw firm. To jest NAJWAŻNIEJSZA zasada.
|
||||
- Wymieniaj WYŁĄCZNIE firmy z sekcji "FIRMY W BAZIE" poniżej — żadnych innych.
|
||||
- Każdą firmę podawaj WYŁĄCZNIE jako link: [Nazwa Firmy](/firma/slug) — używając dokładnego slug z bazy.
|
||||
- Każdą firmę podawaj WYŁĄCZNIE jako link: [Nazwa Firmy](/company/slug) — używając dokładnego slug z bazy.
|
||||
- Jeśli żadna firma z bazy nie pasuje do zapytania, napisz wprost: "W bazie Izby nie znalazłem firmy o takim profilu."
|
||||
- NIE WYMIENIAJ firm jako zwykły tekst (bold, kursywa) — TYLKO jako link [Nazwa](/firma/slug).
|
||||
- NIE WYMIENIAJ firm jako zwykły tekst (bold, kursywa) — TYLKO jako link [Nazwa](/company/slug).
|
||||
- NIE UŻYWAJ nazw firm ze swojej wiedzy ogólnej — TYLKO z dostarczonej bazy.
|
||||
- Złamanie tej zasady oznacza linkowanie do nieistniejących stron (404) co jest niedopuszczalne.
|
||||
"""
|
||||
@ -1412,9 +1412,9 @@ W dyskusji [Artur Wiertel](link) pytał o moderację. Pełna treść: [moje uwag
|
||||
for c in context['all_companies']:
|
||||
name = c.get('name', '')
|
||||
profile = c.get('profile', '')
|
||||
slug = profile.replace('/firma/', '') if profile else ''
|
||||
slug = profile.replace('/company/', '') if profile else ''
|
||||
if name and slug:
|
||||
whitelist_lines.append(f" {name} → [link](/firma/{slug})")
|
||||
whitelist_lines.append(f" {name} → [link](/company/{slug})")
|
||||
system_prompt += "\n\n⚠️ DOZWOLONE FIRMY — możesz wymieniać TYLKO te (użyj dokładnie podanego linku):\n"
|
||||
system_prompt += "\n".join(whitelist_lines)
|
||||
system_prompt += "\n\n🏢 SZCZEGÓŁY FIRM:\n"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user