Skip to content

pydantic_ai.dependencies

AgentDeps module-attribute

AgentDeps = TypeVar('AgentDeps')

Type variable for agent dependencies.

CallContext dataclass

Bases: Generic[AgentDeps]

Information about the current call.

Source code in pydantic_ai/dependencies.py
30
31
32
33
34
35
36
37
38
39
@dataclass
class CallContext(Generic[AgentDeps]):
    """Information about the current call."""

    deps: AgentDeps
    """Dependencies for the agent."""
    retry: int
    """Number of retries so far."""
    tool_name: str | None
    """Name of the tool being called."""

deps instance-attribute

deps: AgentDeps

Dependencies for the agent.

retry instance-attribute

retry: int

Number of retries so far.

tool_name instance-attribute

tool_name: str | None

Name of the tool being called.

RetrieverParams module-attribute

RetrieverParams = ParamSpec('RetrieverParams')

Retrieval function param spec.

SystemPromptFunc module-attribute

A function that may or maybe not take CallContext as an argument, and may or may not be async.

Usage SystemPromptFunc[AgentDeps].

ResultValidatorFunc module-attribute

A function that always takes ResultData and returns ResultData, but may or maybe not take CallInfo as a first argument, and may or may not be async.

Usage ResultValidator[AgentDeps, ResultData].

JsonData module-attribute

JsonData: TypeAlias = (
    "None | str | int | float | Sequence[JsonData] | Mapping[str, JsonData]"
)

Type representing any JSON data.

RetrieverReturnValue module-attribute

RetrieverReturnValue = Union[JsonData, Awaitable[JsonData]]

Return value of a retriever function.

RetrieverContextFunc module-attribute

A retriever function that takes CallContext as the first argument.

Usage RetrieverContextFunc[AgentDeps, RetrieverParams].

RetrieverPlainFunc module-attribute

A retriever function that does not take CallContext as the first argument.

Usage RetrieverPlainFunc[RetrieverParams].