44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
|
|
import {
|
|
extractThinkingMarkup,
|
|
getReasoningText,
|
|
isReasoningStreaming,
|
|
} from "./transforms";
|
|
import type { ConversationMessage } from "./types";
|
|
|
|
const message = (parts: ConversationMessage["parts"]): ConversationMessage => ({
|
|
id: "message-1",
|
|
parts,
|
|
role: "assistant",
|
|
});
|
|
|
|
describe("reasoning traces", () => {
|
|
test("extracts completed and streaming MiniMax think blocks", () => {
|
|
expect(
|
|
extractThinkingMarkup(
|
|
"<think>First thought</think><think>Current thought"
|
|
)
|
|
).toBe("First thought\n\nCurrent thought");
|
|
});
|
|
|
|
test("combines native reasoning with inline thinking", () => {
|
|
expect(
|
|
getReasoningText(
|
|
message([
|
|
{ state: "streaming", text: "Native thought", type: "reasoning" },
|
|
{ state: "streaming", text: "<think>Inline thought", type: "text" },
|
|
])
|
|
)
|
|
).toBe("Native thought\n\nInline thought");
|
|
});
|
|
|
|
test("recognizes an open streamed think block as live reasoning", () => {
|
|
expect(
|
|
isReasoningStreaming(
|
|
message([{ state: "streaming", text: "<think>Working", type: "text" }])
|
|
)
|
|
).toBe(true);
|
|
});
|
|
});
|