controller
NexosAIAPIEndpointController
dataclass
Bases: Generic[EndpointRequestType, EndpointResponseType]
Abstract base class for NexosAI endpoint controllers. This class defines the structure for endpoint controllers in the Nexos AI API.
Source code in src/nexosapi/api/controller.py
Operations
Enum to define operations for the NexosAIEndpointController. This enum can be extended to include specific operations for different controllers.
validate_endpoint
classmethod
validate_endpoint(endpoint: str) -> None
Validates the endpoint format. Raises ValueError if the endpoint does not match the expected format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
The API endpoint to validate. |
required |
Source code in src/nexosapi/api/controller.py
on_response
async
Hook for processing the response before returning it. Can be overridden in subclasses to add custom response handling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
EndpointResponseType
|
The response object to process. |
required |
Returns:
| Type | Description |
|---|---|
EndpointResponseType
|
The processed response object. |
Source code in src/nexosapi/api/controller.py
on_error
async
Hook for handling errors that occur during the request. Can be overridden in subclasses to add custom error handling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Response
|
The HTTP response object which contains the error. |
required |
Returns:
| Type | Description |
|---|---|
EndpointResponseType
|
A null response object or a custom error response. |