diff --git a/backend/app/models/search_schemas.py b/backend/app/models/search_schemas.py index fc2153d..c27cce5 100644 --- a/backend/app/models/search_schemas.py +++ b/backend/app/models/search_schemas.py @@ -11,6 +11,7 @@ class SourceItem(BaseModel): ticket_id: str score: float category: str + full_text: str = "" class SearchResponse(BaseModel): diff --git a/backend/app/routers/search.py b/backend/app/routers/search.py index b0b3612..e385802 100644 --- a/backend/app/routers/search.py +++ b/backend/app/routers/search.py @@ -54,7 +54,7 @@ async def search( reranked = rerank(body.query, qdrant_results, k=FINAL_K) sources = [ - SourceItem(ticket_id=r["ticket_id"], score=r["score"], category=r["category"]) + SourceItem(ticket_id=r["ticket_id"], score=r["score"], category=r["category"], full_text=r["full_text"]) for r in reranked ] diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index 31f4f85..ffb2bd4 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -51,7 +51,7 @@ export interface Collection { export interface SearchResult { answer: string | null - sources: { ticket_id: string; score: number; category: string }[] + sources: { ticket_id: string; score: number; category: string; full_text: string }[] } export const api = { diff --git a/frontend/src/pages/CollectionView.tsx b/frontend/src/pages/CollectionView.tsx index 03145b8..cd242ce 100644 --- a/frontend/src/pages/CollectionView.tsx +++ b/frontend/src/pages/CollectionView.tsx @@ -10,6 +10,7 @@ export default function CollectionView() { const [uploading, setUploading] = useState(false) const [uploadResult, setUploadResult] = useState(null) const [ticketCount, setTicketCount] = useState(0) + const [expanded, setExpanded] = useState>({}) const fileRef = useRef(null) useEffect(() => { @@ -151,10 +152,27 @@ export default function CollectionView() {

Найденные тикеты

{result.sources.map((s: any, i: number) => (
- Тикет №{s.ticket_id} - - Релевантность: {s.score.toFixed(3)} | {s.category} - +
setExpanded(prev => ({ ...prev, [i]: !prev[i] }))} + style={{ cursor: 'pointer', userSelect: 'none' }} + > + Тикет №{s.ticket_id} + + Релевантность: {s.score.toFixed(3)} | {s.category} + + + {expanded[i] ? '▲' : '▼'} + +
+ {expanded[i] && s.full_text && ( +
+                      {s.full_text}
+                    
+ )}
))}