You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow registering exception handlers on an instance of RetryChatModel to customize how different errors are handled. These should get the error (and also the current Chat?) as input and return a list of messages to append (or a new Chat?).
Maybe implement this by adding error handling to Chat and using Chat within RetryModel.
As part of this, export all relevant magentic exceptions from magentic.exceptions for easy access. And document the exceptions.
API could be something like:
frommagenticimportOpenaiChatModelfrommagentic.chat_model.retry_chat_modelimportRetryChatModel# TODO: make exceptions importable from single locationfrommagentic.exceptionsimportUnknownToolErrorretry_model=RetryChatModel(OpenaiChatModel("gpt-4o-mini"), max_retries=3)
# OR retry_model = RetryChatModel("openai:gpt-4o-mini", max_retries=3)@retry_model.register_handler(UnknownToolError)def_(self, error: UnknownToolError) ->Sequence[Message[Any]]:
return [
error.output_message,
ToolResultMessage(
content=str(error.validation_error),
tool_call_id=error.tool_call_id,
),
]
Allow registering exception handlers on an instance of
RetryChatModel
to customize how different errors are handled. These should get the error (and also the currentChat
?) as input and return a list of messages to append (or a newChat
?).Maybe implement this by adding error handling to
Chat
and usingChat
withinRetryModel
.As part of this, export all relevant magentic exceptions from
magentic.exceptions
for easy access. And document the exceptions.API could be something like:
Similar to FastAPI's exception handling: https://fastapi.tiangolo.com/tutorial/handling-errors/#add-custom-headers
The text was updated successfully, but these errors were encountered: