Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sdk-endpoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ GET /api/v1/agent-telemetry/series # not yet wrapped
DELETE /api/v1/agent-telemetry # not yet wrapped
# Agent Gates' Hook Server: a hook-protocol endpoint for agent tooling, not an SDK surface
POST /api/v1/hooks/check # not yet wrapped
POST /api/v1/hooks/guardrails # not yet wrapped
# Routing policies
GET /api/v1/routing/policies # not yet wrapped
POST /api/v1/routing/policies # not yet wrapped
Expand Down Expand Up @@ -389,6 +390,9 @@ POST /api/v1/organizations/me/keys # dashboard-only
PATCH /api/v1/organizations/me/keys/{key_id} # dashboard-only
DELETE /api/v1/organizations/me/keys/{key_id} # dashboard-only
POST /api/v1/organizations/me/keys/{key_id}/rotate # dashboard-only
POST /api/v1/organizations/me/keys/{key_id}/federation-rules # dashboard-only
GET /api/v1/organizations/me/keys/{key_id}/federation-rules # dashboard-only
DELETE /api/v1/organizations/me/keys/{key_id}/federation-rules/{rule_id} # dashboard-only
# The organization's own budgets and the ceilings enforcing them
# (otari-ai#1943), excluded for the same reason as the keys above: the
# organization is resolved from the caller's dashboard session rather than named
Expand Down
10 changes: 10 additions & 0 deletions src/otari/_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,15 @@
"FederationTokenRequest",
"FederationTokenResponse",
"FeedbackSubmission",
"GateDefinitionRequest",
"GateResultResponse",
"GateSummaryPublic",
"GatewaySettings",
"GuardrailCatalog",
"GuardrailCategory",
"GuardrailConfig",
"GuardrailDefinitionRequest",
"GuardrailDefinitionResponse",
"GuardrailParameterSpec",
"GuardrailProfileSpec",
"GuardrailStage",
Expand Down Expand Up @@ -513,6 +517,7 @@
"MessagesRequest",
"Model",
"Model1",
"ModelArchitecture",
"ModelFalse",
"ModelListResponse",
"ModelMetadata",
Expand Down Expand Up @@ -1070,11 +1075,15 @@
from otari._client.models.federation_token_request import FederationTokenRequest as FederationTokenRequest
from otari._client.models.federation_token_response import FederationTokenResponse as FederationTokenResponse
from otari._client.models.feedback_submission import FeedbackSubmission as FeedbackSubmission
from otari._client.models.gate_definition_request import GateDefinitionRequest as GateDefinitionRequest
from otari._client.models.gate_result_response import GateResultResponse as GateResultResponse
from otari._client.models.gate_summary_public import GateSummaryPublic as GateSummaryPublic
from otari._client.models.gateway_settings import GatewaySettings as GatewaySettings
from otari._client.models.guardrail_catalog import GuardrailCatalog as GuardrailCatalog
from otari._client.models.guardrail_category import GuardrailCategory as GuardrailCategory
from otari._client.models.guardrail_config import GuardrailConfig as GuardrailConfig
from otari._client.models.guardrail_definition_request import GuardrailDefinitionRequest as GuardrailDefinitionRequest
from otari._client.models.guardrail_definition_response import GuardrailDefinitionResponse as GuardrailDefinitionResponse
from otari._client.models.guardrail_parameter_spec import GuardrailParameterSpec as GuardrailParameterSpec
from otari._client.models.guardrail_profile_spec import GuardrailProfileSpec as GuardrailProfileSpec
from otari._client.models.guardrail_stage import GuardrailStage as GuardrailStage
Expand Down Expand Up @@ -1284,6 +1293,7 @@
from otari._client.models.messages_request import MessagesRequest as MessagesRequest
from otari._client.models.model import Model as Model
from otari._client.models.model1 import Model1 as Model1
from otari._client.models.model_architecture import ModelArchitecture as ModelArchitecture
from otari._client.models.model_false import ModelFalse as ModelFalse
from otari._client.models.model_list_response import ModelListResponse as ModelListResponse
from otari._client.models.model_metadata import ModelMetadata as ModelMetadata
Expand Down
280 changes: 280 additions & 0 deletions src/otari/_client/api/hooks_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from typing import Any, Dict, List, Optional, Tuple, Union
from typing_extensions import Annotated

from otari._client.models.guardrail_definition_request import GuardrailDefinitionRequest
from otari._client.models.guardrail_definition_response import GuardrailDefinitionResponse
from otari._client.models.policy_check_request import PolicyCheckRequest
from otari._client.models.policy_check_response import PolicyCheckResponse

Expand Down Expand Up @@ -312,3 +314,281 @@ def _hooks_check_policy_serialize(
)




