From 9d0becb2ee25a29459c45c2f6ecc467a1c3c5cda Mon Sep 17 00:00:00 2001 From: Timothy Carambat Date: Mon, 26 Jun 2023 15:08:47 -0700 Subject: [PATCH] Add chat/converstaion mode as the default chat mode for all Vector Databases (#112) * Add chat/converstaion mode as the default chat mode Show menu for toggling options for chat/query/reset command Show chat status below input resolves #61 * remove console logs --- .../ChatContainer/PromptInput/index.jsx | 112 ++++++++++++++++-- .../WorkspaceChat/ChatContainer/index.jsx | 4 +- server/models/workspaceChats.js | 8 +- server/utils/chats/index.js | 5 +- server/utils/helpers/index.js | 1 + .../utils/vectorDbProviders/chroma/index.js | 82 +++++++++++++ server/utils/vectorDbProviders/lance/index.js | 107 ++++++++++++++--- .../utils/vectorDbProviders/pinecone/index.js | 93 +++++++++++---- 8 files changed, 353 insertions(+), 59 deletions(-) diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx index bd656a7f..0ecf3238 100644 --- a/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx +++ b/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx @@ -1,6 +1,6 @@ -import React, { useState, useRef } from "react"; +import React, { useState, useRef, memo, useEffect } from "react"; import { isMobile } from "react-device-detect"; -import { Loader, Menu, Send, X } from "react-feather"; +import { Loader, Menu, X } from "react-feather"; export default function PromptInput({ workspace, @@ -35,6 +35,17 @@ export default function PromptInput({ }; const setTextCommand = (command = "") => { + const storageKey = `workspace_chat_mode_${workspace.slug}`; + if (command === "/query") { + window.localStorage.setItem(storageKey, "query"); + window.dispatchEvent(new Event("workspace_chat_mode_update")); + return; + } else if (command === "/conversation") { + window.localStorage.setItem(storageKey, "chat"); + window.dispatchEvent(new Event("workspace_chat_mode_update")); + return; + } + onChange({ target: { value: `${command} ${message}` } }); }; @@ -45,13 +56,19 @@ export default function PromptInput({ className="flex flex-col gap-y-1 bg-white dark:bg-black-900 md:bg-transparent rounded-t-lg md:w-3/4 w-full mx-auto" >
- {/* Toggle selector? */} - {/* */} +