feat: Add RetrievalDocuments to SearchPage #2247 (#2327)

### What problem does this PR solve?
feat: Add RetrievalDocuments to SearchPage #2247
feat: Click on the link in the reference to display the pdf drawer #2247

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-09-09 19:20:16 +08:00
committed by GitHub
parent 7241c73c7a
commit 42eeb38247
14 changed files with 390 additions and 143 deletions

View File

@@ -46,10 +46,27 @@ export const useSendQuestion = (kbIds: string[]) => {
const handleClickRelatedQuestion = useCallback(
(question: string) => () => {
if (sendingLoading) return;
setSearchStr(question);
sendQuestion(question);
},
[sendQuestion],
[sendQuestion, sendingLoading],
);
const handleTestChunk = useCallback(
(documentIds: string[]) => {
const q = trim(searchStr);
if (sendingLoading || isEmpty(q)) return;
testChunk({
kb_id: kbIds,
highlight: true,
question: q,
doc_ids: Array.isArray(documentIds) ? documentIds : [],
});
},
[sendingLoading, searchStr, kbIds, testChunk],
);
useEffect(() => {
@@ -71,6 +88,7 @@ export const useSendQuestion = (kbIds: string[]) => {
sendQuestion,
handleSearchStrChange,
handleClickRelatedQuestion,
handleTestChunk,
loading,
sendingLoading,
answer: currentAnswer,