Add chat mode functionality to EmptySidePanel component

This commit is contained in:
n4ze3m
2024-02-03 00:33:31 +05:30
parent 28361c47e6
commit 84f4205b56
4 changed files with 65 additions and 12 deletions

View File

@@ -72,7 +72,9 @@ export const useMessage = () => {
isProcessing,
setIsProcessing,
selectedModel,
setSelectedModel
setSelectedModel,
chatMode,
setChatMode
} = useStoreMessage()
const abortControllerRef = React.useRef<AbortController | null>(null)
@@ -89,7 +91,7 @@ export const useMessage = () => {
setIsFirstMessage(true)
}
const voyEmbedding = async (
const memoryEmbedding = async (
url: string,
html: string,
ollamaEmbedding: OllamaEmbeddings
@@ -155,7 +157,7 @@ export const useMessage = () => {
if (isAlreadyExistEmbedding) {
vectorstore = isAlreadyExistEmbedding
} else {
vectorstore = await voyEmbedding(url, html, ollamaEmbedding)
vectorstore = await memoryEmbedding(url, html, ollamaEmbedding)
}
const questionPrompt =
@@ -173,8 +175,6 @@ export const useMessage = () => {
retriever: vectorstore.asRetriever()
})
try {
const chunks = await chain.stream({
question: sanitizedQuestion
@@ -336,7 +336,11 @@ export const useMessage = () => {
}
const onSubmit = async (message: string) => {
await chatWithWebsiteMode(message)
if (chatMode === "normal") {
await normalChatMode(message)
} else {
await chatWithWebsiteMode(message)
}
}
const stopStreamingRequest = () => {
@@ -362,6 +366,8 @@ export const useMessage = () => {
stopStreamingRequest,
clearChat,
selectedModel,
setSelectedModel
setSelectedModel,
chatMode,
setChatMode
}
}