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#
| Attribute | Type | Description |
|---|---|---|
http_client | HttpClientService[HttpClientError] = http_client |
Functions#
__init__#
__init__(http_client, create_decisions) -> None| Parameter | Type | Description |
|---|---|---|
http_client | HttpClientService[HttpClientError] | |
create_decisions | Callable[[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_decisionscreate_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.
| Parameter | Type | Description |
|---|---|---|
request | W.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)