Fix Cohere streaming and xAI tools validation#1983
Merged
Conversation
Contributor
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed everything up to 83dd71c in 1 minute and 16 seconds. Click for details.
- Reviewed
464lines of code in5files - Skipped
0files when reviewing. - Skipped posting
5draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. instructor/dsl/iterable.py:153
- Draft comment:
The COHERE extraction logic (handling event_type and chunk_type) is duplicated in both sync and async methods. Consider refactoring this block into a helper function to adhere to DRY principles. - Reason this comment was not posted:
Confidence changes required:80%<= threshold85%None
2. instructor/providers/cohere/client.py:84
- Draft comment:
In the async_wrapper, using call_kwargs.pop("stream", False) directly modifies the caller’s dictionary. Consider copying the kwargs before modification to prevent unintended side effects. - Reason this comment was not posted:
Confidence changes required:80%<= threshold85%None
3. instructor/providers/xai/client.py:137
- Draft comment:
The logic for selecting and preparing the response model (using prepare_response_model for XAI_TOOLS or streaming mode) could benefit from an inline comment clarifying the decision criteria for future maintainers. - Reason this comment was not posted:
Confidence changes required:80%<= threshold85%None
4. instructor/providers/xai/client.py:218
- Draft comment:
The error message when no tool calls and no text content are found includes the raw response. Ensure that exposing raw responses does not leak sensitive data in production. - Reason this comment was not posted:
Confidence changes required:80%<= threshold85%None
5. instructor/providers/xai/client.py:312
- Draft comment:
The non-streaming branch in the create function duplicates JSON extraction logic from both text and tool_call paths. Consider refactoring this repeated logic into a dedicated helper to reduce duplication. - Reason this comment was not posted:
Confidence changes required:80%<= threshold85%None
Workflow ID: wflow_r5S1IlEJEP8WT8IW
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
instructor | 159f121 | Commit Preview URL Branch Preview URL |
Jan 04 2026, 04:45 PM |
Contributor
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed 159f121 in 57 seconds. Click for details.
- Reviewed
589lines of code in3files - Skipped
0files when reviewing. - Skipped posting
5draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. .pre-commit-config.yaml:37
- Draft comment:
The ty-check hook now ignores unresolved imports. Please add a brief comment explaining why '--ignore unresolved-import' is needed. - Reason this comment was not posted:
Confidence changes required:80%<= threshold85%None
2. instructor/dsl/iterable.py:157
- Draft comment:
There is repeated JSON start extraction logic (search for '{' or '[' and slicing) in multiple event branches. Consider refactoring this pattern into a helper function to adhere to the DRY principle. - Reason this comment was not posted:
Confidence changes required:80%<= threshold85%None
3. instructor/dsl/iterable.py:370
- Draft comment:
The asynchronous JSON extraction (in extract_json_async) duplicates similar logic to its synchronous counterpart. Centralize the JSON start extraction into a shared helper to improve maintainability. - Reason this comment was not posted:
Confidence changes required:80%<= threshold85%None
4. instructor/dsl/partial.py:288
- Draft comment:
Multiple branches in the extract_json function show nearly identical logic for locating the JSON start index. Refactor these repeated blocks into a common helper to reduce duplication. - Reason this comment was not posted:
Confidence changes required:80%<= threshold85%None
5. instructor/dsl/partial.py:245
- Draft comment:
Potential bug: In model_from_chunks, 'chunk_buffer += chunk' is used, which concatenates the characters of the string instead of appending the full chunk. Use 'chunk_buffer.append(chunk)' to correctly accumulate whole chunks. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
Workflow ID: wflow_KlNJhd3BDhfMG1M8
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Testing
Important
Enhance Cohere streaming and xAI tools validation by using
chat_streamand validating responses with prepared models.chat_streamfor streaming infrom_cohere()inclient.py.Mode.COHERE_TOOLSandMode.COHERE_JSON_SCHEMAinextract_json()andextract_json_async()initerable.pyandpartial.py.acreate()andcreate()inclient.py._validate_model_from_json()infunction_calls.py.ty-checkargs in.pre-commit-config.yamlto ignore unresolved imports.This description was created by
for 159f121. You can customize this summary. It will automatically update as commits are pushed.