-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow proper type on AnthropicProvider
when using Bedrock
#2490
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
Open
akoshel
wants to merge
12
commits into
pydantic:main
Choose a base branch
from
akoshel:issue-2215
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+30
−35
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b856c3a
fix: issue-2215
akoshel 20a8451
Merge remote-tracking branch 'origin/main' into issue-2215
akoshel aa939f1
fix: test_provider_names
akoshel c10c059
fix: parallel_evaluation_example
akoshel 546e824
fix: typealias for python=3.9
akoshel 9b84bcd
fix: typealias for python=3.9
akoshel 0fb8f3a
fix: typealias for python=3.9
akoshel cc388ed
feat: AnthropicProvider tests added
akoshel 4f4836d
fix: review comments
akoshel a1ec18f
Merge remote-tracking branch 'origin/main' into issue-2215
akoshel 4f2dbc1
fix: ci-coverage
akoshel 4ceb1fe
Update pydantic_ai_slim/pydantic_ai/providers/anthropic.py
Kludex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -37,12 +37,13 @@ | |||||
) | ||||||
from ..profiles import ModelProfileSpec | ||||||
from ..providers import Provider, infer_provider | ||||||
from ..providers.anthropic import AsyncAnthropicClient | ||||||
from ..settings import ModelSettings | ||||||
from ..tools import ToolDefinition | ||||||
from . import Model, ModelRequestParameters, StreamedResponse, check_allow_model_requests, download_item, get_user_agent | ||||||
|
||||||
try: | ||||||
from anthropic import NOT_GIVEN, APIStatusError, AsyncAnthropic, AsyncStream | ||||||
from anthropic import NOT_GIVEN, APIStatusError, AsyncStream | ||||||
from anthropic.types.beta import ( | ||||||
BetaBase64PDFBlockParam, | ||||||
BetaBase64PDFSourceParam, | ||||||
|
@@ -134,7 +135,7 @@ class AnthropicModel(Model): | |||||
Apart from `__init__`, all methods are private or match those of the base class. | ||||||
""" | ||||||
|
||||||
client: AsyncAnthropic = field(repr=False) | ||||||
client: AsyncAnthropicClient = field(repr=False) | ||||||
|
||||||
_model_name: AnthropicModelName = field(repr=False) | ||||||
_system: str = field(default='anthropic', repr=False) | ||||||
|
@@ -143,7 +144,7 @@ def __init__( | |||||
self, | ||||||
model_name: AnthropicModelName, | ||||||
*, | ||||||
provider: Literal['anthropic'] | Provider[AsyncAnthropic] = 'anthropic', | ||||||
provider: Literal['anthropic'] | Provider[AsyncAnthropicClient] = 'anthropic', | ||||||
profile: ModelProfileSpec | None = None, | ||||||
settings: ModelSettings | None = None, | ||||||
): | ||||||
|
@@ -153,7 +154,7 @@ def __init__( | |||||
model_name: The name of the Anthropic model to use. List of model names available | ||||||
[here](https://docs.anthropic.com/en/docs/about-claude/models). | ||||||
provider: The provider to use for the Anthropic API. Can be either the string 'anthropic' or an | ||||||
instance of `Provider[AsyncAnthropic]`. If not provided, the other parameters will be used. | ||||||
instance of `Provider[ASYNC_ANTHROPIC_CLIENT]`. If not provided, the other parameters will be used. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
profile: The model profile to use. Defaults to a profile picked by the provider based on the model name. | ||||||
settings: Default model settings for this model instance. | ||||||
""" | ||||||
|
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ | |
|
||
from pydantic_ai.providers.anthropic import AnthropicProvider | ||
from pydantic_ai.providers.azure import AzureProvider | ||
from pydantic_ai.providers.cohere import CohereProvider | ||
from pydantic_ai.providers.deepseek import DeepSeekProvider | ||
from pydantic_ai.providers.fireworks import FireworksProvider | ||
from pydantic_ai.providers.github import GitHubProvider | ||
|
@@ -35,7 +34,6 @@ | |
|
||
test_infer_provider_params = [ | ||
('anthropic', AnthropicProvider, 'ANTHROPIC_API_KEY'), | ||
('cohere', CohereProvider, 'CO_API_KEY'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you remove this? |
||
('deepseek', DeepSeekProvider, 'DEEPSEEK_API_KEY'), | ||
('openrouter', OpenRouterProvider, 'OPENROUTER_API_KEY'), | ||
('vercel', VercelProvider, 'VERCEL_AI_GATEWAY_API_KEY'), | ||
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.