New anthropic client to support new generator output design - #410
Merged
liyin2015 merged 3 commits intoJul 5, 2025
Merged
Conversation
…tput design of raw_response
liyin2015
reviewed
Jul 5, 2025
|
|
||
| from dotenv import load_dotenv | ||
|
|
||
| load_dotenv() |
liyin2015
reviewed
Jul 5, 2025
liyin2015
left a comment
Member
There was a problem hiding this comment.
overall, it looks fine, will look closer tomorrow
phi-jkim
pushed a commit
that referenced
this pull request
Jul 22, 2025
…upport_new_generator_output_type New anthropic client to support new generator output design
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.
What does this PR do?
These are some of the things this PR does and a link to the design document
Design document: https://www.notion.so/21c294805781808f898ae1800297b043?v=21c294805781801badc1000ca12d6f74&p=22629480578180cbaadde27d0574e135&pm=s
• Updated AnthropicAPIClient to use OpenAI SDK with Anthropic's compatibility
endpoint instead of the native Anthropic API client
• Added Response API compatibility converter (from OpenAI agents SDK) - Created
ChatCompletionToResponseConverter utility to transform ChatCompletion objects into
OpenAI's Response API format for raw_response of the generator output which should be model-agnostic (follow the OpenAI Response API standard)
Design: Anthropic Client Response API Support
The new Anthropic client implementation supports AdalFlow's model-agnostic
raw_response field design through the following architecture:
OpenAI SDK Compatibility Layer
compatibility endpoint
Anthropic-specific features
Response API Converter (ChatCompletionToResponseConverter)
consistency across model providers
sequencing
Model-Agnostic Generator Output
stream events)
access
with detailed token breakdowns
Before submitting