From c4924b4da81356ddbdfc8e329c09ac8679b18d6d Mon Sep 17 00:00:00 2001 From: ed0ss Date: Sat, 20 Jun 2026 20:11:58 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D1=80=D0=B0=D1=81=D0=BA=D1=80=D1=8B?= =?UTF-8?q?=D1=82=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=BB=D0=BD=D0=BE=D0=B3=D0=BE?= =?UTF-8?q?=20=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=B0=20=D1=82=D0=B8=D0=BA?= =?UTF-8?q?=D0=B5=D1=82=D0=B0=20=D0=BF=D0=BE=20=D0=BA=D0=BB=D0=B8=D0=BA?= =?UTF-8?q?=D1=83=20=D0=B2=20=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82?= =?UTF-8?q?=D0=B0=D1=82=D0=B0=D1=85=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Добавлено поле full_text в SourceItem (бэкенд) - Фронтенд: клик по строке тикета раскрывает/скрывает полный текст --- backend/app/models/search_schemas.py | 1 + backend/app/routers/search.py | 2 +- frontend/src/api/client.ts | 2 +- frontend/src/pages/CollectionView.tsx | 26 ++++++++++++++++++++++---- 4 files changed, 25 insertions(+), 6 deletions(-) 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}
+                    
+ )}
))}