@validate_call
def hooks_record_guardrail_definition(
self,
guardrail_definition_request: GuardrailDefinitionRequest,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Tuple[
Annotated[StrictFloat, Field(gt=0)],
Annotated[StrictFloat, Field(gt=0)]
]
] = None,
_request_auth: Optional[Dict[StrictStr, Any]] = None,
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> GuardrailDefinitionResponse:
"""Record Guardrail Definition

Keep one version of an agent guardrail, so the gate spans that name it can say what each gate is for. `otari hook` sends this once per version, the first time it reports a check against it. The fingerprint is recomputed from the gates, and one that does not match the one sent is refused, so a version cannot be stored under another's name. Sending a version again changes nothing. It is stored in the API key's workspace, beside that key's traces, and takes the same key a trace export does: a budget-exempt API key, never the master key.

:param guardrail_definition_request: (required)
:type guardrail_definition_request: GuardrailDefinitionRequest
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:type _request_timeout: int, tuple(int, int), optional
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the
authentication in the spec for a single request.
:type _request_auth: dict, optional
:param _content_type: force content-type for the request.
:type _content_type: str, Optional
:param _headers: set to override the headers for a single
request; this effectively ignores the headers
in the spec for a single request.
:type _headers: dict, optional
:param _host_index: set to override the host_index for a single
request; this effectively ignores the host_index
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501

_param = self._hooks_record_guardrail_definition_serialize(
guardrail_definition_request=guardrail_definition_request,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
_host_index=_host_index
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "GuardrailDefinitionResponse",
'422': "HTTPValidationError",
}
response_data = self.api_client.call_api(
*_param,
_request_timeout=_request_timeout
)
response_data.read()
return self.api_client.response_deserialize(
response_data=response_data,
response_types_map=_response_types_map,
).data


@validate_call
def hooks_record_guardrail_definition_with_http_info(
self,
guardrail_definition_request: GuardrailDefinitionRequest,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Tuple[
Annotated[StrictFloat, Field(gt=0)],
Annotated[StrictFloat, Field(gt=0)]
]
] = None,
_request_auth: Optional[Dict[StrictStr, Any]] = None,
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> ApiResponse[GuardrailDefinitionResponse]:
"""Record Guardrail Definition

Keep one version of an agent guardrail, so the gate spans that name it can say what each gate is for. `otari hook` sends this once per version, the first time it reports a check against it. The fingerprint is recomputed from the gates, and one that does not match the one sent is refused, so a version cannot be stored under another's name. Sending a version again changes nothing. It is stored in the API key's workspace, beside that key's traces, and takes the same key a trace export does: a budget-exempt API key, never the master key.

:param guardrail_definition_request: (required)
:type guardrail_definition_request: GuardrailDefinitionRequest
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:type _request_timeout: int, tuple(int, int), optional
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the
authentication in the spec for a single request.
:type _request_auth: dict, optional
:param _content_type: force content-type for the request.
:type _content_type: str, Optional
:param _headers: set to override the headers for a single
request; this effectively ignores the headers
in the spec for a single request.
:type _headers: dict, optional
:param _host_index: set to override the host_index for a single
request; this effectively ignores the host_index
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501

_param = self._hooks_record_guardrail_definition_serialize(
guardrail_definition_request=guardrail_definition_request,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
_host_index=_host_index
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "GuardrailDefinitionResponse",
'422': "HTTPValidationError",
}
response_data = self.api_client.call_api(
*_param,
_request_timeout=_request_timeout
)
response_data.read()
return self.api_client.response_deserialize(
response_data=response_data,
response_types_map=_response_types_map,
)


@validate_call
def hooks_record_guardrail_definition_without_preload_content(
self,
guardrail_definition_request: GuardrailDefinitionRequest,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Tuple[
Annotated[StrictFloat, Field(gt=0)],
Annotated[StrictFloat, Field(gt=0)]
]
] = None,
_request_auth: Optional[Dict[StrictStr, Any]] = None,
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> RESTResponseType:
"""Record Guardrail Definition

Keep one version of an agent guardrail, so the gate spans that name it can say what each gate is for. `otari hook` sends this once per version, the first time it reports a check against it. The fingerprint is recomputed from the gates, and one that does not match the one sent is refused, so a version cannot be stored under another's name. Sending a version again changes nothing. It is stored in the API key's workspace, beside that key's traces, and takes the same key a trace export does: a budget-exempt API key, never the master key.

:param guardrail_definition_request: (required)
:type guardrail_definition_request: GuardrailDefinitionRequest
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:type _request_timeout: int, tuple(int, int), optional
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the
authentication in the spec for a single request.
:type _request_auth: dict, optional
:param _content_type: force content-type for the request.
:type _content_type: str, Optional
:param _headers: set to override the headers for a single
request; this effectively ignores the headers
in the spec for a single request.
:type _headers: dict, optional
:param _host_index: set to override the host_index for a single
request; this effectively ignores the host_index
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501

_param = self._hooks_record_guardrail_definition_serialize(
guardrail_definition_request=guardrail_definition_request,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
_host_index=_host_index
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "GuardrailDefinitionResponse",
'422': "HTTPValidationError",
}
response_data = self.api_client.call_api(
*_param,
_request_timeout=_request_timeout
)
return response_data.response


def _hooks_record_guardrail_definition_serialize(
self,
guardrail_definition_request,
_request_auth,
_content_type,
_headers,
_host_index,
) -> RequestSerialized:

_host = None

_collection_formats: Dict[str, str] = {
}

_path_params: Dict[str, str] = {}
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[
str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
] = {}
_body_params: Optional[bytes] = None

# process the path parameters
# process the query parameters
# process the header parameters
# process the form parameters
# process the body parameter
if guardrail_definition_request is not None:
_body_params = guardrail_definition_request


# set the HTTP header `Accept`
if 'Accept' not in _header_params:
_header_params['Accept'] = self.api_client.select_header_accept(
[
'application/json'
]
)

# set the HTTP header `Content-Type`
if _content_type:
_header_params['Content-Type'] = _content_type
else:
_default_content_type = (
self.api_client.select_header_content_type(
[
'application/json'
]
)
)
if _default_content_type is not None:
_header_params['Content-Type'] = _default_content_type

# authentication setting
_auth_settings: List[str] = [
'XApiKeyAuth',
'ApiKeyAuth'
]

return self.api_client.param_serialize(
method='POST',
resource_path='/api/v1/hooks/guardrails',
path_params=_path_params,
query_params=_query_params,
header_params=_header_params,
body=_body_params,
post_params=_form_params,
files=_files,
auth_settings=_auth_settings,
collection_formats=_collection_formats,
_host=_host,
_request_auth=_request_auth
)


Loading
Loading