Replace counter-arguments with possible answers and unify search inputs.

Models, AI assistant, and UI now show diskussionsfertige Antworten without titles; shared search partial fixes aria-label rendering.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Pirmin Hinderling (fedora)
2026-07-07 22:50:53 +02:00
parent 28aab3b16a
commit 16428f2c16
19 changed files with 237 additions and 101 deletions
+18 -4
View File
@@ -20,6 +20,7 @@ Regeln:
- Quellen müssen echte, nachvollziehbare Referenzen sein (URL aus Eingabe bevorzugen).
- Wähle eine passende bestehende Kategorie (use_existing_slug) ODER schlage eine neue vor.
- Icons für neue Kategorien: Bootstrap Icons Klassen wie bi-thermometer-half, bi-virus, bi-lightning-charge.
- Unter possible_answers: 24 kurze, diskussionsfertige Antworten auf die Behauptung formulieren.
Antworte ausschließlich als gültiges JSON mit dieser Struktur:
{
@@ -46,10 +47,9 @@ Antworte ausschließlich als gültiges JSON mit dieser Struktur:
"description": "Kurzbeschreibung"
}
],
"counter_arguments": [
"possible_answers": [
{
"argument": "Häufiges Gegenargument",
"response": "Sachliche Antwort"
"answer": "Kurze, sachliche Antwort auf die Behauptung für die Diskussion"
}
],
"assistant_summary": "Kurze Zusammenfassung für den Admin (1-2 Sätze)"
@@ -229,6 +229,18 @@ def generate_draft_payload(
return _validate_payload(payload)
def _normalize_possible_answers(items):
answers = []
for item in items or []:
if isinstance(item, str):
text = item.strip()
else:
text = (item.get('answer') or item.get('response') or '').strip()
if text:
answers.append({'answer': text})
return answers
def apply_payload_to_draft(draft, payload):
category = payload.get('category') or {}
claim = payload.get('claim') or {}
@@ -245,7 +257,9 @@ def apply_payload_to_draft(draft, payload):
draft.detailed_explanation = claim.get('detailed_explanation', '')
draft.tags = payload.get('tags') or []
draft.sources = payload.get('sources') or []
draft.counter_arguments = payload.get('counter_arguments') or []
draft.possible_answers = _normalize_possible_answers(
payload.get('possible_answers', payload.get('counter_arguments'))
)
draft.ai_raw_response = payload
summary = payload.get('assistant_summary', 'Entwurf wurde erstellt.')
draft.add_message('assistant', summary)
+8 -6
View File
@@ -4,7 +4,7 @@ import uuid
from django.db import transaction
from django.utils.text import slugify
from claims.models import Category, Claim, CounterArgument, EvidenceFile, Source, Tag
from claims.models import Category, Claim, EvidenceFile, PossibleAnswer, Source, Tag
class DraftPublishError(Exception):
@@ -72,11 +72,13 @@ def publish_draft(draft):
description=source.get('description', ''),
)
for counter in draft.counter_arguments or []:
argument = (counter.get('argument') or '').strip()
response = (counter.get('response') or '').strip()
if argument and response:
CounterArgument.objects.create(claim=claim, argument=argument, response=response)
for item in draft.possible_answers or []:
if isinstance(item, str):
answer = item.strip()
else:
answer = (item.get('answer') or item.get('response') or '').strip()
if answer:
PossibleAnswer.objects.create(claim=claim, answer=answer)
if draft.uploaded_file:
_attach_uploaded_file(draft, claim)