feat: adiciona formatos e metadados ao RAG

This commit is contained in:
Bruno Viana 2026-10-23 20:15:55 -03:00
parent e7850f0416
commit c2c2fc716c
10 changed files with 400 additions and 21 deletions

View file

@ -0,0 +1,21 @@
"""Helpers to expose Qdrant source metadata without inventing citations."""
from __future__ import annotations
from typing import Any
SOURCE_FIELDS = ("file_type", "section", "page", "document_id", "chunk_index")
def source_reference(payload: dict[str, Any], score: Any) -> dict[str, Any]:
source = payload.get("source") or payload.get("path") or "fonte_desconhecida"
reference: dict[str, Any] = {
"source": source,
"score": round(float(score or 0.0), 6),
}
for field in SOURCE_FIELDS:
value = payload.get(field)
if value is not None:
reference[field] = value
return reference