θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { chatQueryRefusalResponse } from "@/utils/chat";

export default function ChatQueryRefusalResponse({ workspace, setHasChanges }) {
return (
<div>
<div className="flex flex-col">
<label htmlFor="name" className="block input-label">
Query mode refusal response
</label>
<p className="text-white text-opacity-60 text-xs font-medium py-1.5">
When in <code className="bg-zinc-900 p-0.5 rounded-sm">query</code>{" "}
mode, you may want to return a custom refusal response when no context
is found.
</p>
</div>
<textarea
name="queryRefusalResponse"
rows={2}
defaultValue={chatQueryRefusalResponse(workspace)}
className="border-none bg-zinc-900 placeholder:text-white/20 text-white text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 mt-2"
placeholder="The text returned in query mode when there is no relevant context found for a response."
required={true}
wrap="soft"
autoComplete="off"
onChange={() => setHasChanges(true)}
/>
</div>
);
}
5 changes: 5 additions & 0 deletions frontend/src/pages/WorkspaceSettings/ChatSettings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ChatPromptSettings from "./ChatPromptSettings";
import ChatTemperatureSettings from "./ChatTemperatureSettings";
import ChatModeSelection from "./ChatModeSelection";
import WorkspaceLLMSelection from "./WorkspaceLLMSelection";
import ChatQueryRefusalResponse from "./ChatQueryRefusalResponse";

export default function ChatSettings({ workspace }) {
const [settings, setSettings] = useState({});
Expand Down Expand Up @@ -68,6 +69,10 @@ export default function ChatSettings({ workspace }) {
workspace={workspace}
setHasChanges={setHasChanges}
/>
<ChatQueryRefusalResponse
workspace={workspace}
setHasChanges={setHasChanges}
/>
<ChatTemperatureSettings
settings={settings}
workspace={workspace}
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/utils/chat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,10 @@ export function chatPrompt(workspace) {
"Given the following conversation, relevant context, and a follow up question, reply with an answer to the current question the user is asking. Return only your response to the question given the above information following the users instructions as needed."
);
}

export function chatQueryRefusalResponse(workspace) {
return (
workspace?.queryRefusalResponse ??
"There is no relevant information in this workspace to answer your query."
);
}
1 change: 1 addition & 0 deletions server/models/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const Workspace = {
"pfpFilename",
"agentProvider",
"agentModel",
"queryRefusalResponse",
],

new: async function (name = null, creatorId = null) {
Expand Down
2 changes: 2 additions & 0 deletions server/prisma/migrations/20240430230707_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "workspaces" ADD COLUMN "queryRefusalResponse" TEXT;
1 change: 1 addition & 0 deletions server/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ model workspaces {
pfpFilename String?
agentProvider String?
agentModel String?
queryRefusalResponse String?
workspace_users workspace_users[]
documents workspace_documents[]
workspace_suggested_messages workspace_suggested_messages[]
Expand Down
1 change: 1 addition & 0 deletions server/utils/chats/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ async function streamChatWithForEmbed(
id: uuid,
type: "textResponse",
textResponse:
embed.workspace?.queryRefusalResponse ??
"There is no relevant information in this workspace to answer your query.",
sources: [],
close: true,
Expand Down
2 changes: 2 additions & 0 deletions server/utils/chats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ async function chatWithWorkspace(
close: true,
error: null,
textResponse:
workspace?.queryRefusalResponse ??
"There is no relevant information in this workspace to answer your query.",
};
}
Expand Down Expand Up @@ -150,6 +151,7 @@ async function chatWithWorkspace(
close: true,
error: null,
textResponse:
workspace?.queryRefusalResponse ??
"There is no relevant information in this workspace to answer your query.",
};
}
Expand Down
2 changes: 2 additions & 0 deletions server/utils/chats/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ async function streamChatWithWorkspace(
id: uuid,
type: "textResponse",
textResponse:
workspace?.queryRefusalResponse ??
"There is no relevant information in this workspace to answer your query.",
sources: [],
close: true,
Expand Down Expand Up @@ -162,6 +163,7 @@ async function streamChatWithWorkspace(
id: uuid,
type: "textResponse",
textResponse:
workspace?.queryRefusalResponse ??
"There is no relevant information in this workspace to answer your query.",
sources: [],
close: true,
Expand Down