feat: раскрытие полного текста тикета по клику в результатах поиска
Some checks failed
CI / lint-backend (push) Has been cancelled
CI / lint-frontend (push) Has been cancelled
CI / build-backend (push) Has been cancelled
CI / build-frontend (push) Has been cancelled

- Добавлено поле full_text в SourceItem (бэкенд)
- Фронтенд: клик по строке тикета раскрывает/скрывает полный текст
This commit is contained in:
ed0ss 2026-06-20 20:11:58 +03:00
parent 522fb7717e
commit c4924b4da8
4 changed files with 25 additions and 6 deletions

View file

@ -11,6 +11,7 @@ class SourceItem(BaseModel):
ticket_id: str ticket_id: str
score: float score: float
category: str category: str
full_text: str = ""
class SearchResponse(BaseModel): class SearchResponse(BaseModel):

View file

@ -54,7 +54,7 @@ async def search(
reranked = rerank(body.query, qdrant_results, k=FINAL_K) reranked = rerank(body.query, qdrant_results, k=FINAL_K)
sources = [ 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 for r in reranked
] ]

View file

@ -51,7 +51,7 @@ export interface Collection {
export interface SearchResult { export interface SearchResult {
answer: string | null 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 = { export const api = {

View file

@ -10,6 +10,7 @@ export default function CollectionView() {
const [uploading, setUploading] = useState(false) const [uploading, setUploading] = useState(false)
const [uploadResult, setUploadResult] = useState<string | null>(null) const [uploadResult, setUploadResult] = useState<string | null>(null)
const [ticketCount, setTicketCount] = useState(0) const [ticketCount, setTicketCount] = useState(0)
const [expanded, setExpanded] = useState<Record<number, boolean>>({})
const fileRef = useRef<HTMLInputElement>(null) const fileRef = useRef<HTMLInputElement>(null)
useEffect(() => { useEffect(() => {
@ -151,10 +152,27 @@ export default function CollectionView() {
<h3>Найденные тикеты</h3> <h3>Найденные тикеты</h3>
{result.sources.map((s: any, i: number) => ( {result.sources.map((s: any, i: number) => (
<div key={i} style={{ border: '1px solid #ddd', padding: 12, marginBottom: 8, borderRadius: 4 }}> <div key={i} style={{ border: '1px solid #ddd', padding: 12, marginBottom: 8, borderRadius: 4 }}>
<div
onClick={() => setExpanded(prev => ({ ...prev, [i]: !prev[i] }))}
style={{ cursor: 'pointer', userSelect: 'none' }}
>
<strong>Тикет №{s.ticket_id}</strong> <strong>Тикет №{s.ticket_id}</strong>
<span style={{ marginLeft: 12, color: '#666' }}> <span style={{ marginLeft: 12, color: '#666' }}>
Релевантность: {s.score.toFixed(3)} | {s.category} Релевантность: {s.score.toFixed(3)} | {s.category}
</span> </span>
<span style={{ marginLeft: 8, color: '#999', fontSize: 12 }}>
{expanded[i] ? '▲' : '▼'}
</span>
</div>
{expanded[i] && s.full_text && (
<pre style={{
marginTop: 8, padding: 12, background: '#f9f9f9',
borderRadius: 4, fontSize: 13, whiteSpace: 'pre-wrap',
wordBreak: 'break-word',
}}>
{s.full_text}
</pre>
)}
</div> </div>
))} ))}
</div> </div>