fix: rewrite vllm tool calls from reasoning content
This commit is contained in:
@@ -50,4 +50,29 @@ describe('vLLM Response Rewriter', () => {
|
||||
expect(result.choices[0].message.content).toBe("Here are the calls");
|
||||
expect(result.choices[0].message.tool_calls).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('rewrites tool call found in reasoning_content into structured tool_calls', () => {
|
||||
const inputResponse = {
|
||||
id: "chatcmpl-123",
|
||||
choices: [{
|
||||
index: 0,
|
||||
message: {
|
||||
role: "assistant",
|
||||
content: "",
|
||||
reasoning_content: "<tool_call>\n{\"name\":\"read\",\"arguments\":{\"path\":\"/tmp/test.txt\"}}\n</tool_call>"
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
const result = rewriteVllmResponse(inputResponse);
|
||||
|
||||
expect(result.choices[0].message.content).toBe("");
|
||||
expect(result.choices[0].message.tool_calls).toBeDefined();
|
||||
expect(result.choices[0].message.tool_calls).toHaveLength(1);
|
||||
expect(result.choices[0].message.tool_calls[0].function.name).toBe("read");
|
||||
expect(JSON.parse(result.choices[0].message.tool_calls[0].function.arguments)).toEqual({
|
||||
path: "/tmp/test.txt"
|
||||
});
|
||||
expect(result.choices[0].message.reasoning_content).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user