Skip to content

Commit

Permalink
support attachments via thread API chat/stream-chat endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
timothycarambat committed Dec 31, 2024
1 parent ef71b95 commit d52249a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
34 changes: 30 additions & 4 deletions server/endpoints/api/workspaceThread/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
}
]
}
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -414,6 +426,7 @@ function apiWorkspaceThreadEndpoints(app) {
mode,
user,
thread,
attachments,
});
await Telemetry.sendTelemetry("sent_chat", {
LLMSelection: process.env.LLM_PROVIDER || "openai",
Expand Down Expand Up @@ -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..."
}
]
}
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -568,6 +593,7 @@ function apiWorkspaceThreadEndpoints(app) {
mode,
user,
thread,
attachments,
});
await Telemetry.sendTelemetry("sent_chat", {
LLMSelection: process.env.LLM_PROVIDER || "openai",
Expand Down
18 changes: 16 additions & 2 deletions server/swagger/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
}
]
}
}
}
Expand Down Expand Up @@ -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..."
}
]
}
}
}
Expand Down

0 comments on commit d52249a

Please sign in to comment.