Skip to content

Conversation

SyedShahmeerAli12
Copy link

Related Issues

Proposed Changes:

This PR addresses the confusing and redundant index fields in StreamingChunk and ToolCallDelta classes. The issue was caused by having generic index field names that were ambiguous and could lead to confusion about what they represent.

What was changed:

  • Renamed StreamingChunk.index to StreamingChunk.chunk_index for clarity
  • Renamed ToolCallDelta.index to ToolCallDelta.tool_call_index for clarity
  • Added backward compatibility in from_dict methods to ensure existing code continues to work
  • Updated all references throughout the codebase to use the new field names
  • Fixed test files and fixtures to use the new field names

How it works:
The field renames make the API much clearer by using descriptive names that indicate the purpose of each field. The chunk_index represents the index of the streaming chunk, while tool_call_index represents the index of the tool call within that chunk. Backward compatibility is maintained through the from_dict methods that can still accept the old index field names.

How did you test it?

  • Unit tests: Updated and ran all affected test files
  • Integration tests: Verified that the field renames work correctly across the entire codebase
  • Manual verification: Confirmed that all 52 tests pass across affected test files
  • Backward compatibility: Verified that existing code using the old field names continues to work

Test results:

  • test/dataclasses/test_streaming_chunk.py: 18 tests passed
  • test/components/generators/test_utils.py: 9 tests passed
  • test/components/generators/chat/test_openai.py: 25 tests passed
  • Total: 52 tests passed, 0 failures

Notes for the reviewer

  • The changes are purely field renames with no functional changes to the API
  • Backward compatibility is maintained through from_dict methods
  • All test files have been updated to use the new field names
  • The fix addresses the exact issue described in Improve index keys in StreamingChunk #9684 about confusing and redundant index fields

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes
  • I added unit tests and updated the docstrings
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I documented my code
  • I ran pre-commit hooks and fixed any issue

@SyedShahmeerAli12 SyedShahmeerAli12 requested a review from a team as a code owner August 30, 2025 23:22
@SyedShahmeerAli12 SyedShahmeerAli12 requested review from vblagoje and removed request for a team August 30, 2025 23:22
@CLAassistant
Copy link

CLAassistant commented Aug 30, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added topic:tests type:documentation Improvements on the docs labels Aug 30, 2025
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.

Improve index keys in StreamingChunk
2 participants