WIP: migrate persona to agent
This commit is contained in:
+13
-13
@@ -1,7 +1,7 @@
|
||||
import { module, test } from "qunit";
|
||||
import AiPersona from "discourse/plugins/discourse-ai/discourse/admin/models/ai-persona";
|
||||
import AiAgent from "discourse/plugins/discourse-ai/discourse/admin/models/ai-agent";
|
||||
|
||||
module("Discourse AI | Unit | Model | ai-persona", function () {
|
||||
module("Discourse AI | Unit | Model | ai-agent", function () {
|
||||
test("toPOJO", function (assert) {
|
||||
const properties = {
|
||||
tools: [
|
||||
@@ -11,15 +11,15 @@ module("Discourse AI | Unit | Model | ai-persona", function () {
|
||||
],
|
||||
};
|
||||
|
||||
const aiPersonaPOJO = AiPersona.create(properties).toPOJO();
|
||||
const aiAgentPOJO = AiAgent.create(properties).toPOJO();
|
||||
|
||||
assert.deepEqual(aiPersonaPOJO.tools, [
|
||||
assert.deepEqual(aiAgentPOJO.tools, [
|
||||
"ToolName",
|
||||
"ToolName2",
|
||||
"ToolName3",
|
||||
]);
|
||||
assert.equal(aiPersonaPOJO.toolOptions["ToolName"].option1, "value1");
|
||||
assert.equal(aiPersonaPOJO.toolOptions["ToolName"].option2, "value2");
|
||||
assert.equal(aiAgentPOJO.toolOptions["ToolName"].option1, "value1");
|
||||
assert.equal(aiAgentPOJO.toolOptions["ToolName"].option2, "value2");
|
||||
});
|
||||
|
||||
test("fromPOJO", function (assert) {
|
||||
@@ -51,23 +51,23 @@ module("Discourse AI | Unit | Model | ai-persona", function () {
|
||||
allow_chat: false,
|
||||
tool_details: true,
|
||||
forced_tool_count: -1,
|
||||
allow_personal_messages: true,
|
||||
allow_agentl_messages: true,
|
||||
allow_topic_mentions: true,
|
||||
allow_chat_channel_mentions: true,
|
||||
allow_chat_direct_messages: true,
|
||||
};
|
||||
const updatedValue = "updated";
|
||||
|
||||
const aiPersona = AiPersona.create({ ...properties });
|
||||
const aiAgent = AiAgent.create({ ...properties });
|
||||
|
||||
const personaPOJO = aiPersona.toPOJO();
|
||||
const agentPOJO = aiAgent.toPOJO();
|
||||
|
||||
personaPOJO.toolOptions["ToolName"].option1 = updatedValue;
|
||||
personaPOJO.forcedTools = "ToolName";
|
||||
agentPOJO.toolOptions["ToolName"].option1 = updatedValue;
|
||||
agentPOJO.forcedTools = "ToolName";
|
||||
|
||||
const updatedPersona = aiPersona.fromPOJO(personaPOJO);
|
||||
const updatedAgent = aiAgent.fromPOJO(agentPOJO);
|
||||
|
||||
assert.deepEqual(updatedPersona.tools, [
|
||||
assert.deepEqual(updatedAgent.tools, [
|
||||
["ToolName", { option1: updatedValue }, true],
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user