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 src/otari/_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
"AliasResponse",
"AllocationHealthResponse",
"Annotations",
"AnthropicError",
"AnthropicErrorResponse",
"AnthropicFileDeleted",
"AnthropicFileList",
"AnthropicFileMetadata",
Expand Down Expand Up @@ -892,6 +894,8 @@
from otari._client.models.alias_response import AliasResponse as AliasResponse
from otari._client.models.allocation_health_response import AllocationHealthResponse as AllocationHealthResponse
from otari._client.models.annotations import Annotations as Annotations
from otari._client.models.anthropic_error import AnthropicError as AnthropicError
from otari._client.models.anthropic_error_response import AnthropicErrorResponse as AnthropicErrorResponse
from otari._client.models.anthropic_file_deleted import AnthropicFileDeleted as AnthropicFileDeleted
from otari._client.models.anthropic_file_list import AnthropicFileList as AnthropicFileList
from otari._client.models.anthropic_file_metadata import AnthropicFileMetadata as AnthropicFileMetadata
Expand Down
18 changes: 12 additions & 6 deletions src/otari/_client/api/messages_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def messages_count_message_tokens(

_response_types_map: Dict[str, Optional[str]] = {
'200': "CountTokensResponse",
'422': "HTTPValidationError",
'4XX': "AnthropicErrorResponse",
'5XX': "AnthropicErrorResponse",
}
response_data = self.api_client.call_api(
*_param,
Expand Down Expand Up @@ -164,7 +165,8 @@ def messages_count_message_tokens_with_http_info(

_response_types_map: Dict[str, Optional[str]] = {
'200': "CountTokensResponse",
'422': "HTTPValidationError",
'4XX': "AnthropicErrorResponse",
'5XX': "AnthropicErrorResponse",
}
response_data = self.api_client.call_api(
*_param,
Expand Down Expand Up @@ -232,7 +234,8 @@ def messages_count_message_tokens_without_preload_content(

_response_types_map: Dict[str, Optional[str]] = {
'200': "CountTokensResponse",
'422': "HTTPValidationError",
'4XX': "AnthropicErrorResponse",
'5XX': "AnthropicErrorResponse",
}
response_data = self.api_client.call_api(
*_param,
Expand Down Expand Up @@ -382,7 +385,8 @@ def messages_create_message(

_response_types_map: Dict[str, Optional[str]] = {
'200': "MessageResponse",
'422': "HTTPValidationError",
'4XX': "AnthropicErrorResponse",
'5XX': "AnthropicErrorResponse",
}
response_data = self.api_client.call_api(
*_param,
Expand Down Expand Up @@ -458,7 +462,8 @@ def messages_create_message_with_http_info(

_response_types_map: Dict[str, Optional[str]] = {
'200': "MessageResponse",
'422': "HTTPValidationError",
'4XX': "AnthropicErrorResponse",
'5XX': "AnthropicErrorResponse",
}
response_data = self.api_client.call_api(
*_param,
Expand Down Expand Up @@ -534,7 +539,8 @@ def messages_create_message_without_preload_content(

_response_types_map: Dict[str, Optional[str]] = {
'200': "MessageResponse",
'422': "HTTPValidationError",
'4XX': "AnthropicErrorResponse",
'5XX': "AnthropicErrorResponse",
}
response_data = self.api_client.call_api(
*_param,
Expand Down
2 changes: 2 additions & 0 deletions src/otari/_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
from otari._client.models.alias_response import AliasResponse
from otari._client.models.allocation_health_response import AllocationHealthResponse
from otari._client.models.annotations import Annotations
from otari._client.models.anthropic_error import AnthropicError
from otari._client.models.anthropic_error_response import AnthropicErrorResponse
from otari._client.models.anthropic_file_deleted import AnthropicFileDeleted
from otari._client.models.anthropic_file_list import AnthropicFileList
from otari._client.models.anthropic_file_metadata import AnthropicFileMetadata
Expand Down
90 changes: 90 additions & 0 deletions src/otari/_client/models/anthropic_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# coding: utf-8

"""
otari

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.0.0-dev
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501


from __future__ import annotations
import pprint
import re # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class AnthropicError(BaseModel):
"""
What went wrong, in Anthropic's terms.
""" # noqa: E501
message: StrictStr
type: StrictStr = Field(description="Anthropic's error type, such as `invalid_request_error` or `rate_limit_error`.")
__properties: ClassVar[List[str]] = ["message", "type"]

model_config = ConfigDict(
validate_by_name=True,
validate_by_alias=True,
validate_assignment=True,
protected_namespaces=(),
)


def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(to_jsonable_python(self.to_dict()))

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AnthropicError from a JSON string"""
return cls.from_dict(json.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.

This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:

* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
excluded_fields: Set[str] = set([
])

_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
return _dict

@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of AnthropicError from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return cls.model_validate(obj)

_obj = cls.model_validate({
"message": obj.get("message"),
"type": obj.get("type")
})
return _obj


111 changes: 111 additions & 0 deletions src/otari/_client/models/anthropic_error_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# coding: utf-8

"""
otari

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.0.0-dev
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501


from __future__ import annotations
import pprint
import re # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from otari._client.models.anthropic_error import AnthropicError
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class AnthropicErrorResponse(BaseModel):
"""
Anthropic's error envelope, which every error on a Messages route is answered in.
""" # noqa: E501
code: Optional[StrictStr] = Field(default=None, description="The refusal's `Otari-Error-Code`, where it has one.")
error: AnthropicError
type: Optional[StrictStr] = 'error'
__properties: ClassVar[List[str]] = ["code", "error", "type"]

@field_validator('type')
def type_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value

if value not in set(['error']):
raise ValueError("must be one of enum values ('error')")
return value

model_config = ConfigDict(
validate_by_name=True,
validate_by_alias=True,
validate_assignment=True,
protected_namespaces=(),
)


def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(to_jsonable_python(self.to_dict()))

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AnthropicErrorResponse from a JSON string"""
return cls.from_dict(json.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.

This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:

* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
excluded_fields: Set[str] = set([
])

_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
# override the default output from pydantic by calling `to_dict()` of error
if self.error:
_dict['error'] = self.error.to_dict()
# set to None if code (nullable) is None
# and model_fields_set contains the field
if self.code is None and "code" in self.model_fields_set:
_dict['code'] = None

return _dict

@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of AnthropicErrorResponse from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return cls.model_validate(obj)

_obj = cls.model_validate({
"code": obj.get("code"),
"error": AnthropicError.from_dict(obj["error"]) if obj.get("error") is not None else None,
"type": obj.get("type") if obj.get("type") is not None else 'error'
})
return _obj


Loading