Skip to content

Commit 838d3fb

Browse files
committed
refactor: address lite zai review findings
1 parent a426876 commit 838d3fb

2 files changed

Lines changed: 20 additions & 18 deletions

File tree

src/api/providers/__tests__/lite-llm.spec.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,12 +1052,13 @@ describe("LiteLLMHandler", () => {
10521052
})
10531053

10541054
describe("preserveReasoning message conversion", () => {
1055-
const mockStream = asyncStreamFrom([
1056-
{
1057-
choices: [{ delta: { content: "ok" } }],
1058-
usage: { prompt_tokens: 1, completion_tokens: 1 },
1059-
},
1060-
])
1055+
const makeMockStream = () =>
1056+
asyncStreamFrom([
1057+
{
1058+
choices: [{ delta: { content: "ok" } }],
1059+
usage: { prompt_tokens: 1, completion_tokens: 1 },
1060+
},
1061+
])
10611062

10621063
it("uses convertToR1Format (merging tool-result text) when the model info sets preserveReasoning", async () => {
10631064
const optionsWithReasoning: ApiHandlerOptions = {
@@ -1093,7 +1094,7 @@ describe("LiteLLMHandler", () => {
10931094
]
10941095

10951096
mockCreate.mockReturnValue({
1096-
withResponse: vi.fn().mockResolvedValue({ data: mockStream }),
1097+
withResponse: vi.fn().mockResolvedValue({ data: makeMockStream() }),
10971098
})
10981099

10991100
const generator = handler.createMessage(systemPrompt, messages)
@@ -1153,7 +1154,7 @@ describe("LiteLLMHandler", () => {
11531154
]
11541155

11551156
mockCreate.mockReturnValue({
1156-
withResponse: vi.fn().mockResolvedValue({ data: mockStream }),
1157+
withResponse: vi.fn().mockResolvedValue({ data: makeMockStream() }),
11571158
})
11581159

11591160
const generator = handler.createMessage(systemPrompt, messages)
@@ -1185,16 +1186,17 @@ describe("LiteLLMHandler", () => {
11851186
})
11861187

11871188
describe("session ID header", () => {
1188-
const mockStream = asyncStreamFrom([
1189-
{
1190-
choices: [{ delta: { content: "ok" } }],
1191-
usage: { prompt_tokens: 1, completion_tokens: 1 },
1192-
},
1193-
])
1189+
const makeMockStream = () =>
1190+
asyncStreamFrom([
1191+
{
1192+
choices: [{ delta: { content: "ok" } }],
1193+
usage: { prompt_tokens: 1, completion_tokens: 1 },
1194+
},
1195+
])
11941196

11951197
it("should send the X-Zoo-Session-ID header when a taskId is provided", async () => {
11961198
mockCreate.mockReturnValue({
1197-
withResponse: vi.fn().mockResolvedValue({ data: mockStream }),
1199+
withResponse: vi.fn().mockResolvedValue({ data: makeMockStream() }),
11981200
})
11991201

12001202
const generator = handler.createMessage("system", [{ role: "user", content: "hi" }], {
@@ -1208,7 +1210,7 @@ describe("LiteLLMHandler", () => {
12081210

12091211
it("should not send the X-Zoo-Session-ID header when no taskId is provided", async () => {
12101212
mockCreate.mockReturnValue({
1211-
withResponse: vi.fn().mockResolvedValue({ data: mockStream }),
1213+
withResponse: vi.fn().mockResolvedValue({ data: makeMockStream() }),
12121214
})
12131215

12141216
const generator = handler.createMessage("system", [{ role: "user", content: "hi" }])
@@ -1220,7 +1222,7 @@ describe("LiteLLMHandler", () => {
12201222

12211223
it("should not send the X-Zoo-Session-ID header when taskId is an empty string", async () => {
12221224
mockCreate.mockReturnValue({
1223-
withResponse: vi.fn().mockResolvedValue({ data: mockStream }),
1225+
withResponse: vi.fn().mockResolvedValue({ data: makeMockStream() }),
12241226
})
12251227

12261228
const generator = handler.createMessage("system", [{ role: "user", content: "hi" }], {

src/api/providers/__tests__/zai.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from "@roo-code/types"
1515

1616
import { ZAiHandler } from "../zai"
17-
import { asyncStreamFrom, collectStream } from "../../../test-utils/stream"
17+
import { asyncStreamFrom } from "../../../test-utils/stream"
1818

1919
vitest.mock("openai", () => {
2020
const createMock = vitest.fn()

0 commit comments

Comments
 (0)