pydantic-ai-slim 0.0.31__py3-none-any.whl → 0.0.33__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/_agent_graph.py +39 -38
- pydantic_ai/_pydantic.py +4 -4
- pydantic_ai/_result.py +7 -18
- pydantic_ai/agent.py +24 -21
- pydantic_ai/models/__init__.py +40 -36
- pydantic_ai/models/anthropic.py +3 -1
- pydantic_ai/models/gemini.py +52 -14
- pydantic_ai/models/instrumented.py +25 -27
- pydantic_ai/models/openai.py +56 -15
- pydantic_ai/models/vertexai.py +9 -1
- pydantic_ai/providers/__init__.py +64 -0
- pydantic_ai/providers/deepseek.py +68 -0
- pydantic_ai/providers/google_gla.py +44 -0
- pydantic_ai/providers/google_vertex.py +200 -0
- pydantic_ai/providers/openai.py +72 -0
- pydantic_ai/result.py +19 -27
- {pydantic_ai_slim-0.0.31.dist-info → pydantic_ai_slim-0.0.33.dist-info}/METADATA +4 -4
- {pydantic_ai_slim-0.0.31.dist-info → pydantic_ai_slim-0.0.33.dist-info}/RECORD +19 -14
- {pydantic_ai_slim-0.0.31.dist-info → pydantic_ai_slim-0.0.33.dist-info}/WHEEL +0 -0
pydantic_ai/result.py
CHANGED
|
@@ -6,7 +6,6 @@ from dataclasses import dataclass, field
|
|
|
6
6
|
from datetime import datetime
|
|
7
7
|
from typing import Generic, Union, cast
|
|
8
8
|
|
|
9
|
-
import logfire_api
|
|
10
9
|
from typing_extensions import TypeVar, assert_type
|
|
11
10
|
|
|
12
11
|
from . import _result, _utils, exceptions, messages as _messages, models
|
|
@@ -49,8 +48,6 @@ A function that always takes and returns the same type of data (which is the res
|
|
|
49
48
|
Usage `ResultValidatorFunc[AgentDepsT, T]`.
|
|
50
49
|
"""
|
|
51
50
|
|
|
52
|
-
_logfire = logfire_api.Logfire(otel_scope='pydantic-ai')
|
|
53
|
-
|
|
54
51
|
|
|
55
52
|
@dataclass
|
|
56
53
|
class AgentStream(Generic[AgentDepsT, ResultDataT]):
|
|
@@ -302,17 +299,14 @@ class StreamedRunResult(Generic[AgentDepsT, ResultDataT]):
|
|
|
302
299
|
if self._result_schema and not self._result_schema.allow_text_result:
|
|
303
300
|
raise exceptions.UserError('stream_text() can only be used with text responses')
|
|
304
301
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
combined_validated_text =
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
yield combined_validated_text
|
|
314
|
-
lf_span.set_attribute('combined_text', combined_validated_text)
|
|
315
|
-
await self._marked_completed(self._stream_response.get())
|
|
302
|
+
if delta:
|
|
303
|
+
async for text in self._stream_response_text(delta=delta, debounce_by=debounce_by):
|
|
304
|
+
yield text
|
|
305
|
+
else:
|
|
306
|
+
async for text in self._stream_response_text(delta=delta, debounce_by=debounce_by):
|
|
307
|
+
combined_validated_text = await self._validate_text_result(text)
|
|
308
|
+
yield combined_validated_text
|
|
309
|
+
await self._marked_completed(self._stream_response.get())
|
|
316
310
|
|
|
317
311
|
async def stream_structured(
|
|
318
312
|
self, *, debounce_by: float | None = 0.1
|
|
@@ -327,22 +321,20 @@ class StreamedRunResult(Generic[AgentDepsT, ResultDataT]):
|
|
|
327
321
|
Returns:
|
|
328
322
|
An async iterable of the structured response message and whether that is the last message.
|
|
329
323
|
"""
|
|
330
|
-
with
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if part.has_content():
|
|
335
|
-
yield msg, False
|
|
336
|
-
break
|
|
337
|
-
|
|
338
|
-
async for msg in self._stream_response_structured(debounce_by=debounce_by):
|
|
324
|
+
# if the message currently has any parts with content, yield before streaming
|
|
325
|
+
msg = self._stream_response.get()
|
|
326
|
+
for part in msg.parts:
|
|
327
|
+
if part.has_content():
|
|
339
328
|
yield msg, False
|
|
329
|
+
break
|
|
340
330
|
|
|
341
|
-
|
|
342
|
-
yield msg,
|
|
331
|
+
async for msg in self._stream_response_structured(debounce_by=debounce_by):
|
|
332
|
+
yield msg, False
|
|
333
|
+
|
|
334
|
+
msg = self._stream_response.get()
|
|
335
|
+
yield msg, True
|
|
343
336
|
|
|
344
|
-
|
|
345
|
-
await self._marked_completed(msg)
|
|
337
|
+
await self._marked_completed(msg)
|
|
346
338
|
|
|
347
339
|
async def get_data(self) -> ResultDataT:
|
|
348
340
|
"""Stream the whole response, validate and return it."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pydantic-ai-slim
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.33
|
|
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
|
|
@@ -28,12 +28,12 @@ Requires-Dist: eval-type-backport>=0.2.0
|
|
|
28
28
|
Requires-Dist: exceptiongroup; python_version < '3.11'
|
|
29
29
|
Requires-Dist: griffe>=1.3.2
|
|
30
30
|
Requires-Dist: httpx>=0.27
|
|
31
|
-
Requires-Dist: logfire-api>=1.2.0
|
|
32
31
|
Requires-Dist: opentelemetry-api>=1.28.0
|
|
33
|
-
Requires-Dist: pydantic-graph==0.0.
|
|
32
|
+
Requires-Dist: pydantic-graph==0.0.33
|
|
34
33
|
Requires-Dist: pydantic>=2.10
|
|
34
|
+
Requires-Dist: typing-inspection>=0.4.0
|
|
35
35
|
Provides-Extra: anthropic
|
|
36
|
-
Requires-Dist: anthropic>=0.
|
|
36
|
+
Requires-Dist: anthropic>=0.49.0; extra == 'anthropic'
|
|
37
37
|
Provides-Extra: cohere
|
|
38
38
|
Requires-Dist: cohere>=5.13.11; extra == 'cohere'
|
|
39
39
|
Provides-Extra: duckduckgo
|
|
@@ -1,36 +1,41 @@
|
|
|
1
1
|
pydantic_ai/__init__.py,sha256=xrSDxkBwpUVInbPtTVhReEecStk-mWZMttAPUAQR0Ic,927
|
|
2
|
-
pydantic_ai/_agent_graph.py,sha256=
|
|
2
|
+
pydantic_ai/_agent_graph.py,sha256=wbhm3_5VNpx_Oy1_sQ_6b2hkaFjd9vd1v9g3Rw_8sJY,30127
|
|
3
3
|
pydantic_ai/_griffe.py,sha256=RYRKiLbgG97QxnazbAwlnc74XxevGHLQet-FGfq9qls,3960
|
|
4
4
|
pydantic_ai/_parts_manager.py,sha256=ARfDQY1_5AIY5rNl_M2fAYHEFCe03ZxdhgjHf9qeIKw,11872
|
|
5
|
-
pydantic_ai/_pydantic.py,sha256=
|
|
6
|
-
pydantic_ai/_result.py,sha256=
|
|
5
|
+
pydantic_ai/_pydantic.py,sha256=SxI7HBLzAATlO-_UP4eEuKItkxrkYYToBQMIDdLvwI4,8808
|
|
6
|
+
pydantic_ai/_result.py,sha256=SlxqR-AKWzDoc7cRRN2jmIZ7pCv3DKzaP-dnZW-e7us,10117
|
|
7
7
|
pydantic_ai/_system_prompt.py,sha256=602c2jyle2R_SesOrITBDETZqsLk4BZ8Cbo8yEhmx04,1120
|
|
8
8
|
pydantic_ai/_utils.py,sha256=nx4Suswk2qjLvzphx8uQntKzFi-IzvhX_H1L7t_kJlQ,9579
|
|
9
|
-
pydantic_ai/agent.py,sha256=
|
|
9
|
+
pydantic_ai/agent.py,sha256=zqzFPvRvgb0iPCwRK2IhyTPJfbGjVMxCrQq9uDw9RM4,65873
|
|
10
10
|
pydantic_ai/exceptions.py,sha256=1ujJeB3jDDQ-pH5ydBYrgStvR35-GlEW0bYGTGEr4ME,3127
|
|
11
11
|
pydantic_ai/format_as_xml.py,sha256=QE7eMlg5-YUMw1_2kcI3h0uKYPZZyGkgXFDtfZTMeeI,4480
|
|
12
12
|
pydantic_ai/messages.py,sha256=Yny2hIuExXfw9fvHDSPgbvfN91IOdcLaDEAmaCAoTBs,23751
|
|
13
13
|
pydantic_ai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
pydantic_ai/result.py,sha256=
|
|
14
|
+
pydantic_ai/result.py,sha256=LXKxRzy_rGMkdZ8xJ7yknPP3wGZtGNeZl-gh5opXbaQ,22542
|
|
15
15
|
pydantic_ai/settings.py,sha256=ntuWnke9UA18aByDxk9OIhN0tAgOaPdqCEkRf-wlp8Y,3059
|
|
16
16
|
pydantic_ai/tools.py,sha256=IPZuZJCSQUppz1uyLVwpfFLGoMirB8YtKWXIDQGR444,13414
|
|
17
17
|
pydantic_ai/usage.py,sha256=VmpU_o_RjFI65J81G1wfCwDIAYBclMjeWfLtslntFOw,5406
|
|
18
18
|
pydantic_ai/common_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
19
|
pydantic_ai/common_tools/duckduckgo.py,sha256=-kSa1gGn5-NIYvtxFWrFcX2XdmfEmGxI3_wAqrb6jLI,2230
|
|
20
20
|
pydantic_ai/common_tools/tavily.py,sha256=Lz35037ggkdWKa_Stj0yXBkiN_hygDefEevoRDUclF0,2560
|
|
21
|
-
pydantic_ai/models/__init__.py,sha256=
|
|
22
|
-
pydantic_ai/models/anthropic.py,sha256=
|
|
21
|
+
pydantic_ai/models/__init__.py,sha256=m1TWcmpTKn7hKDqlBNaIt2shUlhFqrVxtFOluhlp0B0,13894
|
|
22
|
+
pydantic_ai/models/anthropic.py,sha256=DxoaSSo-HZYJSqbOAR2p7gsW6kUXY-SV6aA1j-8gy6c,20679
|
|
23
23
|
pydantic_ai/models/cohere.py,sha256=6F6eWPGVT7mpMXlRugbVbR-a8Q1zmb1SKS_fWOoBL80,11514
|
|
24
24
|
pydantic_ai/models/fallback.py,sha256=smHwNIpxu19JsgYYjY0nmzl3yox7yQRJ0Ir08zdhnk0,4207
|
|
25
25
|
pydantic_ai/models/function.py,sha256=THIwVJ8qI3efYLNlYXlYze_J8hc7MHB-NMb3kpknq0g,11373
|
|
26
|
-
pydantic_ai/models/gemini.py,sha256=
|
|
26
|
+
pydantic_ai/models/gemini.py,sha256=r7PG7dMruGNmqFRWVFYLmxhICw2oAYfdB9Q1qLoSf8U,35804
|
|
27
27
|
pydantic_ai/models/groq.py,sha256=Z4sZJDu5Yxa2tZiAPp9EjSVMz4uwLhS3fW7kFSc09gI,16406
|
|
28
|
-
pydantic_ai/models/instrumented.py,sha256=
|
|
28
|
+
pydantic_ai/models/instrumented.py,sha256=7LXQgMtKyU3VQ1ReC7QdYFms01gAivJbPEJXij6HPYE,8196
|
|
29
29
|
pydantic_ai/models/mistral.py,sha256=ZJ4xPcL9wJIQ5io34yP2fPyXy8GZrSvsW4itZiKPYFw,27448
|
|
30
|
-
pydantic_ai/models/openai.py,sha256=
|
|
30
|
+
pydantic_ai/models/openai.py,sha256=NpRFXO-Wc0VVmTY9OHyfl8Qelc_ecxcmRIn6F00CH0Y,21595
|
|
31
31
|
pydantic_ai/models/test.py,sha256=Ux20cmuJFkhvI9L1N7ItHNFcd-j284TBEsrM53eWRag,16873
|
|
32
|
-
pydantic_ai/models/vertexai.py,sha256=
|
|
32
|
+
pydantic_ai/models/vertexai.py,sha256=KbbLC1wdMqlKTh4Ot07Q4ejy-nfl_ZFI8WAST5j1dBk,9869
|
|
33
33
|
pydantic_ai/models/wrapper.py,sha256=Zr3fgiUBpt2N9gXds6iSwaMEtEsFKr9WwhpHjSoHa7o,1410
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
pydantic_ai/providers/__init__.py,sha256=tiH0iwFUjOlYuFQqK2L1coAPgCRlFU_NuLlbJiy_kNg,1819
|
|
35
|
+
pydantic_ai/providers/deepseek.py,sha256=KDNvVXjB8cuRTw_xEM1JYLKig9V5YdvGFPm-dcf0kdc,2065
|
|
36
|
+
pydantic_ai/providers/google_gla.py,sha256=sfJXkuGW17nI-P40glnO8DaL_mrpL4uafgoH8xPvcEY,1539
|
|
37
|
+
pydantic_ai/providers/google_vertex.py,sha256=F2vVukvXeeujgDnbCQnnDQg_3pDFHsyufTGzjJkYvus,7329
|
|
38
|
+
pydantic_ai/providers/openai.py,sha256=wa6_UXtpOCc_XWuyru3Bf1QH44JGXsM3sIOhUa5Y6qs,2893
|
|
39
|
+
pydantic_ai_slim-0.0.33.dist-info/METADATA,sha256=xbzvFSjYDCcjSrXwFjLcrIu3VE_ZsSvJ9EN17S7YoT4,3109
|
|
40
|
+
pydantic_ai_slim-0.0.33.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
41
|
+
pydantic_ai_slim-0.0.33.dist-info/RECORD,,
|
|
File without changes
|