Skip to content
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

fix: Look through all streaming chunks for tools calls #8829

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

vblagoje
Copy link
Member

@vblagoje vblagoje commented Feb 7, 2025

Why:

Enhances the processing logic to support various LLM platforms—not just OpenAI. Testing with the OpenAI Python package using the Mistral platform revealed that some platforms may place tool_calls in any streamed chunk (not only in the first). This change ensures that all chunks are scanned for the tool_calls payload.

What:

  • Refined detection of tool calls across all streaming chunks.
  • Changed the assumption that tool_calls appear only in the first chunk to a search that finds them anywhere.

How can it be used:

This update ensures robust tool call tracking in streaming messages, accurately constructing payloads regardless of where the tool_calls appear:

# Updated logic to search for tool_calls in all chunks
tool_call_index = next((i for i, chunk in enumerate(chunks) if chunk.meta.get("tool_calls")), None)
tools_len = len(chunks[tool_call_index].meta.get("tool_calls", []))

How did you test it:

  • No tests were added, using old tests

Notes for the reviewer:

N/A

@github-actions github-actions bot added the type:documentation Improvements on the docs label Feb 7, 2025
@coveralls
Copy link
Collaborator

coveralls commented Feb 7, 2025

Pull Request Test Coverage Report for Build 13202693684

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.003%) to 92.712%

Files with Coverage Reduction New Missed Lines %
components/generators/chat/openai.py 2 96.4%
Totals Coverage Status
Change from base Build 13200853936: 0.003%
Covered Lines: 9057
Relevant Lines: 9769

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic:tests type:documentation Improvements on the docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants