first commit
This commit is contained in:
100
ui/app/workspace/logs/views/columns.test.ts
Normal file
100
ui/app/workspace/logs/views/columns.test.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { LogEntry } from "@/lib/types/logs";
|
||||
|
||||
import { getMessage } from "./columns";
|
||||
|
||||
describe("getMessage", () => {
|
||||
it("returns EI realtime text from input history", () => {
|
||||
const log = {
|
||||
object: "realtime.turn",
|
||||
input_history: [
|
||||
{
|
||||
role: "user",
|
||||
content: [{ type: "text", text: "hello from the browser" }],
|
||||
},
|
||||
],
|
||||
} as unknown as LogEntry;
|
||||
|
||||
expect(getMessage(log)).toBe("User: hello from the browser");
|
||||
});
|
||||
|
||||
it("returns LM realtime text from output message", () => {
|
||||
const log = {
|
||||
object: "realtime.turn",
|
||||
input_history: [],
|
||||
responses_input_history: [],
|
||||
output_message: {
|
||||
role: "assistant",
|
||||
content: [{ type: "text", text: "hello from the model" }],
|
||||
},
|
||||
} as unknown as LogEntry;
|
||||
|
||||
expect(getMessage(log)).toBe("Assistant: hello from the model");
|
||||
});
|
||||
|
||||
it("returns split realtime text when both user and assistant are present", () => {
|
||||
const log = {
|
||||
object: "realtime.turn",
|
||||
input_history: [
|
||||
{
|
||||
role: "user",
|
||||
content: [{ type: "text", text: "who are you?" }],
|
||||
},
|
||||
],
|
||||
output_message: {
|
||||
role: "assistant",
|
||||
content: [{ type: "text", text: "I am the assistant." }],
|
||||
},
|
||||
} as unknown as LogEntry;
|
||||
|
||||
expect(getMessage(log)).toBe("User: who are you?\nAssistant: I am the assistant.");
|
||||
});
|
||||
|
||||
it("returns split realtime text including tool output", () => {
|
||||
const log = {
|
||||
object: "realtime.turn",
|
||||
input_history: [
|
||||
{
|
||||
role: "tool",
|
||||
content: [{ type: "text", text: '{"nextResponse":"tool result"}' }],
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
content: [{ type: "text", text: "who are you?" }],
|
||||
},
|
||||
],
|
||||
output_message: {
|
||||
role: "assistant",
|
||||
content: [{ type: "text", text: "I am the assistant." }],
|
||||
},
|
||||
} as unknown as LogEntry;
|
||||
|
||||
expect(getMessage(log)).toBe('Tool Result: {"nextResponse":"tool result"}\nUser: who are you?\nAssistant: I am the assistant.');
|
||||
});
|
||||
|
||||
it("returns realtime assistant tool calls from output message", () => {
|
||||
const log = {
|
||||
object: "realtime.turn",
|
||||
input_history: [
|
||||
{
|
||||
role: "user",
|
||||
content: [{ type: "text", text: "show me a pastel palette" }],
|
||||
},
|
||||
],
|
||||
output_message: {
|
||||
role: "assistant",
|
||||
tool_calls: [
|
||||
{
|
||||
function: {
|
||||
name: "display_color_palette",
|
||||
arguments: '{"theme":"pastel"}',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
} as unknown as LogEntry;
|
||||
|
||||
expect(getMessage(log)).toBe('User: show me a pastel palette\nAssistant Tool Call: display_color_palette({"theme":"pastel"})');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user