Movatterモバイル変換


[0]ホーム

URL:


Skip to content

pydantic_ai.exceptions

ModelRetry

Bases:Exception

Exception raised when a tool function should be retried.

The agent will return the message to the model and ask it to try calling the function/tool again.

Source code inpydantic_ai_slim/pydantic_ai/exceptions.py
262728293031323334353637
classModelRetry(Exception):"""Exception raised when a tool function should be retried.    The agent will return the message to the model and ask it to try calling the function/tool again.    """message:str"""The message to return to the model."""def__init__(self,message:str):self.message=messagesuper().__init__(message)

messageinstance-attribute

message:str=message

The message to return to the model.

UserError

Bases:RuntimeError

Error caused by a usage mistake by the application developer — You!

Source code inpydantic_ai_slim/pydantic_ai/exceptions.py
404142434445464748
classUserError(RuntimeError):"""Error caused by a usage mistake by the application developer — You!"""message:str"""Description of the mistake."""def__init__(self,message:str):self.message=messagesuper().__init__(message)

messageinstance-attribute

message:str=message

Description of the mistake.

AgentRunError

Bases:RuntimeError

Base class for errors occurring during an agent run.

Source code inpydantic_ai_slim/pydantic_ai/exceptions.py
515253545556575859606162
classAgentRunError(RuntimeError):"""Base class for errors occurring during an agent run."""message:str"""The error message."""def__init__(self,message:str):self.message=messagesuper().__init__(message)def__str__(self)->str:returnself.message

messageinstance-attribute

message:str=message

The error message.

UsageLimitExceeded

Bases:AgentRunError

Error raised when a Model's usage exceeds the specified limits.

Source code inpydantic_ai_slim/pydantic_ai/exceptions.py
6566
classUsageLimitExceeded(AgentRunError):"""Error raised when a Model's usage exceeds the specified limits."""

UnexpectedModelBehavior

Bases:AgentRunError

Error caused by unexpected Model behavior, e.g. an unexpected response code.

Source code inpydantic_ai_slim/pydantic_ai/exceptions.py
697071727374757677787980818283848586878889909192
classUnexpectedModelBehavior(AgentRunError):"""Error caused by unexpected Model behavior, e.g. an unexpected response code."""message:str"""Description of the unexpected behavior."""body:str|None"""The body of the response, if available."""def__init__(self,message:str,body:str|None=None):self.message=messageifbodyisNone:self.body:str|None=Noneelse:try:self.body=json.dumps(json.loads(body),indent=2)exceptValueError:self.body=bodysuper().__init__(message)def__str__(self)->str:ifself.body:returnf'{self.message}, body:\n{self.body}'else:returnself.message

messageinstance-attribute

message:str=message

Description of the unexpected behavior.

bodyinstance-attribute

body:str|None=dumps(loads(body),indent=2)

The body of the response, if available.

ModelHTTPError

Bases:AgentRunError

Raised when an model provider response has a status code of 4xx or 5xx.

Source code inpydantic_ai_slim/pydantic_ai/exceptions.py
 95 96 97 98 99100101102103104105106107108109110111112113114115
classModelHTTPError(AgentRunError):"""Raised when an model provider response has a status code of 4xx or 5xx."""status_code:int"""The HTTP status code returned by the API."""model_name:str"""The name of the model associated with the error."""body:object|None"""The body of the response, if available."""message:str"""The error message with the status code and response body, if available."""def__init__(self,status_code:int,model_name:str,body:object|None=None):self.status_code=status_codeself.model_name=model_nameself.body=bodymessage=f'status_code:{status_code}, model_name:{model_name}, body:{body}'super().__init__(message)

messageinstance-attribute

message:str

The error message with the status code and response body, if available.

status_codeinstance-attribute

status_code:int=status_code

The HTTP status code returned by the API.

model_nameinstance-attribute

model_name:str=model_name

The name of the model associated with the error.

bodyinstance-attribute

body:object|None=body

The body of the response, if available.

FallbackExceptionGroup

Bases:ExceptionGroup

A group of exceptions that can be raised when all fallback models fail.

Source code inpydantic_ai_slim/pydantic_ai/exceptions.py
118119
classFallbackExceptionGroup(ExceptionGroup):"""A group of exceptions that can be raised when all fallback models fail."""

[8]ページ先頭

©2009-2025 Movatter.jp