feat: раскрытие полного текста тикета по клику в результатах поиска
- Добавлено поле full_text в SourceItem (бэкенд) - Фронтенд: клик по строке тикета раскрывает/скрывает полный текст
This commit is contained in:
parent
522fb7717e
commit
c4924b4da8
4 changed files with 25 additions and 6 deletions
|
|
@ -11,6 +11,7 @@ class SourceItem(BaseModel):
|
|||
ticket_id: str
|
||||
score: float
|
||||
category: str
|
||||
full_text: str = ""
|
||||
|
||||
|
||||
class SearchResponse(BaseModel):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ export default function CollectionView() {
|
|||
const [uploading, setUploading] = useState(false)
|
||||
const [uploadResult, setUploadResult] = useState<string | null>(null)
|
||||
const [ticketCount, setTicketCount] = useState(0)
|
||||
const [expanded, setExpanded] = useState<Record<number, boolean>>({})
|
||||
const fileRef = useRef<HTMLInputElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -151,10 +152,27 @@ export default function CollectionView() {
|
|||
<h3>Найденные тикеты</h3>
|
||||
{result.sources.map((s: any, i: number) => (
|
||||
<div key={i} style={{ border: '1px solid #ddd', padding: 12, marginBottom: 8, borderRadius: 4 }}>
|
||||
<strong>Тикет №{s.ticket_id}</strong>
|
||||
<span style={{ marginLeft: 12, color: '#666' }}>
|
||||
Релевантность: {s.score.toFixed(3)} | {s.category}
|
||||
</span>
|
||||
<div
|
||||
onClick={() => setExpanded(prev => ({ ...prev, [i]: !prev[i] }))}
|
||||
style={{ cursor: 'pointer', userSelect: 'none' }}
|
||||
>
|
||||
<strong>Тикет №{s.ticket_id}</strong>
|
||||
<span style={{ marginLeft: 12, color: '#666' }}>
|
||||
Релевантность: {s.score.toFixed(3)} | {s.category}
|
||||
</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>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue