Skip to content

Conversation

L3o-pold
Copy link
Contributor

@L3o-pold L3o-pold commented Jul 4, 2025

What:

  • Bug Fix
  • New Feature

Description:

With some OpenAI "compatible" servers like VLLM we may have delta tools calls without the arguments attribute like this:

data: {"id":"chatcmpl-996b0e04-7602-4c12-ac19-2dc1c243a6d5","object":"chat.completion.chunk","created":1751620274,"model":"llama4","choices":[{"index":0,"delta":{"tool_calls":[{"id":"InRVNk0Ic","type":"function","index":0,"function":{"name":"get_weather"}}]}}]}

@iBotPeaches iBotPeaches added the Non-OpenAI Model Not an OpenAI Model. label Jul 4, 2025
@L3o-pold L3o-pold force-pushed the L3o-pold-patch-1 branch from 781a0a2 to e04a6a6 Compare July 4, 2025 09:58
@iBotPeaches iBotPeaches changed the title fix: streamed response tool call without arguments fix(VLLM): streamed response tool call without arguments Jul 4, 2025
@iBotPeaches
Copy link
Collaborator

May you enable edits by maintainers? I don't have push to this branch or add this test case?

Index: tests/Resources/Chat.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/tests/Resources/Chat.php b/tests/Resources/Chat.php
--- a/tests/Resources/Chat.php	(revision e04a6a6b9211a5cf741ab3fea01430fd790a9001)
+++ b/tests/Resources/Chat.php	(revision 7835cfd3b2adfd8f488b3444561f23923049889a)
@@ -98,6 +98,11 @@
 
     expect($result->meta())
         ->toBeInstanceOf(MetaInformation::class);
+
+    foreach ($result->getIterator() as $response) {
+        expect($response)
+            ->toBeInstanceOf(CreateStreamedResponse::class);
+    }
 });
 
 test('handles ping messages in stream', function () {
Index: tests/Fixtures/Streams/ChatCompletionCreate.txt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/tests/Fixtures/Streams/ChatCompletionCreate.txt b/tests/Fixtures/Streams/ChatCompletionCreate.txt
--- a/tests/Fixtures/Streams/ChatCompletionCreate.txt	(revision e04a6a6b9211a5cf741ab3fea01430fd790a9001)
+++ b/tests/Fixtures/Streams/ChatCompletionCreate.txt	(revision 7835cfd3b2adfd8f488b3444561f23923049889a)
@@ -9,4 +9,5 @@
 data: {"id":"chatcmpl-6wdIE4DsUtqf1srdMTsfkJp0VWZgz","object":"chat.completion.chunk","created":1679432086,"model":"gpt-4-0314","choices":[{"delta":{"content":" today"},"index":0,"finish_reason":null}]}
 data: {"id":"chatcmpl-6wdIE4DsUtqf1srdMTsfkJp0VWZgz","object":"chat.completion.chunk","created":1679432086,"model":"gpt-4-0314","choices":[{"delta":{"content":"?"},"index":0,"finish_reason":null}]}
 data: {"id":"chatcmpl-6wdIE4DsUtqf1srdMTsfkJp0VWZgz","object":"chat.completion.chunk","created":1679432086,"model":"gpt-4-0314","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}
+data: {"id":"chatcmpl-6wdIE4DsUtqf1srdMTsfkJp0VWZgz","object":"chat.completion.chunk","created":1751620274,"model":"gpt-4-0314","choices":[{"index":0,"delta":{"tool_calls":[{"id":"InRVNk0Ic","type":"function","index":0,"function":{"name":"get_weather"}}]}}]}
 data: [DONE]

@L3o-pold L3o-pold force-pushed the L3o-pold-patch-1 branch from e04a6a6 to 04991c7 Compare July 4, 2025 11:39
@L3o-pold
Copy link
Contributor Author

L3o-pold commented Jul 4, 2025

May you enable edits by maintainers? I don't have push to this branch or add this test case?

@iBotPeaches I can't as this PR is from an organisation repository but I applied your patch

@iBotPeaches iBotPeaches added this to the v0.15.0 milestone Jul 4, 2025
@iBotPeaches iBotPeaches merged commit e9822ad into openai-php:main Jul 4, 2025
12 checks passed
@iBotPeaches
Copy link
Collaborator

thanks! congrats on 1st pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Non-OpenAI Model Not an OpenAI Model.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants