support attachments via thread API chat/stream-chat endpoints

This commit is contained in:
timothycarambat 2024-12-31 09:52:21 -08:00
parent ef71b95cf9
commit d52249aff8
2 changed files with 46 additions and 6 deletions
server
endpoints/api/workspaceThread
swagger

View file

@ -344,7 +344,14 @@ function apiWorkspaceThreadEndpoints(app) {
example: {
message: "What is AnythingLLM?",
mode: "query | chat",
userId: 1
userId: 1,
attachments: [
{
name: "image.png",
mime: "image/png",
contentString: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
]
}
}
}
@ -374,7 +381,12 @@ function apiWorkspaceThreadEndpoints(app) {
*/
try {
const { slug, threadSlug } = request.params;
const { message, mode = "query", userId } = reqBody(request);
const {
message,
mode = "query",
userId,
attachments = [],
} = reqBody(request);
const workspace = await Workspace.get({ slug });
const thread = await WorkspaceThread.get({
slug: threadSlug,
@ -414,6 +426,7 @@ function apiWorkspaceThreadEndpoints(app) {
mode,
user,
thread,
attachments,
});
await Telemetry.sendTelemetry("sent_chat", {
LLMSelection: process.env.LLM_PROVIDER || "openai",
@ -469,7 +482,14 @@ function apiWorkspaceThreadEndpoints(app) {
example: {
message: "What is AnythingLLM?",
mode: "query | chat",
userId: 1
userId: 1,
attachments: [
{
name: "image.png",
mime: "image/png",
contentString: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
]
}
}
}
@ -520,7 +540,12 @@ function apiWorkspaceThreadEndpoints(app) {
*/
try {
const { slug, threadSlug } = request.params;
const { message, mode = "query", userId } = reqBody(request);
const {
message,
mode = "query",
userId,
attachments = [],
} = reqBody(request);
const workspace = await Workspace.get({ slug });
const thread = await WorkspaceThread.get({
slug: threadSlug,
@ -568,6 +593,7 @@ function apiWorkspaceThreadEndpoints(app) {
mode,
user,
thread,
attachments,
});
await Telemetry.sendTelemetry("sent_chat", {
LLMSelection: process.env.LLM_PROVIDER || "openai",

View file

@ -2902,7 +2902,14 @@
"example": {
"message": "What is AnythingLLM?",
"mode": "query | chat",
"userId": 1
"userId": 1,
"attachments": [
{
"name": "image.png",
"mime": "image/png",
"contentString": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
]
}
}
}
@ -3007,7 +3014,14 @@
"example": {
"message": "What is AnythingLLM?",
"mode": "query | chat",
"userId": 1
"userId": 1,
"attachments": [
{
"name": "image.png",
"mime": "image/png",
"contentString": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
]
}
}
}