mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-19 04:30:10 +01:00
Support attachments in developer API (#2373)
* support attachments in developer api * lint --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com>
This commit is contained in:
parent
e2195a96d1
commit
e6c4eb3f1c
@ -546,7 +546,14 @@ function apiWorkspaceEndpoints(app) {
|
||||
example: {
|
||||
message: "What is AnythingLLM?",
|
||||
mode: "query | chat",
|
||||
sessionId: "identifier-to-partition-chats-by-external-id"
|
||||
sessionId: "identifier-to-partition-chats-by-external-id",
|
||||
attachments: [
|
||||
{
|
||||
name: "image.png",
|
||||
mime: "image/png",
|
||||
contentString: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -576,7 +583,12 @@ function apiWorkspaceEndpoints(app) {
|
||||
*/
|
||||
try {
|
||||
const { slug } = request.params;
|
||||
const { message, mode = "query", sessionId = null } = reqBody(request);
|
||||
const {
|
||||
message,
|
||||
mode = "query",
|
||||
sessionId = null,
|
||||
attachments = [],
|
||||
} = reqBody(request);
|
||||
const workspace = await Workspace.get({ slug: String(slug) });
|
||||
|
||||
if (!workspace) {
|
||||
@ -612,6 +624,7 @@ function apiWorkspaceEndpoints(app) {
|
||||
user: null,
|
||||
thread: null,
|
||||
sessionId: !!sessionId ? String(sessionId) : null,
|
||||
attachments,
|
||||
});
|
||||
|
||||
await Telemetry.sendTelemetry("sent_chat", {
|
||||
@ -655,7 +668,14 @@ function apiWorkspaceEndpoints(app) {
|
||||
example: {
|
||||
message: "What is AnythingLLM?",
|
||||
mode: "query | chat",
|
||||
sessionId: "identifier-to-partition-chats-by-external-id"
|
||||
sessionId: "identifier-to-partition-chats-by-external-id",
|
||||
attachments: [
|
||||
{
|
||||
name: "image.png",
|
||||
mime: "image/png",
|
||||
contentString: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -706,7 +726,12 @@ function apiWorkspaceEndpoints(app) {
|
||||
*/
|
||||
try {
|
||||
const { slug } = request.params;
|
||||
const { message, mode = "query", sessionId = null } = reqBody(request);
|
||||
const {
|
||||
message,
|
||||
mode = "query",
|
||||
sessionId = null,
|
||||
attachments = [],
|
||||
} = reqBody(request);
|
||||
const workspace = await Workspace.get({ slug: String(slug) });
|
||||
|
||||
if (!workspace) {
|
||||
@ -749,6 +774,7 @@ function apiWorkspaceEndpoints(app) {
|
||||
user: null,
|
||||
thread: null,
|
||||
sessionId: !!sessionId ? String(sessionId) : null,
|
||||
attachments,
|
||||
});
|
||||
await Telemetry.sendTelemetry("sent_chat", {
|
||||
LLMSelection:
|
||||
|
@ -1958,7 +1958,14 @@
|
||||
"example": {
|
||||
"message": "What is AnythingLLM?",
|
||||
"mode": "query | chat",
|
||||
"sessionId": "identifier-to-partition-chats-by-external-id"
|
||||
"sessionId": "identifier-to-partition-chats-by-external-id",
|
||||
"attachments": [
|
||||
{
|
||||
"name": "image.png",
|
||||
"mime": "image/png",
|
||||
"contentString": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2053,7 +2060,14 @@
|
||||
"example": {
|
||||
"message": "What is AnythingLLM?",
|
||||
"mode": "query | chat",
|
||||
"sessionId": "identifier-to-partition-chats-by-external-id"
|
||||
"sessionId": "identifier-to-partition-chats-by-external-id",
|
||||
"attachments": [
|
||||
{
|
||||
"name": "image.png",
|
||||
"mime": "image/png",
|
||||
"contentString": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ const { Telemetry } = require("../../models/telemetry");
|
||||
* user: import("@prisma/client").users|null,
|
||||
* thread: import("@prisma/client").workspace_threads|null,
|
||||
* sessionId: string|null,
|
||||
* attachments: { name: string; mime: string; contentString: string }[],
|
||||
* }} parameters
|
||||
* @returns {Promise<ResponseObject>}
|
||||
*/
|
||||
@ -39,6 +40,7 @@ async function chatSync({
|
||||
user = null,
|
||||
thread = null,
|
||||
sessionId = null,
|
||||
attachments = [],
|
||||
}) {
|
||||
const uuid = uuidv4();
|
||||
const chatMode = mode ?? "chat";
|
||||
@ -251,6 +253,7 @@ async function chatSync({
|
||||
userPrompt: message,
|
||||
contextTexts,
|
||||
chatHistory,
|
||||
attachments,
|
||||
},
|
||||
rawHistory
|
||||
);
|
||||
@ -301,6 +304,7 @@ async function chatSync({
|
||||
* user: import("@prisma/client").users|null,
|
||||
* thread: import("@prisma/client").workspace_threads|null,
|
||||
* sessionId: string|null,
|
||||
* attachments: { name: string; mime: string; contentString: string }[],
|
||||
* }} parameters
|
||||
* @returns {Promise<VoidFunction>}
|
||||
*/
|
||||
@ -312,6 +316,7 @@ async function streamChat({
|
||||
user = null,
|
||||
thread = null,
|
||||
sessionId = null,
|
||||
attachments = [],
|
||||
}) {
|
||||
const uuid = uuidv4();
|
||||
const chatMode = mode ?? "chat";
|
||||
@ -536,6 +541,7 @@ async function streamChat({
|
||||
userPrompt: message,
|
||||
contextTexts,
|
||||
chatHistory,
|
||||
attachments,
|
||||
},
|
||||
rawHistory
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user