θΏ™ζ˜―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
34 changes: 30 additions & 4 deletions server/endpoints/api/workspace/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
}
]
}
}
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -612,6 +624,7 @@ function apiWorkspaceEndpoints(app) {
user: null,
thread: null,
sessionId: !!sessionId ? String(sessionId) : null,
attachments,
});

await Telemetry.sendTelemetry("sent_chat", {
Expand Down Expand Up @@ -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..."
}
]
}
}
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -749,6 +774,7 @@ function apiWorkspaceEndpoints(app) {
user: null,
thread: null,
sessionId: !!sessionId ? String(sessionId) : null,
attachments,
});
await Telemetry.sendTelemetry("sent_chat", {
LLMSelection:
Expand Down
18 changes: 16 additions & 2 deletions server/swagger/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
}
]
}
}
}
Expand Down Expand Up @@ -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..."
}
]
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions server/utils/chats/apiChatHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>}
*/
Expand All @@ -39,6 +40,7 @@ async function chatSync({
user = null,
thread = null,
sessionId = null,
attachments = [],
}) {
const uuid = uuidv4();
const chatMode = mode ?? "chat";
Expand Down Expand Up @@ -251,6 +253,7 @@ async function chatSync({
userPrompt: message,
contextTexts,
chatHistory,
attachments,
},
rawHistory
);
Expand Down Expand Up @@ -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>}
*/
Expand All @@ -312,6 +316,7 @@ async function streamChat({
user = null,
thread = null,
sessionId = null,
attachments = [],
}) {
const uuid = uuidv4();
const chatMode = mode ?? "chat";
Expand Down Expand Up @@ -536,6 +541,7 @@ async function streamChat({
userPrompt: message,
contextTexts,
chatHistory,
attachments,
},
rawHistory
);
Expand Down