One of the responsibilities of the SDK is to categorize function outputs (return values or exceptions raised) into a Status, so that Dispatch knows a) whether to retry, and b) how to adjust the execution concurrency moving forwards.
The SDK provides two functions for registering handler functions that map base error and output (return value) classes to a Status:
Sometimes the user simply wants to map a specific class to a specific status, and the handler function is unnecessary indirection.
This PR simplifies the interface so that users can either pass a Status directly, or (as before) a handler function that maps error/output classes to statuses. For example, the following is now accepted:
One of the responsibilities of the SDK is to categorize function outputs (return values or exceptions raised) into a
Status
, so that Dispatch knows a) whether to retry, and b) how to adjust the execution concurrency moving forwards.The SDK provides two functions for registering handler functions that map base error and output (return value) classes to a
Status
:For example usage, see https://github.com/dispatchrun/dispatch-py/blob/main/src/dispatch/integrations/openai.py
Sometimes the user simply wants to map a specific class to a specific status, and the handler function is unnecessary indirection.
This PR simplifies the interface so that users can either pass a
Status
directly, or (as before) a handler function that maps error/output classes to statuses. For example, the following is now accepted: