diff --git a/server/endpoints/api/workspace/index.js b/server/endpoints/api/workspace/index.js index c8e435f6f00..e8dbbc91d11 100644 --- a/server/endpoints/api/workspace/index.js +++ b/server/endpoints/api/workspace/index.js @@ -613,7 +613,8 @@ function apiWorkspaceEndpoints(app) { contentString: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..." } ], - reset: false + reset: false, + includeSources: true } } } @@ -649,6 +650,7 @@ function apiWorkspaceEndpoints(app) { sessionId = null, attachments = [], reset = false, + includeSources = true, } = reqBody(request); const workspace = await Workspace.get({ slug: String(slug) }); @@ -687,6 +689,7 @@ function apiWorkspaceEndpoints(app) { sessionId: !!sessionId ? String(sessionId) : null, attachments, reset, + includeSources, }); await Telemetry.sendTelemetry("sent_chat", { @@ -738,7 +741,8 @@ function apiWorkspaceEndpoints(app) { contentString: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..." } ], - reset: false + reset: false, + includeSources: true } } } @@ -795,6 +799,7 @@ function apiWorkspaceEndpoints(app) { sessionId = null, attachments = [], reset = false, + includeSources = true, } = reqBody(request); const workspace = await Workspace.get({ slug: String(slug) }); @@ -840,6 +845,7 @@ function apiWorkspaceEndpoints(app) { sessionId: !!sessionId ? String(sessionId) : null, attachments, reset, + includeSources, }); await Telemetry.sendTelemetry("sent_chat", { LLMSelection: diff --git a/server/swagger/openapi.json b/server/swagger/openapi.json index cdca9e46cae..a238f1e6ebb 100644 --- a/server/swagger/openapi.json +++ b/server/swagger/openapi.json @@ -2321,7 +2321,8 @@ "contentString": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..." } ], - "reset": false + "reset": false, + "includeSources": true } } } @@ -2424,7 +2425,8 @@ "contentString": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..." } ], - "reset": false + "reset": false, + "includeSources": true } } } diff --git a/server/utils/chats/apiChatHandler.js b/server/utils/chats/apiChatHandler.js index 43a87d60c14..1e25a917ce7 100644 --- a/server/utils/chats/apiChatHandler.js +++ b/server/utils/chats/apiChatHandler.js @@ -49,6 +49,7 @@ async function chatSync({ sessionId = null, attachments = [], reset = false, + includeSources = true, }) { const uuid = uuidv4(); const chatMode = mode ?? "chat"; @@ -343,7 +344,7 @@ async function chatSync({ error: null, chatId: chat.id, textResponse, - sources, + sources: includeSources ? sources : [], metrics: performanceMetrics, }; } @@ -373,6 +374,7 @@ async function streamChat({ sessionId = null, attachments = [], reset = false, + includeSources = true, }) { const uuid = uuidv4(); const chatMode = mode ?? "chat"; @@ -654,7 +656,7 @@ async function streamChat({ metrics = performanceMetrics; writeResponseChunk(response, { uuid, - sources, + sources: includeSources ? sources : [], type: "textResponseChunk", textResponse: completeText, close: true, @@ -667,7 +669,7 @@ async function streamChat({ }); completeText = await LLMConnector.handleStream(response, stream, { uuid, - sources, + sources: includeSources ? sources : [], }); metrics = stream.metrics; }