-
Notifications
You must be signed in to change notification settings - Fork 117
fix: set index of tool calls in stream mode #1468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1468 +/- ##
==========================================
- Coverage 83.99% 83.68% -0.31%
==========================================
Files 142 142
Lines 12555 12588 +33
==========================================
- Hits 10545 10534 -11
- Misses 1400 1443 +43
- Partials 610 611 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| Name: part.FunctionCall.Name, | ||
| Arguments: string(args), | ||
| }, | ||
| Index: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here should handle multiple tool calls to ensure that multiple tool calls in a single streaming response receive proper incremental indices
a27b5cd to
a7ded26
Compare
…ion (envoyproxy#1418) **Description** This PR implement adds a translator from the Anthropic API to AWS Bedrock for Anthropic. **Related Issues/PRs (if applicable)** Closes envoyproxy#1371 --------- Signed-off-by: secustor <sebastian@poxhofer.at> Signed-off-by: yxia216 <yxia216@bloomberg.net>
envoyproxy#1466) **Description** This is to fix issue: envoyproxy#1465 After this change, the empty `input: {}` is removed in `arguments` **Special notes for reviewers (if applicable)** Example: Before this change if user make a streaming request with tool use for claude: - data: {"choices":[{"index":0,"delta":{"content":"I'll check","role":"assistant"}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"content":" the delivery date for your order right"}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"content":" away."}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":"toolu_vrtx_013xZtkBipjVEQqLAdRtLyES","function":{"arguments":"{}","name":"get_delivery_date"},"type":"function"}]}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":null,"function":{"arguments":"","name":""}}]}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":null,"function":{"arguments":"{\"","name":""}}]}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":null,"function":{"arguments":"orde","name":""}}]}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":null,"function":{"arguments":"r_id\"","name":""}}]}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":null,"function":{"arguments":": \"order_12","name":""}}]}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":null,"function":{"arguments":"345\"}","name":""}}]}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{},"finish_reason":"tool_calls"}],"object":"chat.completion.chunk"} - data: {"object":"chat.completion.chunk","usage":{"prompt_tokens":458,"completion_tokens":73,"total_tokens":531,"prompt_tokens_details":{}}} - data: [DONE] After this change: - data: {"choices":[{"index":0,"delta":{"content":"I'll help you check","role":"assistant"}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"content":" the delivery date for your order. Let"}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"content":" me look that up for you."}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":"toolu_vrtx_01CrVxrmRpMn5DgBTvy2cEFX","function":{"arguments":"","name":"get_delivery_date"},"type":"function"}]}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":null,"function":{"arguments":"","name":""}}]}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":null,"function":{"arguments":"{\"o","name":""}}]}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":null,"function":{"arguments":"rde","name":""}}]}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":null,"function":{"arguments":"r_i","name":""}}]}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":null,"function":{"arguments":"d\"","name":""}}]}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":null,"function":{"arguments":": \"order_12","name":""}}]}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":null,"function":{"arguments":"345\"}","name":""}}]}}],"object":"chat.completion.chunk"} - data: {"choices":[{"index":0,"delta":{},"finish_reason":"tool_calls"}],"object":"chat.completion.chunk"} - data: {"object":"chat.completion.chunk","usage":{"prompt_tokens":458,"completion_tokens":81,"total_tokens":539,"prompt_tokens_details":{}}} - data: [DONE] --------- Signed-off-by: ydu208 <YDU208@bloomberg.net> Co-authored-by: ydu208 <YDU208@bloomberg.net> Co-authored-by: Dan Sun <dsun20@bloomberg.net> Signed-off-by: yxia216 <yxia216@bloomberg.net>
**Description** The extproc test's envoy config was missing TLS config for AWS Bedrock sicne envoyproxy#1418. Since the test is using credentials, hence only running on the main branch, this was not caught before merging it. **Related Issues/PRs (if applicable)** Follow up on envoyproxy#1418 Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> Signed-off-by: yxia216 <yxia216@bloomberg.net>
Signed-off-by: yxia216 <yxia216@bloomberg.net>
Signed-off-by: Dan Sun <dsun20@bloomberg.net> Signed-off-by: yxia216 <yxia216@bloomberg.net>
ab6f765 to
26b609e
Compare
|
/retest |
327858e to
475dd3c
Compare
Description
There is an
indexfield in the tool calls definition in stream mode: https://github.com/openai/openai-python/blob/4e8856576211064b09c0cc4a1ed35b82b169abe2/src/openai/types/chat/chat_completion_chunk.py#L48, and it's not optional. Third party libs might implement based on this assumption, for example: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/447aac2b0fbe88998e970941c1160147f355ec73/instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/patch.py#L285. Internally, this is not set and may break codes. Thus, set it as 0 to make it compatible with OpenAI API.Also, in the previous implementation,
ChatCompletionMessageToolCallParamwas reused in the response, and has anindexfield, which is not correct: https://github.com/openai/openai-python/blob/4e8856576211064b09c0cc4a1ed35b82b169abe2/src/openai/types/chat/chat_completion_message_function_tool_call_param.py#L23Discuss/suggestion:
It seems that many definitions are reused. I think it's a very bad practice and very hard to maintain/debug. Would suggest to have separate definitions.
For both converse api and anthropic api, the stream chunks have strong dependencies. We should use complete responses to write unit tests.