### What problem does this PR solve? feat: Fetch mind map in search page #2247 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { useFetchMindMap, useFetchRelatedQuestions } from '@/hooks/chat-hooks';
|
||||
import { useTestChunkRetrieval } from '@/hooks/knowledge-hooks';
|
||||
import { useSendMessageWithSse } from '@/hooks/logic-hooks';
|
||||
import { IAnswer } from '@/interfaces/database/chat';
|
||||
@@ -10,6 +11,13 @@ export const useSendQuestion = (kbIds: string[]) => {
|
||||
const { testChunk, loading } = useTestChunkRetrieval();
|
||||
const [sendingLoading, setSendingLoading] = useState(false);
|
||||
const [currentAnswer, setCurrentAnswer] = useState({} as IAnswer);
|
||||
const { fetchRelatedQuestions, data: relatedQuestions } =
|
||||
useFetchRelatedQuestions();
|
||||
const {
|
||||
fetchMindMap,
|
||||
data: mindMap,
|
||||
loading: mindMapLoading,
|
||||
} = useFetchMindMap();
|
||||
|
||||
const sendQuestion = useCallback(
|
||||
(question: string) => {
|
||||
@@ -17,8 +25,13 @@ export const useSendQuestion = (kbIds: string[]) => {
|
||||
setSendingLoading(true);
|
||||
send({ kb_ids: kbIds, question });
|
||||
testChunk({ kb_id: kbIds, highlight: true, question });
|
||||
fetchMindMap({
|
||||
question,
|
||||
kb_ids: kbIds,
|
||||
});
|
||||
fetchRelatedQuestions(question);
|
||||
},
|
||||
[send, testChunk, kbIds],
|
||||
[send, testChunk, kbIds, fetchRelatedQuestions, fetchMindMap],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -33,5 +46,13 @@ export const useSendQuestion = (kbIds: string[]) => {
|
||||
}
|
||||
}, [done]);
|
||||
|
||||
return { sendQuestion, loading, sendingLoading, answer: currentAnswer };
|
||||
return {
|
||||
sendQuestion,
|
||||
loading,
|
||||
sendingLoading,
|
||||
answer: currentAnswer,
|
||||
relatedQuestions: relatedQuestions?.slice(0, 5) ?? [],
|
||||
mindMap,
|
||||
mindMapLoading,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user