4
4
import inspect
5
5
from collections .abc import Awaitable
6
6
from dataclasses import dataclass , field
7
- from typing import TYPE_CHECKING , Any , Callable , Generic , TypeVar , Union , cast
7
+ from typing import TYPE_CHECKING , Any , Callable , Generic , Union , cast
8
8
9
9
from pydantic import ValidationError
10
10
from pydantic_core import SchemaValidator
11
- from typing_extensions import Concatenate , ParamSpec , TypeAlias
11
+ from typing_extensions import Concatenate , ParamSpec , TypeAlias , TypeVar
12
12
13
13
from . import _pydantic , _utils , messages as _messages , models
14
14
from .exceptions import ModelRetry , UnexpectedModelBehavior
30
30
'ToolDefinition' ,
31
31
)
32
32
33
- AgentDeps = TypeVar ('AgentDeps' )
33
+ AgentDeps = TypeVar ('AgentDeps' , default = None )
34
34
"""Type variable for agent dependencies."""
35
35
36
36
@@ -67,7 +67,7 @@ def replace_with(
67
67
return dataclasses .replace (self , ** kwargs )
68
68
69
69
70
- ToolParams = ParamSpec ('ToolParams' )
70
+ ToolParams = ParamSpec ('ToolParams' , default = ... )
71
71
"""Retrieval function param spec."""
72
72
73
73
SystemPromptFunc = Union [
@@ -92,7 +92,7 @@ def replace_with(
92
92
Usage `ToolPlainFunc[ToolParams]`.
93
93
"""
94
94
ToolFuncEither = Union [ToolFuncContext [AgentDeps , ToolParams ], ToolFuncPlain [ToolParams ]]
95
- """Either part_kind of tool function.
95
+ """Either kind of tool function.
96
96
97
97
This is just a union of [`ToolFuncContext`][pydantic_ai.tools.ToolFuncContext] and
98
98
[`ToolFuncPlain`][pydantic_ai.tools.ToolFuncPlain].
@@ -134,7 +134,7 @@ def hitchhiker(ctx: RunContext[int], answer: str) -> str:
134
134
class Tool (Generic [AgentDeps ]):
135
135
"""A tool function for an agent."""
136
136
137
- function : ToolFuncEither [AgentDeps , ... ]
137
+ function : ToolFuncEither [AgentDeps ]
138
138
takes_ctx : bool
139
139
max_retries : int | None
140
140
name : str
@@ -150,7 +150,7 @@ class Tool(Generic[AgentDeps]):
150
150
151
151
def __init__ (
152
152
self ,
153
- function : ToolFuncEither [AgentDeps , ... ],
153
+ function : ToolFuncEither [AgentDeps ],
154
154
* ,
155
155
takes_ctx : bool | None = None ,
156
156
max_retries : int | None = None ,
0 commit comments