pydantic-ai-slim 0.0.38__tar.gz → 0.0.39__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pydantic-ai-slim might be problematic. Click here for more details.
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/PKG-INFO +2 -2
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/models/bedrock.py +1 -1
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/models/groq.py +35 -9
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/providers/__init__.py +4 -0
- pydantic_ai_slim-0.0.39/pydantic_ai/providers/groq.py +75 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pyproject.toml +2 -2
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/.gitignore +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/README.md +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/__init__.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/_agent_graph.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/_cli.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/_griffe.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/_parts_manager.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/_pydantic.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/_result.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/_system_prompt.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/_utils.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/agent.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/common_tools/__init__.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/common_tools/duckduckgo.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/common_tools/tavily.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/exceptions.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/format_as_xml.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/messages.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/models/__init__.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/models/anthropic.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/models/cohere.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/models/fallback.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/models/function.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/models/gemini.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/models/instrumented.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/models/mistral.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/models/openai.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/models/test.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/models/vertexai.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/models/wrapper.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/providers/bedrock.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/providers/deepseek.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/providers/google_gla.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/providers/google_vertex.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/providers/openai.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/py.typed +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/result.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/settings.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/tools.py +0 -0
- {pydantic_ai_slim-0.0.38 → pydantic_ai_slim-0.0.39}/pydantic_ai/usage.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pydantic-ai-slim
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.39
|
|
4
4
|
Summary: Agent Framework / shim to use Pydantic with LLMs, slim package
|
|
5
5
|
Author-email: Samuel Colvin <samuel@pydantic.dev>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -29,7 +29,7 @@ Requires-Dist: exceptiongroup; python_version < '3.11'
|
|
|
29
29
|
Requires-Dist: griffe>=1.3.2
|
|
30
30
|
Requires-Dist: httpx>=0.27
|
|
31
31
|
Requires-Dist: opentelemetry-api>=1.28.0
|
|
32
|
-
Requires-Dist: pydantic-graph==0.0.
|
|
32
|
+
Requires-Dist: pydantic-graph==0.0.39
|
|
33
33
|
Requires-Dist: pydantic>=2.10
|
|
34
34
|
Requires-Dist: typing-inspection>=0.4.0
|
|
35
35
|
Provides-Extra: anthropic
|
|
@@ -10,7 +10,6 @@ from typing import TYPE_CHECKING, Generic, Literal, Union, cast, overload
|
|
|
10
10
|
|
|
11
11
|
import anyio
|
|
12
12
|
import anyio.to_thread
|
|
13
|
-
from mypy_boto3_bedrock_runtime.type_defs import ImageBlockTypeDef
|
|
14
13
|
from typing_extensions import ParamSpec, assert_never
|
|
15
14
|
|
|
16
15
|
from pydantic_ai import _utils, result
|
|
@@ -46,6 +45,7 @@ if TYPE_CHECKING:
|
|
|
46
45
|
ConverseResponseTypeDef,
|
|
47
46
|
ConverseStreamMetadataEventTypeDef,
|
|
48
47
|
ConverseStreamOutputTypeDef,
|
|
48
|
+
ImageBlockTypeDef,
|
|
49
49
|
InferenceConfigurationTypeDef,
|
|
50
50
|
MessageUnionTypeDef,
|
|
51
51
|
ToolChoiceTypeDef,
|
|
@@ -9,7 +9,7 @@ from itertools import chain
|
|
|
9
9
|
from typing import Literal, Union, cast, overload
|
|
10
10
|
|
|
11
11
|
from httpx import AsyncClient as AsyncHTTPClient
|
|
12
|
-
from typing_extensions import assert_never
|
|
12
|
+
from typing_extensions import assert_never, deprecated
|
|
13
13
|
|
|
14
14
|
from .. import ModelHTTPError, UnexpectedModelBehavior, _utils, usage
|
|
15
15
|
from .._utils import guard_tool_call_id as _guard_tool_call_id
|
|
@@ -29,15 +29,10 @@ from ..messages import (
|
|
|
29
29
|
ToolReturnPart,
|
|
30
30
|
UserPromptPart,
|
|
31
31
|
)
|
|
32
|
+
from ..providers import Provider, infer_provider
|
|
32
33
|
from ..settings import ModelSettings
|
|
33
34
|
from ..tools import ToolDefinition
|
|
34
|
-
from . import
|
|
35
|
-
Model,
|
|
36
|
-
ModelRequestParameters,
|
|
37
|
-
StreamedResponse,
|
|
38
|
-
cached_async_http_client,
|
|
39
|
-
check_allow_model_requests,
|
|
40
|
-
)
|
|
35
|
+
from . import Model, ModelRequestParameters, StreamedResponse, cached_async_http_client, check_allow_model_requests
|
|
41
36
|
|
|
42
37
|
try:
|
|
43
38
|
from groq import NOT_GIVEN, APIStatusError, AsyncGroq, AsyncStream
|
|
@@ -49,6 +44,7 @@ except ImportError as _import_error:
|
|
|
49
44
|
"you can use the `groq` optional group — `pip install 'pydantic-ai-slim[groq]'`"
|
|
50
45
|
) from _import_error
|
|
51
46
|
|
|
47
|
+
|
|
52
48
|
LatestGroqModelNames = Literal[
|
|
53
49
|
'llama-3.3-70b-versatile',
|
|
54
50
|
'llama-3.3-70b-specdec',
|
|
@@ -94,10 +90,31 @@ class GroqModel(Model):
|
|
|
94
90
|
_model_name: GroqModelName = field(repr=False)
|
|
95
91
|
_system: str | None = field(default='groq', repr=False)
|
|
96
92
|
|
|
93
|
+
@overload
|
|
94
|
+
def __init__(
|
|
95
|
+
self,
|
|
96
|
+
model_name: GroqModelName,
|
|
97
|
+
*,
|
|
98
|
+
provider: Literal['groq'] | Provider[AsyncGroq] = 'groq',
|
|
99
|
+
) -> None: ...
|
|
100
|
+
|
|
101
|
+
@deprecated('Use the `provider` parameter instead of `api_key`, `groq_client`, and `http_client`.')
|
|
102
|
+
@overload
|
|
103
|
+
def __init__(
|
|
104
|
+
self,
|
|
105
|
+
model_name: GroqModelName,
|
|
106
|
+
*,
|
|
107
|
+
provider: None = None,
|
|
108
|
+
api_key: str | None = None,
|
|
109
|
+
groq_client: AsyncGroq | None = None,
|
|
110
|
+
http_client: AsyncHTTPClient | None = None,
|
|
111
|
+
) -> None: ...
|
|
112
|
+
|
|
97
113
|
def __init__(
|
|
98
114
|
self,
|
|
99
115
|
model_name: GroqModelName,
|
|
100
116
|
*,
|
|
117
|
+
provider: Literal['groq'] | Provider[AsyncGroq] | None = None,
|
|
101
118
|
api_key: str | None = None,
|
|
102
119
|
groq_client: AsyncGroq | None = None,
|
|
103
120
|
http_client: AsyncHTTPClient | None = None,
|
|
@@ -107,6 +124,9 @@ class GroqModel(Model):
|
|
|
107
124
|
Args:
|
|
108
125
|
model_name: The name of the Groq model to use. List of model names available
|
|
109
126
|
[here](https://console.groq.com/docs/models).
|
|
127
|
+
provider: The provider to use for authentication and API access. Can be either the string
|
|
128
|
+
'groq' or an instance of `Provider[AsyncGroq]`. If not provided, a new provider will be
|
|
129
|
+
created using the other parameters.
|
|
110
130
|
api_key: The API key to use for authentication, if not provided, the `GROQ_API_KEY` environment variable
|
|
111
131
|
will be used if available.
|
|
112
132
|
groq_client: An existing
|
|
@@ -115,7 +135,13 @@ class GroqModel(Model):
|
|
|
115
135
|
http_client: An existing `httpx.AsyncClient` to use for making HTTP requests.
|
|
116
136
|
"""
|
|
117
137
|
self._model_name = model_name
|
|
118
|
-
|
|
138
|
+
|
|
139
|
+
if provider is not None:
|
|
140
|
+
if isinstance(provider, str):
|
|
141
|
+
self.client = infer_provider(provider).client
|
|
142
|
+
else:
|
|
143
|
+
self.client = provider.client
|
|
144
|
+
elif groq_client is not None:
|
|
119
145
|
assert http_client is None, 'Cannot provide both `groq_client` and `http_client`'
|
|
120
146
|
assert api_key is None, 'Cannot provide both `groq_client` and `api_key`'
|
|
121
147
|
self.client = groq_client
|
|
@@ -65,5 +65,9 @@ def infer_provider(provider: str) -> Provider[Any]:
|
|
|
65
65
|
from .bedrock import BedrockProvider
|
|
66
66
|
|
|
67
67
|
return BedrockProvider()
|
|
68
|
+
elif provider == 'groq':
|
|
69
|
+
from .groq import GroqProvider
|
|
70
|
+
|
|
71
|
+
return GroqProvider()
|
|
68
72
|
else: # pragma: no cover
|
|
69
73
|
raise ValueError(f'Unknown provider: {provider}')
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from __future__ import annotations as _annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from typing import overload
|
|
5
|
+
|
|
6
|
+
from httpx import AsyncClient as AsyncHTTPClient
|
|
7
|
+
|
|
8
|
+
from pydantic_ai.models import cached_async_http_client
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
from groq import AsyncGroq
|
|
12
|
+
except ImportError as _import_error: # pragma: no cover
|
|
13
|
+
raise ImportError(
|
|
14
|
+
'Please install `groq` to use the Groq provider, '
|
|
15
|
+
"you can use the `groq` optional group — `pip install 'pydantic-ai-slim[groq]'`"
|
|
16
|
+
) from _import_error
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
from . import Provider
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class GroqProvider(Provider[AsyncGroq]):
|
|
23
|
+
"""Provider for Groq API."""
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def name(self) -> str:
|
|
27
|
+
return 'groq'
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def base_url(self) -> str:
|
|
31
|
+
return os.environ.get('GROQ_BASE_URL', 'https://api.groq.com')
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def client(self) -> AsyncGroq:
|
|
35
|
+
return self._client
|
|
36
|
+
|
|
37
|
+
@overload
|
|
38
|
+
def __init__(self, *, groq_client: AsyncGroq | None = None) -> None: ...
|
|
39
|
+
|
|
40
|
+
@overload
|
|
41
|
+
def __init__(self, *, api_key: str | None = None, http_client: AsyncHTTPClient | None = None) -> None: ...
|
|
42
|
+
|
|
43
|
+
def __init__(
|
|
44
|
+
self,
|
|
45
|
+
*,
|
|
46
|
+
api_key: str | None = None,
|
|
47
|
+
groq_client: AsyncGroq | None = None,
|
|
48
|
+
http_client: AsyncHTTPClient | None = None,
|
|
49
|
+
) -> None:
|
|
50
|
+
"""Create a new Groq provider.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
api_key: The API key to use for authentication, if not provided, the `GROQ_API_KEY` environment variable
|
|
54
|
+
will be used if available.
|
|
55
|
+
groq_client: An existing
|
|
56
|
+
[`AsyncGroq`](https://github.com/groq/groq-python?tab=readme-ov-file#async-usage)
|
|
57
|
+
client to use. If provided, `api_key` and `http_client` must be `None`.
|
|
58
|
+
http_client: An existing `AsyncHTTPClient` to use for making HTTP requests.
|
|
59
|
+
"""
|
|
60
|
+
api_key = api_key or os.environ.get('GROQ_API_KEY')
|
|
61
|
+
|
|
62
|
+
if api_key is None and groq_client is None:
|
|
63
|
+
raise ValueError(
|
|
64
|
+
'Set the `GROQ_API_KEY` environment variable or pass it via `GroqProvider(api_key=...)`'
|
|
65
|
+
'to use the Groq provider.'
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
if groq_client is not None:
|
|
69
|
+
assert http_client is None, 'Cannot provide both `groq_client` and `http_client`'
|
|
70
|
+
assert api_key is None, 'Cannot provide both `groq_client` and `api_key`'
|
|
71
|
+
self._client = groq_client
|
|
72
|
+
elif http_client is not None:
|
|
73
|
+
self._client = AsyncGroq(base_url=self.base_url, api_key=api_key, http_client=http_client)
|
|
74
|
+
else:
|
|
75
|
+
self._client = AsyncGroq(base_url=self.base_url, api_key=api_key, http_client=cached_async_http_client())
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pydantic-ai-slim"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.39"
|
|
8
8
|
description = "Agent Framework / shim to use Pydantic with LLMs, slim package"
|
|
9
9
|
authors = [{ name = "Samuel Colvin", email = "samuel@pydantic.dev" }]
|
|
10
10
|
license = "MIT"
|
|
@@ -36,7 +36,7 @@ dependencies = [
|
|
|
36
36
|
"griffe>=1.3.2",
|
|
37
37
|
"httpx>=0.27",
|
|
38
38
|
"pydantic>=2.10",
|
|
39
|
-
"pydantic-graph==0.0.
|
|
39
|
+
"pydantic-graph==0.0.39",
|
|
40
40
|
"exceptiongroup; python_version < '3.11'",
|
|
41
41
|
"opentelemetry-api>=1.28.0",
|
|
42
42
|
"typing-inspection>=0.4.0",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|