fix: normalize ollama tool calls from content and thinking
This commit is contained in:
@@ -49,4 +49,25 @@ describe('Response Rewriter', () => {
|
||||
expect(result.message.content).toBe("Here are the calls"); // not cleared
|
||||
expect(result.message.tool_calls).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('rewrites tool call found in thinking into structured tool_calls', () => {
|
||||
const inputResponse: OllamaChatResponse = {
|
||||
model: "test-model",
|
||||
done: true,
|
||||
message: {
|
||||
role: "assistant",
|
||||
content: "",
|
||||
thinking: "<tool_call>\n{\"name\":\"read\",\"arguments\":{\"path\":\"/tmp/test.txt\"}}\n</tool_call>"
|
||||
}
|
||||
};
|
||||
|
||||
const result = rewriteResponse(inputResponse);
|
||||
|
||||
expect(result.message.content).toBe("");
|
||||
expect(result.message.tool_calls).toBeDefined();
|
||||
expect(result.message.tool_calls).toHaveLength(1);
|
||||
expect(result.message.tool_calls![0].function.name).toBe("read");
|
||||
expect(result.message.tool_calls![0].function.arguments).toEqual({ path: "/tmp/test.txt" });
|
||||
expect(result.message.thinking).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user