mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-13 02:00:10 +01:00
Workspace prompt changes (#949)
* track workspace prompt change * refactor * modify arg order --------- Co-authored-by: timothycarambat <rambat1010@gmail.com>
This commit is contained in:
parent
373c833aad
commit
35a155d3ac
@ -87,7 +87,7 @@ function workspaceEndpoints(app) {
|
||||
response.sendStatus(400).end();
|
||||
return;
|
||||
}
|
||||
|
||||
await Workspace.trackChange(currWorkspace, data, user);
|
||||
const { workspace, message } = await Workspace.update(
|
||||
currWorkspace.id,
|
||||
data
|
||||
|
@ -6,6 +6,8 @@ const { ROLES } = require("../utils/middleware/multiUserProtected");
|
||||
const { v4: uuidv4 } = require("uuid");
|
||||
|
||||
const Workspace = {
|
||||
defaultPrompt:
|
||||
"Given the following conversation, relevant context, and a follow up question, reply with an answer to the current question the user is asking. Return only your response to the question given the above information following the users instructions as needed.",
|
||||
writable: [
|
||||
// Used for generic updates so we can validate keys in request body
|
||||
"name",
|
||||
@ -213,6 +215,34 @@ const Workspace = {
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
},
|
||||
|
||||
trackChange: async function (prevData, newData, user) {
|
||||
try {
|
||||
const { Telemetry } = require("./telemetry");
|
||||
const { EventLogs } = require("./eventLogs");
|
||||
if (
|
||||
!newData?.openAiPrompt ||
|
||||
newData?.openAiPrompt === this.defaultPrompt ||
|
||||
newData?.openAiPrompt === prevData?.openAiPrompt
|
||||
)
|
||||
return;
|
||||
|
||||
await Telemetry.sendTelemetry("workspace_prompt_changed");
|
||||
await EventLogs.logEvent(
|
||||
"workspace_prompt_changed",
|
||||
{
|
||||
workspaceName: prevData?.name,
|
||||
prevSystemPrompt: prevData?.openAiPrompt || this.defaultPrompt,
|
||||
newSystemPrompt: newData?.openAiPrompt,
|
||||
},
|
||||
user?.id
|
||||
);
|
||||
return;
|
||||
} catch (error) {
|
||||
console.error("Error tracking workspace change:", error.message);
|
||||
return;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = { Workspace };
|
||||
|
Loading…
Reference in New Issue
Block a user