fix: make vllm tool-calling turns tool-first
This commit is contained in:
@@ -59,4 +59,37 @@ describe('vLLM Proxy Integration Test', () => {
|
||||
path: "/tmp/test.txt"
|
||||
});
|
||||
});
|
||||
|
||||
it('spoofs streaming responses for tool-calling turns without content chunks', async () => {
|
||||
const requestFixturePath = path.join(__dirname, 'fixtures', 'vllm-like-request.json');
|
||||
const responseFixturePath = path.join(__dirname, 'fixtures', 'vllm-xml-response.json');
|
||||
|
||||
const requestJson = JSON.parse(fs.readFileSync(requestFixturePath, 'utf8'));
|
||||
const responseJson = JSON.parse(fs.readFileSync(responseFixturePath, 'utf8'));
|
||||
requestJson.stream = true;
|
||||
|
||||
(global.fetch as any).mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => responseJson
|
||||
});
|
||||
|
||||
const response = await server.inject({
|
||||
method: 'POST',
|
||||
url: '/v1/chat/completions',
|
||||
payload: requestJson
|
||||
});
|
||||
|
||||
expect(response.statusCode).toBe(200);
|
||||
expect(response.headers['content-type']).toContain('text/event-stream');
|
||||
|
||||
const fetchArgs = (global.fetch as any).mock.calls[0];
|
||||
const upstreamBody = JSON.parse(fetchArgs[1].body);
|
||||
expect(upstreamBody.stream).toBe(false);
|
||||
|
||||
expect(response.payload).toContain('"role":"assistant"');
|
||||
expect(response.payload).toContain('"tool_calls"');
|
||||
expect(response.payload).toContain('"finish_reason":"tool_calls"');
|
||||
expect(response.payload).not.toContain('"content"');
|
||||
expect(response.payload).toContain('data: [DONE]');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user