diff --git a/app/embeddings.py b/app/embeddings.py index efbdb4a..ff82426 100644 --- a/app/embeddings.py +++ b/app/embeddings.py @@ -648,17 +648,35 @@ def render_highlighted_page(programm_id: str, seite: int, query: str) -> Optiona target_page_idx = i break - # Volles PDF mit Highlight-Annotation statt Single-Page-Extract. - # Der Browser öffnet das vollständige Wahlprogramm; das Frontend - # hängt #page=N an die URL, sodass direkt zur Fundstelle gescrollt - # wird. Kontext des Programms bleibt erhalten. + # Volles PDF mit Highlight-Annotation. Der Browser öffnet das + # vollständige Wahlprogramm; das Frontend hängt #page=N an die URL. + page = src[target_page_idx] if needle and rects: - page = src[target_page_idx] for rect in rects: annot = page.add_highlight_annot(rect) if annot is not None: annot.set_colors(stroke=(1.0, 0.93, 0.0)) # gelb annot.update() + elif needle: + # Kein Match — halluziniertes Zitat aus Pre-#60-Assessment. + # Sichtbare Notiz-Annotation am Seitenkopf, damit der User + # versteht warum nichts markiert ist. + note_rect = fitz.Rect(20, 20, 400, 55) + note_text = ( + "Textstelle nicht im Dokument auffindbar — " + "das Zitat wurde möglicherweise vom LLM paraphrasiert. " + "Eine Re-Analyse des Antrags würde verifizierte Zitate erzeugen." + ) + annot = page.add_freetext_annot( + note_rect, + note_text, + fontsize=9, + fontname="helv", + text_color=(0.5, 0.2, 0.0), + fill_color=(1.0, 0.95, 0.8), + ) + if annot is not None: + annot.update() return src.tobytes(), target_page_idx + 1 finally: