feat: Neuheiten-Suche — 1.861 Spiele in DB + Chatbot-Integration

- 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
This commit is contained in:
Hermes Agent
2026-06-18 14:44:22 +02:00
parent ced5604799
commit 4b50bbfd37
+39
View File
@@ -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"