Add chat sources and citations
This commit is contained in:
@@ -253,6 +253,14 @@ describe("savingsChatHistory", () => {
|
||||
resultSummary: "2 Umsätze, Saldo 100.00€, 1 Kategorien",
|
||||
},
|
||||
],
|
||||
sources: [
|
||||
{
|
||||
id: "tool-1",
|
||||
title: "summarize_spending",
|
||||
description: "2 Umsätze, Saldo 100.00€, 1 Kategorien",
|
||||
},
|
||||
],
|
||||
citations: [{ marker: "1", sourceId: "tool-1" }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -282,6 +290,14 @@ describe("savingsChatHistory", () => {
|
||||
resultSummary: "2 Umsätze, Saldo 100.00€, 1 Kategorien",
|
||||
},
|
||||
],
|
||||
sources: [
|
||||
{
|
||||
id: "tool-1",
|
||||
title: "summarize_spending",
|
||||
description: "2 Umsätze, Saldo 100.00€, 1 Kategorien",
|
||||
},
|
||||
],
|
||||
citations: [{ marker: "1", sourceId: "tool-1" }],
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -440,8 +456,24 @@ describe("savingsChat.sendMessage", () => {
|
||||
basis: "effective",
|
||||
});
|
||||
|
||||
expect(result.answer).toBe("Agenten-Antwort");
|
||||
expect(result.answer).toBe("Agenten-Antwort [1] [2]");
|
||||
expect(result.toolTrace).toHaveLength(2);
|
||||
expect(result.sources).toEqual([
|
||||
{
|
||||
id: "tool-1",
|
||||
title: "get_transactions",
|
||||
description: "2 Umsätze, Saldo 2880.00€, vollständig",
|
||||
},
|
||||
{
|
||||
id: "tool-2",
|
||||
title: "summarize_spending",
|
||||
description: "2 Umsätze, Saldo 2880.00€, 1 Kategorien",
|
||||
},
|
||||
]);
|
||||
expect(result.citations).toEqual([
|
||||
{ marker: "1", sourceId: "tool-1" },
|
||||
{ marker: "2", sourceId: "tool-2" },
|
||||
]);
|
||||
|
||||
const generateCall = vi.mocked(generateText).mock.calls[0][0] as {
|
||||
messages: Array<{ role: string; content: string }>;
|
||||
@@ -461,7 +493,7 @@ describe("savingsChat.sendMessage", () => {
|
||||
{ role: "user", content: "Wie sieht Februar aus?" },
|
||||
{
|
||||
role: "assistant",
|
||||
content: "Agenten-Antwort",
|
||||
content: "Agenten-Antwort [1] [2]",
|
||||
toolTrace: [
|
||||
{
|
||||
name: "get_transactions",
|
||||
@@ -474,6 +506,22 @@ describe("savingsChat.sendMessage", () => {
|
||||
resultSummary: "2 Umsätze, Saldo 2880.00€, 1 Kategorien",
|
||||
},
|
||||
],
|
||||
sources: [
|
||||
{
|
||||
id: "tool-1",
|
||||
title: "get_transactions",
|
||||
description: "2 Umsätze, Saldo 2880.00€, vollständig",
|
||||
},
|
||||
{
|
||||
id: "tool-2",
|
||||
title: "summarize_spending",
|
||||
description: "2 Umsätze, Saldo 2880.00€, 1 Kategorien",
|
||||
},
|
||||
],
|
||||
citations: [
|
||||
{ marker: "1", sourceId: "tool-1" },
|
||||
{ marker: "2", sourceId: "tool-2" },
|
||||
],
|
||||
},
|
||||
]);
|
||||
} finally {
|
||||
@@ -1382,7 +1430,7 @@ describe("savingsChat read-only agent tools", () => {
|
||||
basis: "effective",
|
||||
});
|
||||
|
||||
expect(result.answer).toBe("Agenten-Antwort");
|
||||
expect(result.answer).toBe("Agenten-Antwort [1] [2]");
|
||||
expect(result.model).toBe("gpt-5.4-mini");
|
||||
expect(result.usedTransactions).toBe(2);
|
||||
expect(result.usedBalance).toEqual({ income: 3000, expenses: -120, balance: 2880 });
|
||||
@@ -1398,6 +1446,22 @@ describe("savingsChat read-only agent tools", () => {
|
||||
resultSummary: "2 Umsätze, Saldo 2880.00€, 1 Kategorien",
|
||||
},
|
||||
]);
|
||||
expect(result.sources).toEqual([
|
||||
{
|
||||
id: "tool-1",
|
||||
title: "get_transactions",
|
||||
description: "2 Umsätze, Saldo 2880.00€, vollständig",
|
||||
},
|
||||
{
|
||||
id: "tool-2",
|
||||
title: "summarize_spending",
|
||||
description: "2 Umsätze, Saldo 2880.00€, 1 Kategorien",
|
||||
},
|
||||
]);
|
||||
expect(result.citations).toEqual([
|
||||
{ marker: "1", sourceId: "tool-1" },
|
||||
{ marker: "2", sourceId: "tool-2" },
|
||||
]);
|
||||
expect(JSON.stringify(result.toolTrace)).not.toContain("RAW PAYLOAD");
|
||||
expect(JSON.stringify(result.toolTrace)).not.toContain("private note");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user