From 4b50bbfd37e94fe0359e9c2e2dfc7f84d5728dbe Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Thu, 18 Jun 2026 14:44:22 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20Neuheiten-Suche=20=E2=80=94=201.861=20S?= =?UTF-8?q?piele=20in=20DB=20+=20Chatbot-Integration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Neue Tabelle 'neuheiten' mit 1.861 Spielen von spiel-essen.de - Themen-Namen aufgelöst (96 Kategorien: Flip'n'Write, Kartenspiel, etc.) - Chatbot /api/chat durchsucht jetzt Submissions + Aussteller + Neuheiten - Erweiterter Kontext bei Spiel/Neuheit-Fragen (bis 40 Treffer) - 586 Verlage mit Verlags-Suche --- app.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/app.py b/app.py index 1dc7ce6..6464079 100644 --- a/app.py +++ b/app.py @@ -3147,6 +3147,44 @@ def api_chat(): + (f" | {halle_stand}" if halle_stand else '') + (f" | {land}" if land else '') ) + # Also search neuheiten table for matching games + neuheiten_rows = [] + try: + neuheiten_rows = db.execute( + "SELECT titel, untertitel, halle, stand, info_text, themen, web FROM neuheiten LIMIT 1861" + ).fetchall() + except Exception: + neuheiten_rows = [] + + if neuheiten_rows: + scored_n = [] + for n in neuheiten_rows: + full_text = f"{n['titel'] or ''} {n['untertitel'] or ''} {n['halle'] or ''} {n['stand'] or ''} {n['info_text'] or ''} {n['themen'] or ''}".lower() + score = sum(1 for t in search_terms if t in full_text) + if score > 0: + scored_n.append((score, n)) + scored_n.sort(key=lambda x: -x[0]) + # Add top matching games + for _, n in scored_n[:20]: + halle_stand = f"{n['halle'] or ''} {n['stand'] or ''}".strip() + verlag = n['untertitel'] or '' + themen = (n['themen'] or '').strip() + context_parts.append( + f"[Neuheit] {n['titel']}" + + (f" | Verlag: {verlag}" if verlag else '') + + (f" | {halle_stand}" if halle_stand else '') + + (f" | {themen}" if themen else '') + ) + # For game/neuheit-specific queries, add more results + if any(t in user_message.lower() for t in ['neuheit', 'neuheiten', 'spiel', 'spiele', 'brettspiel', 'kartenspiel', 'würfelspiel', 'game', 'neu']): + for _, n in scored_n[:40]: + halle_stand = f"{n['halle'] or ''} {n['stand'] or ''}".strip() + verlag = n['untertitel'] or '' + context_parts.append( + f"[Neuheit] {n['titel']}" + + (f" | Verlag: {verlag}" if verlag else '') + + (f" | {halle_stand}" if halle_stand else '') + ) context = '\n'.join(context_parts) # System prompt @@ -3161,6 +3199,7 @@ def api_chat(): "- Halte Antworten kurz und präzise (2-4 Sätze).\n" "- Bei Standortfragen nenne immer die Hallen-Nummer.\n" "- [Aussteller]-Einträge enthalten Verlage/Shops mit Halle, Stand und Land.\n" + "- [Neuheit]-Einträge enthalten Brettspiel-Neuheiten mit Verlag, Halle, Stand und Kategorien.\n" "- Wenn du einen Beitrag erwähnst, verlinke ihn IMMER mit der Beitrags-ID aus dem Kontext.\n" " Format: [Kurzbeschreibung](/beitrag/ID)\n" " Beispiel: 'Schau dir [diesen Erfahrungsbericht](/beitrag/53) an!'\n"