-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Don't require anthropic dependency when using Anthropic model with other provider
#3652
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
Conversation
| ), | ||
| # Bedrock does not support native structured output | ||
| supports_json_schema_output=False, | ||
| json_schema_transformer=None, |
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.
BedrockProvider is not the only one that uses anthropic_model_profile, so with this changes the other providers still have the same issue.
I think we should implement this as I suggested in #3625 (comment):
That means moving the
AnthropicJsonSchemaTransformerbit out ofpydantic_ai.profiles.anthropic.anthropic_model_profile, and intoAnthropicProvider.model_profile.
So anthropic_model_profile should not have any json_schema_transformer, and we should add it in AnthropicProvider.model_profile That way, AnthropicJsonSchemaTransformer will only be used with AnthropicProvider, not any other provider.
| def model_profile(self, model_name: str) -> ModelProfile | None: | ||
| return anthropic_model_profile(model_name) | ||
| profile = anthropic_model_profile(model_name) | ||
| if profile: |
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.
I liked the ModelProfile.from_profile(profile).update(...) (or ModelProfile(...).update(profile)) approach you had before better exactly because it also does the right thing when anthropic_model_profile returns None
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.
fixed it now, sorry about that
anthropic dependency when using Anthropic model with other provider
Fixes #3625
many thanks to @nataziel for the reporting and suggesting a fix