discourse/plugins/discourse-ai/test/javascripts/unit/models/ai-persona-test.js
Sam e27f493995
FEATURE: support thinking summary on responses API (#36013)
This is an extensive set of changes to the way we handle LLM thinking
blocks

- We now treat "thinking" as a unified entity meaning that tool calls
and thinking blocks all live in a single details block
- We reworked Thinking object so it stores provider specific data, that
allows thinking blocks to work differently for anthropic / open ai while
keeping a consistent UI
- "Show tool details" is now "Show thinking" which is far more intuitive
- The Open AI responses API was implemented more completely
2025-11-18 07:54:14 +11:00

74 lines
2.1 KiB
JavaScript
Vendored

import { module, test } from "qunit";
import AiPersona from "discourse/plugins/discourse-ai/discourse/admin/models/ai-persona";
module("Discourse AI | Unit | Model | ai-persona", function () {
test("toPOJO", function (assert) {
const properties = {
tools: [
["ToolName", { option1: "value1", option2: "value2" }, false],
"ToolName2",
"ToolName3",
],
};
const aiPersonaPOJO = AiPersona.create(properties).toPOJO();
assert.deepEqual(aiPersonaPOJO.tools, [
"ToolName",
"ToolName2",
"ToolName3",
]);
assert.strictEqual(aiPersonaPOJO.toolOptions["ToolName"].option1, "value1");
assert.strictEqual(aiPersonaPOJO.toolOptions["ToolName"].option2, "value2");
});
test("fromPOJO", function (assert) {
const properties = {
id: 1,
name: "Test",
tools: [["ToolName", { option1: "value1" }, false]],
allowed_group_ids: [12],
system: false,
enabled: true,
system_prompt: "System Prompt",
priority: false,
description: "Description",
top_p: 0.8,
temperature: 0.7,
default_llm_id: 1,
force_default_llm: false,
user: null,
user_id: null,
max_context_posts: 5,
vision_enabled: true,
vision_max_pixels: 100,
rag_uploads: [],
rag_chunk_tokens: 374,
rag_chunk_overlap_tokens: 10,
rag_conversation_chunks: 10,
rag_llm_model_id: 1,
question_consolidator_llm_id: 2,
allow_chat: false,
show_thinking: true,
forced_tool_count: -1,
allow_personal_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 personaPOJO = aiPersona.toPOJO();
personaPOJO.toolOptions["ToolName"].option1 = updatedValue;
personaPOJO.forcedTools = "ToolName";
const updatedPersona = aiPersona.fromPOJO(personaPOJO);
assert.deepEqual(updatedPersona.tools, [
["ToolName", { option1: updatedValue }, true],
]);
});
});