mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
test(ui): add vllm reasoning object and timing coverage
This commit is contained in:
parent
fbaa4d109d
commit
1f5f37444f
1 changed files with 58 additions and 0 deletions
|
|
@ -312,4 +312,62 @@ describe("chat_completion", () => {
|
|||
|
||||
expect(onReasoningContent).toHaveBeenCalledWith("step 1 step 2");
|
||||
});
|
||||
|
||||
it("should support object-typed `reasoning` delta", async () => {
|
||||
const onReasoningContent = vi.fn();
|
||||
const mockChunks = [
|
||||
{
|
||||
choices: [{ delta: { reasoning: { text: "inner thought" } }, index: 0 }],
|
||||
model: "qwen3.5",
|
||||
},
|
||||
];
|
||||
async function* mockStream() {
|
||||
for (const chunk of mockChunks) {
|
||||
yield chunk;
|
||||
}
|
||||
}
|
||||
mockCreate.mockResolvedValueOnce(mockStream());
|
||||
|
||||
await makeOpenAIChatCompletionRequest(
|
||||
mockChatHistory,
|
||||
mockUpdateUI,
|
||||
"qwen3.5",
|
||||
"test-token",
|
||||
undefined,
|
||||
undefined,
|
||||
onReasoningContent,
|
||||
);
|
||||
|
||||
expect(onReasoningContent).toHaveBeenCalledWith("inner thought");
|
||||
});
|
||||
|
||||
it("should trigger first-token timing when reasoning field arrives", async () => {
|
||||
const onTimingData = vi.fn();
|
||||
const mockChunks = [
|
||||
{
|
||||
choices: [{ delta: { reasoning: "thinking..." }, index: 0 }],
|
||||
model: "qwen3.5",
|
||||
},
|
||||
];
|
||||
async function* mockStream() {
|
||||
for (const chunk of mockChunks) {
|
||||
yield chunk;
|
||||
}
|
||||
}
|
||||
mockCreate.mockResolvedValueOnce(mockStream());
|
||||
|
||||
await makeOpenAIChatCompletionRequest(
|
||||
mockChatHistory,
|
||||
mockUpdateUI,
|
||||
"qwen3.5",
|
||||
"test-token",
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
onTimingData,
|
||||
);
|
||||
|
||||
expect(onTimingData).toHaveBeenCalledTimes(1);
|
||||
expect(onTimingData).toHaveBeenCalledWith(expect.any(Number));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue