pydantic-ai-slim 0.0.19__py3-none-any.whl → 0.0.20__py3-none-any.whl
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/_pydantic.py +1 -0
- pydantic_ai/_result.py +26 -21
- pydantic_ai/_system_prompt.py +4 -4
- pydantic_ai/agent.py +107 -87
- pydantic_ai/messages.py +3 -10
- pydantic_ai/models/__init__.py +29 -1
- pydantic_ai/models/anthropic.py +94 -30
- pydantic_ai/models/cohere.py +278 -0
- pydantic_ai/models/function.py +12 -8
- pydantic_ai/models/gemini.py +9 -9
- pydantic_ai/models/groq.py +9 -7
- pydantic_ai/models/mistral.py +12 -6
- pydantic_ai/models/ollama.py +3 -0
- pydantic_ai/models/openai.py +27 -13
- pydantic_ai/models/test.py +16 -8
- pydantic_ai/models/vertexai.py +2 -1
- pydantic_ai/result.py +45 -26
- pydantic_ai/settings.py +18 -1
- pydantic_ai/tools.py +18 -18
- {pydantic_ai_slim-0.0.19.dist-info → pydantic_ai_slim-0.0.20.dist-info}/METADATA +6 -4
- pydantic_ai_slim-0.0.20.dist-info/RECORD +30 -0
- pydantic_ai_slim-0.0.19.dist-info/RECORD +0 -29
- {pydantic_ai_slim-0.0.19.dist-info → pydantic_ai_slim-0.0.20.dist-info}/WHEEL +0 -0
pydantic_ai/tools.py
CHANGED
|
@@ -17,7 +17,7 @@ if TYPE_CHECKING:
|
|
|
17
17
|
from .result import Usage
|
|
18
18
|
|
|
19
19
|
__all__ = (
|
|
20
|
-
'
|
|
20
|
+
'AgentDepsT',
|
|
21
21
|
'DocstringFormat',
|
|
22
22
|
'RunContext',
|
|
23
23
|
'SystemPromptFunc',
|
|
@@ -31,15 +31,15 @@ __all__ = (
|
|
|
31
31
|
'ToolDefinition',
|
|
32
32
|
)
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
AgentDepsT = TypeVar('AgentDepsT', default=None, contravariant=True)
|
|
35
35
|
"""Type variable for agent dependencies."""
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
@dataclasses.dataclass
|
|
39
|
-
class RunContext(Generic[
|
|
39
|
+
class RunContext(Generic[AgentDepsT]):
|
|
40
40
|
"""Information about the current call."""
|
|
41
41
|
|
|
42
|
-
deps:
|
|
42
|
+
deps: AgentDepsT
|
|
43
43
|
"""Dependencies for the agent."""
|
|
44
44
|
model: models.Model
|
|
45
45
|
"""The model used in this run."""
|
|
@@ -58,7 +58,7 @@ class RunContext(Generic[AgentDeps]):
|
|
|
58
58
|
|
|
59
59
|
def replace_with(
|
|
60
60
|
self, retry: int | None = None, tool_name: str | None | _utils.Unset = _utils.UNSET
|
|
61
|
-
) -> RunContext[
|
|
61
|
+
) -> RunContext[AgentDepsT]:
|
|
62
62
|
# Create a new `RunContext` a new `retry` value and `tool_name`.
|
|
63
63
|
kwargs = {}
|
|
64
64
|
if retry is not None:
|
|
@@ -72,8 +72,8 @@ ToolParams = ParamSpec('ToolParams', default=...)
|
|
|
72
72
|
"""Retrieval function param spec."""
|
|
73
73
|
|
|
74
74
|
SystemPromptFunc = Union[
|
|
75
|
-
Callable[[RunContext[
|
|
76
|
-
Callable[[RunContext[
|
|
75
|
+
Callable[[RunContext[AgentDepsT]], str],
|
|
76
|
+
Callable[[RunContext[AgentDepsT]], Awaitable[str]],
|
|
77
77
|
Callable[[], str],
|
|
78
78
|
Callable[[], Awaitable[str]],
|
|
79
79
|
]
|
|
@@ -82,7 +82,7 @@ SystemPromptFunc = Union[
|
|
|
82
82
|
Usage `SystemPromptFunc[AgentDeps]`.
|
|
83
83
|
"""
|
|
84
84
|
|
|
85
|
-
ToolFuncContext = Callable[Concatenate[RunContext[
|
|
85
|
+
ToolFuncContext = Callable[Concatenate[RunContext[AgentDepsT], ToolParams], Any]
|
|
86
86
|
"""A tool function that takes `RunContext` as the first argument.
|
|
87
87
|
|
|
88
88
|
Usage `ToolContextFunc[AgentDeps, ToolParams]`.
|
|
@@ -92,7 +92,7 @@ ToolFuncPlain = Callable[ToolParams, Any]
|
|
|
92
92
|
|
|
93
93
|
Usage `ToolPlainFunc[ToolParams]`.
|
|
94
94
|
"""
|
|
95
|
-
ToolFuncEither = Union[ToolFuncContext[
|
|
95
|
+
ToolFuncEither = Union[ToolFuncContext[AgentDepsT, ToolParams], ToolFuncPlain[ToolParams]]
|
|
96
96
|
"""Either kind of tool function.
|
|
97
97
|
|
|
98
98
|
This is just a union of [`ToolFuncContext`][pydantic_ai.tools.ToolFuncContext] and
|
|
@@ -100,7 +100,7 @@ This is just a union of [`ToolFuncContext`][pydantic_ai.tools.ToolFuncContext] a
|
|
|
100
100
|
|
|
101
101
|
Usage `ToolFuncEither[AgentDeps, ToolParams]`.
|
|
102
102
|
"""
|
|
103
|
-
ToolPrepareFunc: TypeAlias = 'Callable[[RunContext[
|
|
103
|
+
ToolPrepareFunc: TypeAlias = 'Callable[[RunContext[AgentDepsT], ToolDefinition], Awaitable[ToolDefinition | None]]'
|
|
104
104
|
"""Definition of a function that can prepare a tool definition at call time.
|
|
105
105
|
|
|
106
106
|
See [tool docs](../tools.md#tool-prepare) for more information.
|
|
@@ -141,15 +141,15 @@ A = TypeVar('A')
|
|
|
141
141
|
|
|
142
142
|
|
|
143
143
|
@dataclass(init=False)
|
|
144
|
-
class Tool(Generic[
|
|
144
|
+
class Tool(Generic[AgentDepsT]):
|
|
145
145
|
"""A tool function for an agent."""
|
|
146
146
|
|
|
147
|
-
function: ToolFuncEither[
|
|
147
|
+
function: ToolFuncEither[AgentDepsT]
|
|
148
148
|
takes_ctx: bool
|
|
149
149
|
max_retries: int | None
|
|
150
150
|
name: str
|
|
151
151
|
description: str
|
|
152
|
-
prepare: ToolPrepareFunc[
|
|
152
|
+
prepare: ToolPrepareFunc[AgentDepsT] | None
|
|
153
153
|
docstring_format: DocstringFormat
|
|
154
154
|
require_parameter_descriptions: bool
|
|
155
155
|
_is_async: bool = field(init=False)
|
|
@@ -162,13 +162,13 @@ class Tool(Generic[AgentDeps]):
|
|
|
162
162
|
|
|
163
163
|
def __init__(
|
|
164
164
|
self,
|
|
165
|
-
function: ToolFuncEither[
|
|
165
|
+
function: ToolFuncEither[AgentDepsT],
|
|
166
166
|
*,
|
|
167
167
|
takes_ctx: bool | None = None,
|
|
168
168
|
max_retries: int | None = None,
|
|
169
169
|
name: str | None = None,
|
|
170
170
|
description: str | None = None,
|
|
171
|
-
prepare: ToolPrepareFunc[
|
|
171
|
+
prepare: ToolPrepareFunc[AgentDepsT] | None = None,
|
|
172
172
|
docstring_format: DocstringFormat = 'auto',
|
|
173
173
|
require_parameter_descriptions: bool = False,
|
|
174
174
|
):
|
|
@@ -240,7 +240,7 @@ class Tool(Generic[AgentDeps]):
|
|
|
240
240
|
self._validator = f['validator']
|
|
241
241
|
self._parameters_json_schema = f['json_schema']
|
|
242
242
|
|
|
243
|
-
async def prepare_tool_def(self, ctx: RunContext[
|
|
243
|
+
async def prepare_tool_def(self, ctx: RunContext[AgentDepsT]) -> ToolDefinition | None:
|
|
244
244
|
"""Get the tool definition.
|
|
245
245
|
|
|
246
246
|
By default, this method creates a tool definition, then either returns it, or calls `self.prepare`
|
|
@@ -260,7 +260,7 @@ class Tool(Generic[AgentDeps]):
|
|
|
260
260
|
return tool_def
|
|
261
261
|
|
|
262
262
|
async def run(
|
|
263
|
-
self, message: _messages.ToolCallPart, run_context: RunContext[
|
|
263
|
+
self, message: _messages.ToolCallPart, run_context: RunContext[AgentDepsT]
|
|
264
264
|
) -> _messages.ModelRequestPart:
|
|
265
265
|
"""Run the tool function asynchronously."""
|
|
266
266
|
try:
|
|
@@ -293,7 +293,7 @@ class Tool(Generic[AgentDeps]):
|
|
|
293
293
|
self,
|
|
294
294
|
args_dict: dict[str, Any],
|
|
295
295
|
message: _messages.ToolCallPart,
|
|
296
|
-
run_context: RunContext[
|
|
296
|
+
run_context: RunContext[AgentDepsT],
|
|
297
297
|
) -> tuple[list[Any], dict[str, Any]]:
|
|
298
298
|
if self._single_arg_name:
|
|
299
299
|
args_dict = {self._single_arg_name: args_dict}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pydantic-ai-slim
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.20
|
|
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
|
|
@@ -26,13 +26,15 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
26
26
|
Requires-Python: >=3.9
|
|
27
27
|
Requires-Dist: eval-type-backport>=0.2.0
|
|
28
28
|
Requires-Dist: griffe>=1.3.2
|
|
29
|
-
Requires-Dist: httpx>=0.27
|
|
29
|
+
Requires-Dist: httpx>=0.27
|
|
30
30
|
Requires-Dist: logfire-api>=1.2.0
|
|
31
31
|
Requires-Dist: pydantic>=2.10
|
|
32
32
|
Provides-Extra: anthropic
|
|
33
33
|
Requires-Dist: anthropic>=0.40.0; extra == 'anthropic'
|
|
34
|
+
Provides-Extra: cohere
|
|
35
|
+
Requires-Dist: cohere>=5.13.11; extra == 'cohere'
|
|
34
36
|
Provides-Extra: graph
|
|
35
|
-
Requires-Dist: pydantic-graph==0.0.
|
|
37
|
+
Requires-Dist: pydantic-graph==0.0.20; extra == 'graph'
|
|
36
38
|
Provides-Extra: groq
|
|
37
39
|
Requires-Dist: groq>=0.12.0; extra == 'groq'
|
|
38
40
|
Provides-Extra: logfire
|
|
@@ -40,7 +42,7 @@ Requires-Dist: logfire>=2.3; extra == 'logfire'
|
|
|
40
42
|
Provides-Extra: mistral
|
|
41
43
|
Requires-Dist: mistralai>=1.2.5; extra == 'mistral'
|
|
42
44
|
Provides-Extra: openai
|
|
43
|
-
Requires-Dist: openai>=1.
|
|
45
|
+
Requires-Dist: openai>=1.59.0; extra == 'openai'
|
|
44
46
|
Provides-Extra: vertexai
|
|
45
47
|
Requires-Dist: google-auth>=2.36.0; extra == 'vertexai'
|
|
46
48
|
Requires-Dist: requests>=2.32.3; extra == 'vertexai'
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
pydantic_ai/__init__.py,sha256=FbYetEgT6OO25u2KF5ZnFxKpz5DtnSpfckRXP4mjl8E,489
|
|
2
|
+
pydantic_ai/_griffe.py,sha256=RYRKiLbgG97QxnazbAwlnc74XxevGHLQet-FGfq9qls,3960
|
|
3
|
+
pydantic_ai/_parts_manager.py,sha256=pMDZs6BGC8EmaNa-73QvuptmxdG2MhBrBLIydCOl-gM,11886
|
|
4
|
+
pydantic_ai/_pydantic.py,sha256=dROz3Hmfdi0C2exq88FhefDRVo_8S3rtkXnoUHzsz0c,8753
|
|
5
|
+
pydantic_ai/_result.py,sha256=zlkI82g78DeLW4zTCP3OgWeMUUOqxeDdu0nxLKYsv9c,10381
|
|
6
|
+
pydantic_ai/_system_prompt.py,sha256=602c2jyle2R_SesOrITBDETZqsLk4BZ8Cbo8yEhmx04,1120
|
|
7
|
+
pydantic_ai/_utils.py,sha256=EHW866W6ZpGJLCWtoEAcwIPeWo9OQFhnD5el2DwVcwc,10949
|
|
8
|
+
pydantic_ai/agent.py,sha256=EwaH207k4LcU_M-DYom8ZFiKMVaHJ2ZobxU2WjjsrSk,63500
|
|
9
|
+
pydantic_ai/exceptions.py,sha256=eGDKX6bGhgVxXBzu81Sk3iiAkXr0GUtgT7bD5Rxlqpg,2028
|
|
10
|
+
pydantic_ai/format_as_xml.py,sha256=QE7eMlg5-YUMw1_2kcI3h0uKYPZZyGkgXFDtfZTMeeI,4480
|
|
11
|
+
pydantic_ai/messages.py,sha256=V6JwFuADF21wKfszqT1CNgiYUeSAuJzjsngD-BJo3Y4,17841
|
|
12
|
+
pydantic_ai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
pydantic_ai/result.py,sha256=uubCdc51fYeZwkGGy1E9x2H9WP8FKoeqNQDaL0vzD1s,18393
|
|
14
|
+
pydantic_ai/settings.py,sha256=Yn4cXoESeJouFktfWqY1o0Exlf6yHfsvf6Uw6iMkuZQ,2278
|
|
15
|
+
pydantic_ai/tools.py,sha256=IrFeIxYQcpRUCrIv9p_4-hqmpjmUNC3dVwvr0gXf-1w,13057
|
|
16
|
+
pydantic_ai/usage.py,sha256=60d9f6M7YEYuKMbqDGDogX4KsA73fhDtWyDXYXoIPaI,4948
|
|
17
|
+
pydantic_ai/models/__init__.py,sha256=-tsz2kKwqvLXhTXk2WvdxB-PoMcaA043sQhkhzM9OFU,11715
|
|
18
|
+
pydantic_ai/models/anthropic.py,sha256=xhTTSq7wniIf4IlTyIAIGSmXpuXUvVOF9I6TRJLfmeo,16645
|
|
19
|
+
pydantic_ai/models/cohere.py,sha256=fGuXNpHUXfhfQ9AyG-Bo-Zet2njuNhjcpELmsCjhsvo,9933
|
|
20
|
+
pydantic_ai/models/function.py,sha256=jv2aw5K4KrMIRPFSTiGbBHcv16UZtGEe_1irjTudLg0,9826
|
|
21
|
+
pydantic_ai/models/gemini.py,sha256=nixBvW4YEtzURAj1qQrVEHKabFN13SUV1QgA1lm_eWo,27595
|
|
22
|
+
pydantic_ai/models/groq.py,sha256=6V_b4Gj63Uask8CfZLO1RjCNdv2FYd8SVjcRtMLMvgo,13355
|
|
23
|
+
pydantic_ai/models/mistral.py,sha256=8kyZiHeAOaZdcJCwFF_xgS_dJkq_e9xwjFOv9IE3YPY,24766
|
|
24
|
+
pydantic_ai/models/ollama.py,sha256=CEgcMW6KliaS7h5Fakx80EmSgm4rDLNjofBOCwM15lM,4288
|
|
25
|
+
pydantic_ai/models/openai.py,sha256=MV7S6hxW6PTOAWNmKBLTZ-e6vkYMByQXT16t4KK54DA,14776
|
|
26
|
+
pydantic_ai/models/test.py,sha256=SKtWqfjc8cb-U2gXJD1U43POxQnHFj_bEx734tCMov0,16328
|
|
27
|
+
pydantic_ai/models/vertexai.py,sha256=bQZ5W8n4521AH3jTiyP1fOYxtNgCgkhjCbBeASv5Ap8,9388
|
|
28
|
+
pydantic_ai_slim-0.0.20.dist-info/METADATA,sha256=3Z-xQLFaAP-JStPOVeiZFwU8ZkIbXzUCkBh8TkLEbuQ,2879
|
|
29
|
+
pydantic_ai_slim-0.0.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
30
|
+
pydantic_ai_slim-0.0.20.dist-info/RECORD,,
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
pydantic_ai/__init__.py,sha256=FbYetEgT6OO25u2KF5ZnFxKpz5DtnSpfckRXP4mjl8E,489
|
|
2
|
-
pydantic_ai/_griffe.py,sha256=RYRKiLbgG97QxnazbAwlnc74XxevGHLQet-FGfq9qls,3960
|
|
3
|
-
pydantic_ai/_parts_manager.py,sha256=pMDZs6BGC8EmaNa-73QvuptmxdG2MhBrBLIydCOl-gM,11886
|
|
4
|
-
pydantic_ai/_pydantic.py,sha256=Zvjd2te6EzPrFnz--oDSdqwZuPw3vCiflTHriRhpNsY,8698
|
|
5
|
-
pydantic_ai/_result.py,sha256=cUSugZQV0n5Z4fFHiMqua-2xs_0S6m-rr-yd6QS3nFE,10317
|
|
6
|
-
pydantic_ai/_system_prompt.py,sha256=Fsl1K6GdQP0WhWBzvJxCc5uTqCD06lHjJlTADah-PI0,1116
|
|
7
|
-
pydantic_ai/_utils.py,sha256=EHW866W6ZpGJLCWtoEAcwIPeWo9OQFhnD5el2DwVcwc,10949
|
|
8
|
-
pydantic_ai/agent.py,sha256=Z_79gw4BIJooBIqJwPbnDHvmBcCXp2dbNd_832tc_do,62500
|
|
9
|
-
pydantic_ai/exceptions.py,sha256=eGDKX6bGhgVxXBzu81Sk3iiAkXr0GUtgT7bD5Rxlqpg,2028
|
|
10
|
-
pydantic_ai/format_as_xml.py,sha256=QE7eMlg5-YUMw1_2kcI3h0uKYPZZyGkgXFDtfZTMeeI,4480
|
|
11
|
-
pydantic_ai/messages.py,sha256=b4RpaXogREquE8WHlGPMm0UGTNx2QtePV5GYk-9EscY,18185
|
|
12
|
-
pydantic_ai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
pydantic_ai/result.py,sha256=93ZLxr2jPx0cZeslHgphJ6XJnQMEybktzQ_LUT47h3Q,17429
|
|
14
|
-
pydantic_ai/settings.py,sha256=oTk8ZfYuUsNxpJMWLvSrO1OH_0ur7VKgDNTMQG0tPyM,1974
|
|
15
|
-
pydantic_ai/tools.py,sha256=iwa2PyhnKmvh_njy4aMfRIh7AP5igDIZ1ZPvgvvn6bM,13018
|
|
16
|
-
pydantic_ai/usage.py,sha256=60d9f6M7YEYuKMbqDGDogX4KsA73fhDtWyDXYXoIPaI,4948
|
|
17
|
-
pydantic_ai/models/__init__.py,sha256=Q4_fHy48szaA_TrIW3LZhRXiDUlhPAYf8LkhinSP3s8,10883
|
|
18
|
-
pydantic_ai/models/anthropic.py,sha256=MkFqy2F7SPb_qAbgzc04iZWmVuoEBgn30v1HY1Wjadc,13543
|
|
19
|
-
pydantic_ai/models/function.py,sha256=iT4XT8VEaJbNwYJAWtrI_jbRAb2tZO6UL93ErR4RYhM,9629
|
|
20
|
-
pydantic_ai/models/gemini.py,sha256=3RTVQBAI1jWL3Xx_hi7qdy_6H-kTeuAOTPELnlVtPp4,27498
|
|
21
|
-
pydantic_ai/models/groq.py,sha256=kzQSFT-04WmQmdRaB6Wj0mxHeAXIgyrryZkptNiA4Ng,13211
|
|
22
|
-
pydantic_ai/models/mistral.py,sha256=qyYOLBpOdI5iPBmQxf5jp1d17sxqa1r8GJ7tb4yE45U,24549
|
|
23
|
-
pydantic_ai/models/ollama.py,sha256=aHI8pNw7fqOOgvlEWcTnTYTmhf0cGg41x-p5sUQr2_k,4200
|
|
24
|
-
pydantic_ai/models/openai.py,sha256=FzV6OCuK4Sr_J2GTuM-6Vu9NbDyZPxllwQPmssdOtbQ,13774
|
|
25
|
-
pydantic_ai/models/test.py,sha256=0m2Pdn0xJMjvAVekVIoADQL0aSkOnGZJct9k4WvImrQ,15880
|
|
26
|
-
pydantic_ai/models/vertexai.py,sha256=dHGrmLMgekWAEOZkLsO5rwDtQ6mjPixvn0umlvWAZok,9323
|
|
27
|
-
pydantic_ai_slim-0.0.19.dist-info/METADATA,sha256=lnGlda0-tCapsWI72DyzGV9Sppm5I7koWbb7-xEpWcU,2808
|
|
28
|
-
pydantic_ai_slim-0.0.19.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
29
|
-
pydantic_ai_slim-0.0.19.dist-info/RECORD,,
|
|
File without changes
|