-
-
Notifications
You must be signed in to change notification settings - Fork 484
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
Anthropic streaming support #682
Conversation
Streaming is now available with anthropic - https://docs.anthropic.com/en/api/messages-streaming
Sweep: PR Reviewinstructor/client.pyThe changes remove assertions that prevent the Sweep Found These Issues
instructor/instructor/client.py Line 128 in a846c45
View Diff instructor/instructor/client.py Line 311 in a846c45
View Diff instructor/dsl/iterable.pyThe changes introduce new conditions to handle Sweep Found These Issues
instructor/instructor/dsl/iterable.py Lines 114 to 115 in a846c45
View Diff instructor/dsl/partial.pyThe changes introduce new conditions to handle Sweep Found These Issues
instructor/instructor/dsl/partial.py Line 185 in a846c45
View Diff tests/llm/test_anthropic/conftest.pyThe changes introduce pytest fixtures for tests/llm/test_anthropic/test_stream.pyThe changes add four new test functions to validate synchronous and asynchronous creation of models returning either an iterable or a partial Sweep Found These Issues
instructor/tests/llm/test_anthropic/test_stream.py Lines 33 to 52 in a846c45
View Diff instructor/tests/llm/test_anthropic/test_stream.py Lines 72 to 87 in a846c45
View Diff tests/llm/test_anthropic/util.pyIntroduced a new utility file for testing with model and mode configurations. Potential IssuesSweep isn't 100% sure if the following are issues or not but they may be worth taking a look at.
instructor/tests/llm/test_anthropic/util.py Lines 1 to 5 in a846c45
View Diff |
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.
❌ Changes requested. Reviewed everything up to a846c45 in 47 seconds
More details
- Looked at
242
lines of code in6
files - Skipped
0
files when reviewing. - Skipped posting
0
drafted comments based on config settings.
Workflow ID: wflow_dnsiYwLSpx2waGgY
Want Ellipsis to fix these issues? Tag @ellipsis-dev
in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
@@ -128,8 +128,6 @@ def create_partial( | |||
strict: bool = True, |
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.
The PR introduces significant functionality changes by supporting streaming for Anthropic. Please ensure that the documentation is updated to reflect these changes, and consider adding relevant entries to the mkdocs.yml if new documentation files are created.
if json_chunk := chunk.delta.text: | ||
yield json_chunk | ||
if mode == Mode.ANTHROPIC_TOOLS: | ||
yield chunk.model_extra.get("delta", "").get("partial_json", "") |
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.
yield chunk.model_extra.get("delta", "").get("partial_json", "") | |
yield chunk.model_extra.get("delta", {}).get("partial_json", "") |
should it be {} since "".get
would error?
can you try and update the documentation on anthropic docs? |
Streaming is now live on Anthropic. This change introduces json parsing support for streamed chunks.
https://docs.anthropic.com/en/api/messages-streaming
Summary:
This PR introduces streaming support for Anthropic in the instructor library, updating methods and adding tests to ensure functionality.
Key points:
instructor/client.py
for streaming support.instructor/dsl/iterable.py
andinstructor/dsl/partial.py
for new Anthropic modes.tests/llm/test_anthropic/
to validate streaming functionality.Generated with ❤️ by ellipsis.dev