|
| 1 | +import type { ChatCompletionRequest } from "@copilotkit/aimock" |
| 2 | +import { LLMock } from "@copilotkit/aimock" |
| 3 | + |
| 4 | +// Turn-2 completion fixtures for DeepSeek V4 tests. |
| 5 | +// Uses lastToolMsg.tool_call_id to scope each fixture — aimock v1.16.4+ changed |
| 6 | +// toolCallId matching to require the very last message to be the tool message, |
| 7 | +// but Roo Code appends <environment_details> as a user message after tool results. |
| 8 | +const turn2Fixtures = [ |
| 9 | + { |
| 10 | + toolCallId: "call_dsv4_flash_on_read", |
| 11 | + model: "deepseek-v4-flash", |
| 12 | + result: "DEEPSEEK_V4_MARKER_deepseek_v4_flash_reasoning_on", |
| 13 | + doneId: "call_dsv4_flash_on_done", |
| 14 | + }, |
| 15 | + { |
| 16 | + toolCallId: "call_dsv4_flash_off_read", |
| 17 | + model: "deepseek-v4-flash", |
| 18 | + result: "DEEPSEEK_V4_MARKER_deepseek_v4_flash_reasoning_off", |
| 19 | + doneId: "call_dsv4_flash_off_done", |
| 20 | + }, |
| 21 | + { |
| 22 | + toolCallId: "call_dsv4_pro_on_read", |
| 23 | + model: "deepseek-v4-pro", |
| 24 | + result: "DEEPSEEK_V4_MARKER_deepseek_v4_pro_reasoning_on", |
| 25 | + doneId: "call_dsv4_pro_on_done", |
| 26 | + }, |
| 27 | + { |
| 28 | + toolCallId: "call_dsv4_pro_off_read", |
| 29 | + model: "deepseek-v4-pro", |
| 30 | + result: "DEEPSEEK_V4_MARKER_deepseek_v4_pro_reasoning_off", |
| 31 | + doneId: "call_dsv4_pro_off_done", |
| 32 | + }, |
| 33 | +] |
| 34 | + |
| 35 | +export function addDeepSeekV4Fixtures(mock: InstanceType<typeof LLMock>) { |
| 36 | + for (const fixture of turn2Fixtures) { |
| 37 | + mock.addFixture({ |
| 38 | + match: { |
| 39 | + predicate: (req: ChatCompletionRequest) => { |
| 40 | + const messages = Array.isArray(req?.messages) ? req.messages : [] |
| 41 | + const lastToolMsg = messages.filter((m) => m?.role === "tool").at(-1) |
| 42 | + return req?.model === fixture.model && lastToolMsg?.tool_call_id === fixture.toolCallId |
| 43 | + }, |
| 44 | + }, |
| 45 | + response: { |
| 46 | + toolCalls: [ |
| 47 | + { |
| 48 | + name: "attempt_completion", |
| 49 | + arguments: JSON.stringify({ result: fixture.result }), |
| 50 | + id: fixture.doneId, |
| 51 | + }, |
| 52 | + ], |
| 53 | + }, |
| 54 | + }) |
| 55 | + } |
| 56 | +} |
0 commit comments