pydantic-ai-slim 0.0.7__py3-none-any.whl → 0.0.8__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.py +1 -0
- pydantic_ai/messages.py +4 -0
- pydantic_ai/models/gemini.py +4 -0
- pydantic_ai/models/test.py +4 -8
- pydantic_ai/models/vertexai.py +2 -0
- pydantic_ai/result.py +9 -7
- {pydantic_ai_slim-0.0.7.dist-info → pydantic_ai_slim-0.0.8.dist-info}/METADATA +1 -1
- {pydantic_ai_slim-0.0.7.dist-info → pydantic_ai_slim-0.0.8.dist-info}/RECORD +9 -9
- {pydantic_ai_slim-0.0.7.dist-info → pydantic_ai_slim-0.0.8.dist-info}/WHEEL +0 -0
pydantic_ai/agent.py
CHANGED
pydantic_ai/messages.py
CHANGED
|
@@ -139,12 +139,16 @@ class ModelTextResponse:
|
|
|
139
139
|
|
|
140
140
|
@dataclass
|
|
141
141
|
class ArgsJson:
|
|
142
|
+
"""Tool arguments as a JSON string."""
|
|
143
|
+
|
|
142
144
|
args_json: str
|
|
143
145
|
"""A JSON string of arguments."""
|
|
144
146
|
|
|
145
147
|
|
|
146
148
|
@dataclass
|
|
147
149
|
class ArgsDict:
|
|
150
|
+
"""Tool arguments as a Python dictionary."""
|
|
151
|
+
|
|
148
152
|
args_dict: dict[str, Any]
|
|
149
153
|
"""A python dictionary of arguments."""
|
|
150
154
|
|
pydantic_ai/models/gemini.py
CHANGED
|
@@ -109,11 +109,15 @@ class GeminiModel(Model):
|
|
|
109
109
|
|
|
110
110
|
|
|
111
111
|
class AuthProtocol(Protocol):
|
|
112
|
+
"""Abstract definition for Gemini authentication."""
|
|
113
|
+
|
|
112
114
|
async def headers(self) -> dict[str, str]: ...
|
|
113
115
|
|
|
114
116
|
|
|
115
117
|
@dataclass
|
|
116
118
|
class ApiKeyAuth:
|
|
119
|
+
"""Authentication using an API key for the `X-Goog-Api-Key` header."""
|
|
120
|
+
|
|
117
121
|
api_key: str
|
|
118
122
|
|
|
119
123
|
async def headers(self) -> dict[str, str]:
|
pydantic_ai/models/test.py
CHANGED
|
@@ -31,14 +31,6 @@ from . import (
|
|
|
31
31
|
)
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
class UnSetType:
|
|
35
|
-
def __repr__(self):
|
|
36
|
-
return 'UnSet'
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
UnSet = UnSetType()
|
|
40
|
-
|
|
41
|
-
|
|
42
34
|
@dataclass
|
|
43
35
|
class TestModel(Model):
|
|
44
36
|
"""A model specifically for testing purposes.
|
|
@@ -186,6 +178,8 @@ class TestAgentModel(AgentModel):
|
|
|
186
178
|
|
|
187
179
|
@dataclass
|
|
188
180
|
class TestStreamTextResponse(StreamTextResponse):
|
|
181
|
+
"""A text response that streams test data."""
|
|
182
|
+
|
|
189
183
|
_text: str
|
|
190
184
|
_cost: Cost
|
|
191
185
|
_iter: Iterator[str] = field(init=False)
|
|
@@ -217,6 +211,8 @@ class TestStreamTextResponse(StreamTextResponse):
|
|
|
217
211
|
|
|
218
212
|
@dataclass
|
|
219
213
|
class TestStreamStructuredResponse(StreamStructuredResponse):
|
|
214
|
+
"""A structured response that streams test data."""
|
|
215
|
+
|
|
220
216
|
_structured_response: ModelStructuredResponse
|
|
221
217
|
_cost: Cost
|
|
222
218
|
_iter: Iterator[None] = field(default_factory=lambda: iter([None]))
|
pydantic_ai/models/vertexai.py
CHANGED
|
@@ -182,6 +182,8 @@ MAX_TOKEN_AGE = timedelta(seconds=3000)
|
|
|
182
182
|
|
|
183
183
|
@dataclass
|
|
184
184
|
class BearerTokenAuth:
|
|
185
|
+
"""Authentication using a bearer token generated by google-auth."""
|
|
186
|
+
|
|
185
187
|
credentials: BaseCredentials | ServiceAccountCredentials
|
|
186
188
|
token_created: datetime | None = field(default=None, init=False)
|
|
187
189
|
|
pydantic_ai/result.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations as _annotations
|
|
2
2
|
|
|
3
3
|
from abc import ABC, abstractmethod
|
|
4
|
-
from collections.abc import AsyncIterator
|
|
5
|
-
from dataclasses import dataclass
|
|
4
|
+
from collections.abc import AsyncIterator, Callable
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
6
|
from datetime import datetime
|
|
7
7
|
from typing import Generic, TypeVar, cast
|
|
8
8
|
|
|
@@ -49,11 +49,11 @@ class Cost:
|
|
|
49
49
|
This is provided so it's trivial to sum costs from multiple requests and runs.
|
|
50
50
|
"""
|
|
51
51
|
counts: dict[str, int] = {}
|
|
52
|
-
for
|
|
53
|
-
self_value = getattr(self,
|
|
54
|
-
other_value = getattr(other,
|
|
52
|
+
for f in 'request_tokens', 'response_tokens', 'total_tokens':
|
|
53
|
+
self_value = getattr(self, f)
|
|
54
|
+
other_value = getattr(other, f)
|
|
55
55
|
if self_value is not None or other_value is not None:
|
|
56
|
-
counts[
|
|
56
|
+
counts[f] = (self_value or 0) + (other_value or 0)
|
|
57
57
|
|
|
58
58
|
details = self.details.copy() if self.details is not None else None
|
|
59
59
|
if other.details is not None:
|
|
@@ -122,7 +122,8 @@ class StreamedRunResult(_BaseRunResult[ResultData], Generic[AgentDeps, ResultDat
|
|
|
122
122
|
_result_schema: _result.ResultSchema[ResultData] | None
|
|
123
123
|
_deps: AgentDeps
|
|
124
124
|
_result_validators: list[_result.ResultValidator[AgentDeps, ResultData]]
|
|
125
|
-
|
|
125
|
+
_on_complete: Callable[[list[messages.Message]], None]
|
|
126
|
+
is_complete: bool = field(default=False, init=False)
|
|
126
127
|
"""Whether the stream has all been received.
|
|
127
128
|
|
|
128
129
|
This is set to `True` when one of
|
|
@@ -312,3 +313,4 @@ class StreamedRunResult(_BaseRunResult[ResultData], Generic[AgentDeps, ResultDat
|
|
|
312
313
|
else:
|
|
313
314
|
assert structured_message is not None, 'Either text or structured_message should provided, not both'
|
|
314
315
|
self._all_messages.append(structured_message)
|
|
316
|
+
self._on_complete(self._all_messages)
|
|
@@ -5,19 +5,19 @@ pydantic_ai/_result.py,sha256=cAqfPipK39cz-p-ftlJ83Q5_LI1TRb3-HH-iivb5rEM,9674
|
|
|
5
5
|
pydantic_ai/_system_prompt.py,sha256=63egOej8zHsDVOInPayn0EEEDXKd0HVAbbrqXUTV96s,1092
|
|
6
6
|
pydantic_ai/_tool.py,sha256=5Q9XaGOEXbyOLS644osB1AA5EMoJkr4eYK60MVZo0Z8,4528
|
|
7
7
|
pydantic_ai/_utils.py,sha256=eNb7f3-ZQC8WDEa87iUcXGQ-lyuutFQG-5yBCMD4Vvs,8227
|
|
8
|
-
pydantic_ai/agent.py,sha256=
|
|
8
|
+
pydantic_ai/agent.py,sha256=r5DI4ZBqYE67GOMEEu-LXrTa5ty2AchW4szotwm5Qis,34338
|
|
9
9
|
pydantic_ai/dependencies.py,sha256=EHvD68AFkItxMnfHzJLG7T_AD1RGI2MZOfzm1v89hGQ,2399
|
|
10
10
|
pydantic_ai/exceptions.py,sha256=ko_47M0k6Rhg9mUC9P1cj7N4LCH6cC0pEsF65A2vL-U,1561
|
|
11
|
-
pydantic_ai/messages.py,sha256=
|
|
11
|
+
pydantic_ai/messages.py,sha256=FFTQ9Bo2Ct4bLuyJF-M9xkeraw05I--NC_ieR6oGtTM,7587
|
|
12
12
|
pydantic_ai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
pydantic_ai/result.py,sha256=
|
|
13
|
+
pydantic_ai/result.py,sha256=qsanb7v4qJ4pJdkdsqpy68kuZ1WNCpQB5jcXeTwGpe0,13658
|
|
14
14
|
pydantic_ai/models/__init__.py,sha256=Cx8PjEsi5gkNOVQic32sf4CmM-A3pRu1LcjpM6poiBI,10138
|
|
15
15
|
pydantic_ai/models/function.py,sha256=Mzc-zXnb2RayWAA8N9NS7KGF49do1S-VW3U9fkc661o,10045
|
|
16
|
-
pydantic_ai/models/gemini.py,sha256=
|
|
16
|
+
pydantic_ai/models/gemini.py,sha256=ruO4tnnpDDuHThg7jUOphs8I_KXBJH7gfDMluliED8E,26606
|
|
17
17
|
pydantic_ai/models/groq.py,sha256=Tx2yU3ysmPLBmWGsjzES-XcumzrsoBtB7spCnJBlLiM,14947
|
|
18
18
|
pydantic_ai/models/openai.py,sha256=5ihH25CrS0tnZNW-BZw4GyPe8V-IxIHWw3B9ulPVjQE,14931
|
|
19
|
-
pydantic_ai/models/test.py,sha256=
|
|
20
|
-
pydantic_ai/models/vertexai.py,sha256=
|
|
21
|
-
pydantic_ai_slim-0.0.
|
|
22
|
-
pydantic_ai_slim-0.0.
|
|
23
|
-
pydantic_ai_slim-0.0.
|
|
19
|
+
pydantic_ai/models/test.py,sha256=q1wch_E7TSb4qx9PCcP1YyBGZx567MGlAQhlAlON0S8,14463
|
|
20
|
+
pydantic_ai/models/vertexai.py,sha256=5wI8y2YjeRgSE51uKy5OtevQkks65uEbxIUAs5EGBaI,9161
|
|
21
|
+
pydantic_ai_slim-0.0.8.dist-info/METADATA,sha256=CmpvlEAUyaWaPbdRCbFuypVLJ8yNC3TwZ0jgvlR9yps,2561
|
|
22
|
+
pydantic_ai_slim-0.0.8.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
23
|
+
pydantic_ai_slim-0.0.8.dist-info/RECORD,,
|
|
File without changes
|