pydantic-ai-slim 0.3.7__tar.gz → 0.4.0__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.3.7 → pydantic_ai_slim-0.4.0}/PKG-INFO +4 -4
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/_function_schema.py +1 -1
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/_griffe.py +2 -2
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/_utils.py +4 -1
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/mcp.py +1 -1
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/messages.py +22 -6
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/models/anthropic.py +1 -1
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/models/bedrock.py +9 -6
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/models/gemini.py +1 -1
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/models/google.py +1 -1
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/models/groq.py +1 -1
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/models/mistral.py +3 -1
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/models/openai.py +1 -1
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/profiles/openai.py +9 -1
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/tools.py +5 -5
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/.gitignore +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/LICENSE +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/README.md +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/__init__.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/__main__.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/_a2a.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/_agent_graph.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/_cli.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/_mcp.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/_output.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/_parts_manager.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/_run_context.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/_system_prompt.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/_thinking_part.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/agent.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/common_tools/__init__.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/common_tools/duckduckgo.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/common_tools/tavily.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/direct.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/exceptions.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/ext/__init__.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/ext/aci.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/ext/langchain.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/format_as_xml.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/format_prompt.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/models/__init__.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/models/cohere.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/models/fallback.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/models/function.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/models/instrumented.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/models/mcp_sampling.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/models/test.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/models/wrapper.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/output.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/profiles/__init__.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/profiles/_json_schema.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/profiles/amazon.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/profiles/anthropic.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/profiles/cohere.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/profiles/deepseek.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/profiles/google.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/profiles/grok.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/profiles/meta.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/profiles/mistral.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/profiles/qwen.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/__init__.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/anthropic.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/azure.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/bedrock.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/cohere.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/deepseek.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/fireworks.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/github.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/google.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/google_gla.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/google_vertex.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/grok.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/groq.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/heroku.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/mistral.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/openai.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/openrouter.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/providers/together.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/py.typed +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/result.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/settings.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pydantic_ai/usage.py +0 -0
- {pydantic_ai_slim-0.3.7 → pydantic_ai_slim-0.4.0}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pydantic-ai-slim
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Agent Framework / shim to use Pydantic with LLMs, slim package
|
|
5
5
|
Author-email: Samuel Colvin <samuel@pydantic.dev>, Marcelo Trylesinski <marcelotryle@gmail.com>, David Montague <david@pydantic.dev>, Alex Hall <alex@pydantic.dev>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -30,11 +30,11 @@ Requires-Dist: exceptiongroup; python_version < '3.11'
|
|
|
30
30
|
Requires-Dist: griffe>=1.3.2
|
|
31
31
|
Requires-Dist: httpx>=0.27
|
|
32
32
|
Requires-Dist: opentelemetry-api>=1.28.0
|
|
33
|
-
Requires-Dist: pydantic-graph==0.
|
|
33
|
+
Requires-Dist: pydantic-graph==0.4.0
|
|
34
34
|
Requires-Dist: pydantic>=2.10
|
|
35
35
|
Requires-Dist: typing-inspection>=0.4.0
|
|
36
36
|
Provides-Extra: a2a
|
|
37
|
-
Requires-Dist: fasta2a==0.
|
|
37
|
+
Requires-Dist: fasta2a==0.4.0; extra == 'a2a'
|
|
38
38
|
Provides-Extra: anthropic
|
|
39
39
|
Requires-Dist: anthropic>=0.52.0; extra == 'anthropic'
|
|
40
40
|
Provides-Extra: bedrock
|
|
@@ -48,7 +48,7 @@ Requires-Dist: cohere>=5.13.11; (platform_system != 'Emscripten') and extra == '
|
|
|
48
48
|
Provides-Extra: duckduckgo
|
|
49
49
|
Requires-Dist: duckduckgo-search>=7.0.0; extra == 'duckduckgo'
|
|
50
50
|
Provides-Extra: evals
|
|
51
|
-
Requires-Dist: pydantic-evals==0.
|
|
51
|
+
Requires-Dist: pydantic-evals==0.4.0; extra == 'evals'
|
|
52
52
|
Provides-Extra: google
|
|
53
53
|
Requires-Dist: google-genai>=1.24.0; extra == 'google'
|
|
54
54
|
Provides-Extra: groq
|
|
@@ -35,7 +35,7 @@ class FunctionSchema:
|
|
|
35
35
|
"""Internal information about a function schema."""
|
|
36
36
|
|
|
37
37
|
function: Callable[..., Any]
|
|
38
|
-
description: str
|
|
38
|
+
description: str | None
|
|
39
39
|
validator: SchemaValidator
|
|
40
40
|
json_schema: ObjectJsonSchema
|
|
41
41
|
# if not None, the function takes a single by that name (besides potentially `info`)
|
|
@@ -19,7 +19,7 @@ def doc_descriptions(
|
|
|
19
19
|
sig: Signature,
|
|
20
20
|
*,
|
|
21
21
|
docstring_format: DocstringFormat,
|
|
22
|
-
) -> tuple[str, dict[str, str]]:
|
|
22
|
+
) -> tuple[str | None, dict[str, str]]:
|
|
23
23
|
"""Extract the function description and parameter descriptions from a function's docstring.
|
|
24
24
|
|
|
25
25
|
The function parses the docstring using the specified format (or infers it if 'auto')
|
|
@@ -35,7 +35,7 @@ def doc_descriptions(
|
|
|
35
35
|
"""
|
|
36
36
|
doc = func.__doc__
|
|
37
37
|
if doc is None:
|
|
38
|
-
return
|
|
38
|
+
return None, {}
|
|
39
39
|
|
|
40
40
|
# see https://github.com/mkdocstrings/griffe/issues/293
|
|
41
41
|
parent = cast(GriffeObject, sig)
|
|
@@ -315,8 +315,11 @@ def dataclasses_no_defaults_repr(self: Any) -> str:
|
|
|
315
315
|
return f'{self.__class__.__qualname__}({", ".join(kv_pairs)})'
|
|
316
316
|
|
|
317
317
|
|
|
318
|
+
_datetime_ta = TypeAdapter(datetime)
|
|
319
|
+
|
|
320
|
+
|
|
318
321
|
def number_to_datetime(x: int | float) -> datetime:
|
|
319
|
-
return
|
|
322
|
+
return _datetime_ta.validate_python(x)
|
|
320
323
|
|
|
321
324
|
|
|
322
325
|
AwaitableCallable = Callable[..., Awaitable[T]]
|
|
@@ -98,7 +98,7 @@ class MCPServer(ABC):
|
|
|
98
98
|
return [
|
|
99
99
|
tools.ToolDefinition(
|
|
100
100
|
name=self.get_prefixed_tool_name(tool.name),
|
|
101
|
-
description=tool.description
|
|
101
|
+
description=tool.description,
|
|
102
102
|
parameters_json_schema=tool.inputSchema,
|
|
103
103
|
)
|
|
104
104
|
for tool in mcp_tools.tools
|
|
@@ -25,7 +25,7 @@ if TYPE_CHECKING:
|
|
|
25
25
|
from .models.instrumented import InstrumentationSettings
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
AudioMediaType: TypeAlias = Literal['audio/wav', 'audio/mpeg']
|
|
28
|
+
AudioMediaType: TypeAlias = Literal['audio/wav', 'audio/mpeg', 'audio/ogg', 'audio/flac', 'audio/aiff', 'audio/aac']
|
|
29
29
|
ImageMediaType: TypeAlias = Literal['image/jpeg', 'image/png', 'image/gif', 'image/webp']
|
|
30
30
|
DocumentMediaType: TypeAlias = Literal[
|
|
31
31
|
'application/pdf',
|
|
@@ -48,7 +48,7 @@ VideoMediaType: TypeAlias = Literal[
|
|
|
48
48
|
'video/3gpp',
|
|
49
49
|
]
|
|
50
50
|
|
|
51
|
-
AudioFormat: TypeAlias = Literal['wav', 'mp3']
|
|
51
|
+
AudioFormat: TypeAlias = Literal['wav', 'mp3', 'oga', 'flac', 'aiff', 'aac']
|
|
52
52
|
ImageFormat: TypeAlias = Literal['jpeg', 'png', 'gif', 'webp']
|
|
53
53
|
DocumentFormat: TypeAlias = Literal['csv', 'doc', 'docx', 'html', 'md', 'pdf', 'txt', 'xls', 'xlsx']
|
|
54
54
|
VideoFormat: TypeAlias = Literal['mkv', 'mov', 'mp4', 'webm', 'flv', 'mpeg', 'mpg', 'wmv', 'three_gp']
|
|
@@ -182,13 +182,25 @@ class AudioUrl(FileUrl):
|
|
|
182
182
|
|
|
183
183
|
@property
|
|
184
184
|
def media_type(self) -> AudioMediaType:
|
|
185
|
-
"""Return the media type of the audio file, based on the url.
|
|
185
|
+
"""Return the media type of the audio file, based on the url.
|
|
186
|
+
|
|
187
|
+
References:
|
|
188
|
+
- Gemini: https://ai.google.dev/gemini-api/docs/audio#supported-formats
|
|
189
|
+
"""
|
|
186
190
|
if self.url.endswith('.mp3'):
|
|
187
191
|
return 'audio/mpeg'
|
|
188
|
-
|
|
192
|
+
if self.url.endswith('.wav'):
|
|
189
193
|
return 'audio/wav'
|
|
190
|
-
|
|
191
|
-
|
|
194
|
+
if self.url.endswith('.flac'):
|
|
195
|
+
return 'audio/flac'
|
|
196
|
+
if self.url.endswith('.oga'):
|
|
197
|
+
return 'audio/ogg'
|
|
198
|
+
if self.url.endswith('.aiff'):
|
|
199
|
+
return 'audio/aiff'
|
|
200
|
+
if self.url.endswith('.aac'):
|
|
201
|
+
return 'audio/aac'
|
|
202
|
+
|
|
203
|
+
raise ValueError(f'Unknown audio file extension: {self.url}')
|
|
192
204
|
|
|
193
205
|
@property
|
|
194
206
|
def format(self) -> AudioFormat:
|
|
@@ -358,6 +370,10 @@ _document_format_lookup: dict[str, DocumentFormat] = {
|
|
|
358
370
|
_audio_format_lookup: dict[str, AudioFormat] = {
|
|
359
371
|
'audio/mpeg': 'mp3',
|
|
360
372
|
'audio/wav': 'wav',
|
|
373
|
+
'audio/flac': 'flac',
|
|
374
|
+
'audio/ogg': 'oga',
|
|
375
|
+
'audio/aiff': 'aiff',
|
|
376
|
+
'audio/aac': 'aac',
|
|
361
377
|
}
|
|
362
378
|
_image_format_lookup: dict[str, ImageFormat] = {
|
|
363
379
|
'image/jpeg': 'jpeg',
|
|
@@ -416,7 +416,7 @@ class AnthropicModel(Model):
|
|
|
416
416
|
def _map_tool_definition(f: ToolDefinition) -> BetaToolParam:
|
|
417
417
|
return {
|
|
418
418
|
'name': f.name,
|
|
419
|
-
'description': f.description,
|
|
419
|
+
'description': f.description or '',
|
|
420
420
|
'input_schema': f.parameters_json_schema,
|
|
421
421
|
}
|
|
422
422
|
|
|
@@ -62,6 +62,7 @@ if TYPE_CHECKING:
|
|
|
62
62
|
SystemContentBlockTypeDef,
|
|
63
63
|
ToolChoiceTypeDef,
|
|
64
64
|
ToolConfigurationTypeDef,
|
|
65
|
+
ToolSpecificationTypeDef,
|
|
65
66
|
ToolTypeDef,
|
|
66
67
|
VideoBlockTypeDef,
|
|
67
68
|
)
|
|
@@ -228,14 +229,16 @@ class BedrockConverseModel(Model):
|
|
|
228
229
|
|
|
229
230
|
@staticmethod
|
|
230
231
|
def _map_tool_definition(f: ToolDefinition) -> ToolTypeDef:
|
|
231
|
-
|
|
232
|
-
'
|
|
233
|
-
|
|
234
|
-
'description': f.description,
|
|
235
|
-
'inputSchema': {'json': f.parameters_json_schema},
|
|
236
|
-
}
|
|
232
|
+
tool_spec: ToolSpecificationTypeDef = {
|
|
233
|
+
'name': f.name,
|
|
234
|
+
'inputSchema': {'json': f.parameters_json_schema},
|
|
237
235
|
}
|
|
238
236
|
|
|
237
|
+
if f.description: # pragma: no branch
|
|
238
|
+
tool_spec['description'] = f.description
|
|
239
|
+
|
|
240
|
+
return {'toolSpec': tool_spec}
|
|
241
|
+
|
|
239
242
|
@property
|
|
240
243
|
def base_url(self) -> str:
|
|
241
244
|
return str(self.client.meta.endpoint_url)
|
|
@@ -773,7 +773,7 @@ class _GeminiFunction(TypedDict):
|
|
|
773
773
|
|
|
774
774
|
def _function_from_abstract_tool(tool: ToolDefinition) -> _GeminiFunction:
|
|
775
775
|
json_schema = tool.parameters_json_schema
|
|
776
|
-
f = _GeminiFunction(name=tool.name, description=tool.description, parameters=json_schema)
|
|
776
|
+
f = _GeminiFunction(name=tool.name, description=tool.description or '', parameters=json_schema)
|
|
777
777
|
return f
|
|
778
778
|
|
|
779
779
|
|
|
@@ -534,7 +534,7 @@ def _function_declaration_from_tool(tool: ToolDefinition) -> FunctionDeclaration
|
|
|
534
534
|
json_schema = tool.parameters_json_schema
|
|
535
535
|
f = FunctionDeclarationDict(
|
|
536
536
|
name=tool.name,
|
|
537
|
-
description=tool.description,
|
|
537
|
+
description=tool.description or '',
|
|
538
538
|
parameters=json_schema, # type: ignore
|
|
539
539
|
)
|
|
540
540
|
return f
|
|
@@ -306,7 +306,9 @@ class MistralModel(Model):
|
|
|
306
306
|
)
|
|
307
307
|
tools = [
|
|
308
308
|
MistralTool(
|
|
309
|
-
function=MistralFunction(
|
|
309
|
+
function=MistralFunction(
|
|
310
|
+
name=r.name, parameters=r.parameters_json_schema, description=r.description or ''
|
|
311
|
+
)
|
|
310
312
|
)
|
|
311
313
|
for r in all_tools
|
|
312
314
|
]
|
|
@@ -93,10 +93,18 @@ class OpenAIJsonSchemaTransformer(JsonSchemaTransformer):
|
|
|
93
93
|
def transform(self, schema: JsonSchema) -> JsonSchema: # noqa C901
|
|
94
94
|
# Remove unnecessary keys
|
|
95
95
|
schema.pop('title', None)
|
|
96
|
-
schema.pop('default', None)
|
|
97
96
|
schema.pop('$schema', None)
|
|
98
97
|
schema.pop('discriminator', None)
|
|
99
98
|
|
|
99
|
+
default = schema.get('default', _sentinel)
|
|
100
|
+
if default is not _sentinel:
|
|
101
|
+
# the "default" keyword is not allowed in strict mode, but including it makes some Ollama models behave
|
|
102
|
+
# better, so we keep it around when not strict
|
|
103
|
+
if self.strict is True:
|
|
104
|
+
schema.pop('default', None)
|
|
105
|
+
elif self.strict is None: # pragma: no branch
|
|
106
|
+
self.is_strict_compatible = False
|
|
107
|
+
|
|
100
108
|
if schema_ref := schema.get('$ref'):
|
|
101
109
|
if schema_ref == self.root_ref:
|
|
102
110
|
schema['$ref'] = '#'
|
|
@@ -161,7 +161,7 @@ class Tool(Generic[AgentDepsT]):
|
|
|
161
161
|
takes_ctx: bool
|
|
162
162
|
max_retries: int | None
|
|
163
163
|
name: str
|
|
164
|
-
description: str
|
|
164
|
+
description: str | None
|
|
165
165
|
prepare: ToolPrepareFunc[AgentDepsT] | None
|
|
166
166
|
docstring_format: DocstringFormat
|
|
167
167
|
require_parameter_descriptions: bool
|
|
@@ -269,7 +269,7 @@ class Tool(Generic[AgentDepsT]):
|
|
|
269
269
|
cls,
|
|
270
270
|
function: Callable[..., Any],
|
|
271
271
|
name: str,
|
|
272
|
-
description: str,
|
|
272
|
+
description: str | None,
|
|
273
273
|
json_schema: JsonSchemaValue,
|
|
274
274
|
) -> Self:
|
|
275
275
|
"""Creates a Pydantic tool from a function and a JSON schema.
|
|
@@ -440,12 +440,12 @@ class ToolDefinition:
|
|
|
440
440
|
name: str
|
|
441
441
|
"""The name of the tool."""
|
|
442
442
|
|
|
443
|
-
description: str
|
|
444
|
-
"""The description of the tool."""
|
|
445
|
-
|
|
446
443
|
parameters_json_schema: ObjectJsonSchema
|
|
447
444
|
"""The JSON schema for the tool's parameters."""
|
|
448
445
|
|
|
446
|
+
description: str | None = None
|
|
447
|
+
"""The description of the tool."""
|
|
448
|
+
|
|
449
449
|
outer_typed_dict_key: str | None = None
|
|
450
450
|
"""The key in the outer [TypedDict] that wraps an output tool.
|
|
451
451
|
|
|
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
|
|
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
|