mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-12-03 10:47:06 +03:00
fix chat reasoning not splitting after tool calls
This commit is contained in:
@@ -219,6 +219,110 @@ test.describe("Chat — streaming @medium", () => {
|
||||
).toBeVisible({ timeout: 5_000 });
|
||||
});
|
||||
|
||||
test("each model call's reasoning renders with its own message", async ({
|
||||
frigateApp,
|
||||
}) => {
|
||||
const toolTurn = [
|
||||
{ role: "system", content: "sys" },
|
||||
{ role: "user", content: "find people" },
|
||||
{
|
||||
role: "assistant",
|
||||
content: null,
|
||||
tool_calls: [
|
||||
{
|
||||
id: "call_1",
|
||||
type: "function",
|
||||
function: {
|
||||
name: "search_objects",
|
||||
arguments: '{"label":"person"}',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{ role: "tool", tool_call_id: "call_1", content: "[]" },
|
||||
];
|
||||
await installChatStreamOverride(frigateApp, [
|
||||
{ type: "reasoning", delta: "first thought" },
|
||||
{ type: "messages", messages: toolTurn },
|
||||
{ type: "reasoning", delta: "second thought" },
|
||||
{ type: "content", delta: "No people found." },
|
||||
{
|
||||
type: "messages",
|
||||
messages: [
|
||||
...toolTurn,
|
||||
{ role: "assistant", content: "No people found." },
|
||||
],
|
||||
},
|
||||
{ type: "done" },
|
||||
]);
|
||||
await frigateApp.goto("/chat");
|
||||
const input = frigateApp.page.getByPlaceholder(/ask/i);
|
||||
await expect(input).toBeVisible({ timeout: 10_000 });
|
||||
await input.fill("find people");
|
||||
await input.press("Enter");
|
||||
|
||||
await expect(frigateApp.page.getByText("No people found.")).toBeVisible({
|
||||
timeout: 10_000,
|
||||
});
|
||||
// Two separate, collapsed reasoning bubbles; expanding both shows each
|
||||
// trace on its own rather than one concatenated block.
|
||||
const toggles = frigateApp.page.getByRole("button", {
|
||||
name: /show reasoning/i,
|
||||
});
|
||||
await expect(toggles).toHaveCount(2);
|
||||
// Expanding one relabels it to "Hide reasoning", so click the first
|
||||
// remaining "Show" toggle twice.
|
||||
await toggles.first().click();
|
||||
await expect(toggles).toHaveCount(1);
|
||||
await toggles.first().click();
|
||||
await expect(
|
||||
frigateApp.page.locator("pre", { hasText: /^first thought$/ }),
|
||||
).toHaveCount(1);
|
||||
await expect(
|
||||
frigateApp.page.locator("pre", { hasText: /^second thought$/ }),
|
||||
).toHaveCount(1);
|
||||
});
|
||||
|
||||
test("a turn that ends without a final answer keeps its tool calls", async ({
|
||||
frigateApp,
|
||||
}) => {
|
||||
const toolTurn = [
|
||||
{ role: "system", content: "sys" },
|
||||
{ role: "user", content: "find people" },
|
||||
{
|
||||
role: "assistant",
|
||||
content: null,
|
||||
tool_calls: [
|
||||
{
|
||||
id: "call_1",
|
||||
type: "function",
|
||||
function: {
|
||||
name: "search_objects",
|
||||
arguments: '{"label":"person"}',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{ role: "tool", tool_call_id: "call_1", content: "[]" },
|
||||
];
|
||||
await installChatStreamOverride(frigateApp, [
|
||||
{ type: "messages", messages: toolTurn },
|
||||
{ type: "messages", messages: toolTurn },
|
||||
{ type: "error", error: "iteration limit" },
|
||||
{ type: "done" },
|
||||
]);
|
||||
await frigateApp.goto("/chat");
|
||||
const input = frigateApp.page.getByPlaceholder(/ask/i);
|
||||
await expect(input).toBeVisible({ timeout: 10_000 });
|
||||
await input.fill("find people");
|
||||
await input.press("Enter");
|
||||
|
||||
await expect(
|
||||
frigateApp.page.getByRole("alert").filter({ hasText: /iteration limit/ }),
|
||||
).toBeVisible({ timeout: 10_000 });
|
||||
await expect(frigateApp.page.getByText(/search objects/i)).toBeVisible();
|
||||
});
|
||||
|
||||
test("assistant markdown renders only same-origin images", async ({
|
||||
frigateApp,
|
||||
}) => {
|
||||
|
||||
Reference in New Issue
Block a user