GitHub

API reference for Service.

The client: the configured HttpClient and the decisions call. make builds it; Service(http_client, create_decisions) makes one of a function (a test double, say).

Attributes

AttributeTypeDescription
http_clientHttpClientService[HttpClientError] = http_client

Functions

__init__

__init__(http_client, create_decisions) -> None
ParameterTypeDescription
http_clientHttpClientService[HttpClientError]
create_decisionsCallable[[W.DecisionsRequest], Effect[W.DecisionsResponse, AiError]]
def __init__(
    self,
    http_client: HttpClientService[HttpClientError],
    create_decisions: Callable[[W.DecisionsRequest], Effect[W.DecisionsResponse, AiError]],
) -> None:
    self.http_client = http_client
    self._create_decisions = create_decisions

create_decisions

create_decisions(request) -> Effect[W.DecisionsResponse, AiError]

Run request 's Clef model: POST to /accounts/<account_id>/ai/run/@cf/cloudflare/<model>, giving the result of Cloudflare's envelope. Every failure is an AiError: an error status or a failure envelope maps to its reason (a 429 to a RateLimitError), an undecodable body to an InvalidOutputError or InvalidResponseError, a transport failure to a NetworkError. Nothing is retried.

ParameterTypeDescription
requestW.DecisionsRequest

Returns Effect[W.DecisionsResponse, AiError]

def create_decisions(self, request: W.DecisionsRequest) -> Effect[W.DecisionsResponse, AiError]:
    """Run ``request`` 's Clef model: ``POST`` to
    ``/accounts/<account_id>/ai/run/@cf/cloudflare/<model>``, giving the
    ``result`` of Cloudflare's envelope. Every failure is an ``AiError``:
    an error status or a failure envelope maps to its reason (a 429 to a
    ``RateLimitError``), an undecodable body to an ``InvalidOutputError``
    or ``InvalidResponseError``, a transport failure to a
    ``NetworkError``. Nothing is retried."""
    return self._create_decisions(request)