mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2025-04-23 13:08:11 +00: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
2 changed files with 31 additions and 1 deletions
server
|
@ -87,7 +87,7 @@ function workspaceEndpoints(app) {
|
||||||
response.sendStatus(400).end();
|
response.sendStatus(400).end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
await Workspace.trackChange(currWorkspace, data, user);
|
||||||
const { workspace, message } = await Workspace.update(
|
const { workspace, message } = await Workspace.update(
|
||||||
currWorkspace.id,
|
currWorkspace.id,
|
||||||
data
|
data
|
||||||
|
|
|
@ -6,6 +6,8 @@ const { ROLES } = require("../utils/middleware/multiUserProtected");
|
||||||
const { v4: uuidv4 } = require("uuid");
|
const { v4: uuidv4 } = require("uuid");
|
||||||
|
|
||||||
const Workspace = {
|
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: [
|
writable: [
|
||||||
// Used for generic updates so we can validate keys in request body
|
// Used for generic updates so we can validate keys in request body
|
||||||
"name",
|
"name",
|
||||||
|
@ -213,6 +215,34 @@ const Workspace = {
|
||||||
return { success: false, error: error.message };
|
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 };
|
module.exports = { Workspace };
|
||||||
|
|
Loading…
Add table
Reference in a new issue