feat: per-user assistant name and system prompt customization
Each user can rename the AI assistant and edit their own system prompt in Settings.
This commit is contained in:
@@ -16,7 +16,7 @@ test("assistant chat smoke after opt-in", async ({ page }) => {
|
||||
await page.getByRole("button", { name: "Open assistant" }).click();
|
||||
await expect(page.getByRole("dialog", { name: "Assistant" })).toBeVisible();
|
||||
|
||||
await page.getByLabel("Assistant message").fill("hello assistant");
|
||||
await page.getByLabel("Message for Assistant").fill("hello assistant");
|
||||
await page.getByRole("button", { name: "Send" }).click();
|
||||
|
||||
await expect(page.getByText("hello assistant")).toBeVisible();
|
||||
|
||||
@@ -71,4 +71,16 @@ describe("runAgentChat", () => {
|
||||
assert.equal(result.toolCalls[0]?.name, "add_list_item");
|
||||
assert.equal(result.toolCalls[0]?.status, 201);
|
||||
});
|
||||
|
||||
it("accepts a custom system prompt override", async () => {
|
||||
const result = await runAgentChat({
|
||||
messages: [{ role: "user", content: "hello" }],
|
||||
request: new Request("http://localhost:3000/api/agent/chat"),
|
||||
systemPrompt: "You are a pirate.",
|
||||
llm: createMockLlmClient(),
|
||||
});
|
||||
|
||||
assert.equal(result.message.role, "assistant");
|
||||
assert.ok(result.message.content.length > 0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
import {
|
||||
DEFAULT_ASSISTANT_NAME,
|
||||
resolveAssistantSystemPrompt,
|
||||
} from "../../src/lib/assistant-config";
|
||||
import { AGENT_SYSTEM_PROMPT } from "../../src/modules/agent/tools";
|
||||
|
||||
describe("resolveAssistantSystemPrompt", () => {
|
||||
it("returns the default prompt when custom is null", () => {
|
||||
assert.equal(resolveAssistantSystemPrompt(null), AGENT_SYSTEM_PROMPT);
|
||||
});
|
||||
|
||||
it("returns the default prompt when custom is blank", () => {
|
||||
assert.equal(resolveAssistantSystemPrompt(" "), AGENT_SYSTEM_PROMPT);
|
||||
});
|
||||
|
||||
it("returns trimmed custom prompt when set", () => {
|
||||
assert.equal(resolveAssistantSystemPrompt(" Be extra cheerful. "), "Be extra cheerful.");
|
||||
});
|
||||
});
|
||||
|
||||
describe("DEFAULT_ASSISTANT_NAME", () => {
|
||||
it("is Assistant", () => {
|
||||
assert.equal(DEFAULT_ASSISTANT_NAME, "Assistant");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user