fix: Rename index fields to chunk_index and tool_call_index for clarity #9750
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issues
index
keys inStreamingChunk
#9684Proposed Changes:
This PR addresses the confusing and redundant
index
fields inStreamingChunk
andToolCallDelta
classes. The issue was caused by having genericindex
field names that were ambiguous and could lead to confusion about what they represent.What was changed:
StreamingChunk.index
toStreamingChunk.chunk_index
for clarityToolCallDelta.index
toToolCallDelta.tool_call_index
for clarityfrom_dict
methods to ensure existing code continues to workHow 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, whiletool_call_index
represents the index of the tool call within that chunk. Backward compatibility is maintained through thefrom_dict
methods that can still accept the oldindex
field names.How did you test it?
Test results:
test/dataclasses/test_streaming_chunk.py
: 18 tests passedtest/components/generators/test_utils.py
: 9 tests passedtest/components/generators/chat/test_openai.py
: 25 tests passedNotes for the reviewer
from_dict
methodsindex
keys inStreamingChunk
#9684 about confusing and redundantindex
fieldsChecklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
and added!
in case the PR includes breaking changes.