mirror of
https://github.com/Mintplex-Labs/anything-llm
synced 2026-04-30 19:37:27 +02:00
Enable slash commands in dev API chat/stream-chat (#3514)
* enable slash commands in dev api * lint * Remove ability to use default slash commands in API request Add `reset` param to body that can reset chats according to the api chat execution parameters Allow null `message` if `reset` is set in request. Added early return for if message is null and reset is true Enable chat to reset chat history and continue `message` execution Added generic WorkspaceChat history reset function. Deprecated others * update grep function comment remove debug --------- Co-authored-by: timothycarambat <rambat1010@gmail.com>
This commit is contained in:
@@ -351,7 +351,8 @@ function apiWorkspaceThreadEndpoints(app) {
|
||||
mime: "image/png",
|
||||
contentString: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
|
||||
}
|
||||
]
|
||||
],
|
||||
reset: false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -386,6 +387,7 @@ function apiWorkspaceThreadEndpoints(app) {
|
||||
mode = "query",
|
||||
userId,
|
||||
attachments = [],
|
||||
reset = false,
|
||||
} = reqBody(request);
|
||||
const workspace = await Workspace.get({ slug });
|
||||
const thread = await WorkspaceThread.get({
|
||||
@@ -405,7 +407,7 @@ function apiWorkspaceThreadEndpoints(app) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!message?.length || !VALID_CHAT_MODE.includes(mode)) {
|
||||
if ((!message?.length || !VALID_CHAT_MODE.includes(mode)) && !reset) {
|
||||
response.status(400).json({
|
||||
id: uuidv4(),
|
||||
type: "abort",
|
||||
@@ -413,7 +415,7 @@ function apiWorkspaceThreadEndpoints(app) {
|
||||
sources: [],
|
||||
close: true,
|
||||
error: !message?.length
|
||||
? "message parameter cannot be empty."
|
||||
? "Message is empty"
|
||||
: `${mode} is not a valid mode.`,
|
||||
});
|
||||
return;
|
||||
@@ -427,6 +429,7 @@ function apiWorkspaceThreadEndpoints(app) {
|
||||
user,
|
||||
thread,
|
||||
attachments,
|
||||
reset,
|
||||
});
|
||||
await Telemetry.sendTelemetry("sent_chat", {
|
||||
LLMSelection: process.env.LLM_PROVIDER || "openai",
|
||||
@@ -489,7 +492,8 @@ function apiWorkspaceThreadEndpoints(app) {
|
||||
mime: "image/png",
|
||||
contentString: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
|
||||
}
|
||||
]
|
||||
],
|
||||
reset: false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -545,6 +549,7 @@ function apiWorkspaceThreadEndpoints(app) {
|
||||
mode = "query",
|
||||
userId,
|
||||
attachments = [],
|
||||
reset = false,
|
||||
} = reqBody(request);
|
||||
const workspace = await Workspace.get({ slug });
|
||||
const thread = await WorkspaceThread.get({
|
||||
@@ -564,7 +569,7 @@ function apiWorkspaceThreadEndpoints(app) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!message?.length || !VALID_CHAT_MODE.includes(mode)) {
|
||||
if ((!message?.length || !VALID_CHAT_MODE.includes(mode)) && !reset) {
|
||||
response.status(400).json({
|
||||
id: uuidv4(),
|
||||
type: "abort",
|
||||
@@ -594,6 +599,7 @@ function apiWorkspaceThreadEndpoints(app) {
|
||||
user,
|
||||
thread,
|
||||
attachments,
|
||||
reset,
|
||||
});
|
||||
await Telemetry.sendTelemetry("sent_chat", {
|
||||
LLMSelection: process.env.LLM_PROVIDER || "openai",
|
||||
|
||||
Reference in New Issue
Block a user