Skip to content

Commit 448412d

Browse files
committed
update generated sdk
1 parent 9b78e8f commit 448412d

File tree

10 files changed

+66
-128
lines changed

10 files changed

+66
-128
lines changed

guard-rails-api-client/guard_rails_api_client/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
""" A client library for accessing GuardRails API """
1+
"""A client library for accessing GuardRails API"""
2+
23
from .client import AuthenticatedClient, Client
34

45
__all__ = (
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
""" Contains methods for accessing the API """
1+
"""Contains methods for accessing the API"""
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" Contains shared errors types that can be raised from API functions """
1+
"""Contains shared errors types that can be raised from API functions"""
22

33

44
class UnexpectedStatus(Exception):
@@ -8,7 +8,9 @@ def __init__(self, status_code: int, content: bytes):
88
self.status_code = status_code
99
self.content = content
1010

11-
super().__init__(f"Unexpected status code: {status_code}")
11+
super().__init__(
12+
f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
13+
)
1214

1315

1416
__all__ = ["UnexpectedStatus"]

guard-rails-api-client/guard_rails_api_client/models/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" Contains all the data models used in inputs/outputs """
1+
"""Contains all the data models used in inputs/outputs"""
22

33
from .any_object import AnyObject
44
from .data_type import DataType
@@ -15,10 +15,8 @@
1515
from .health_check import HealthCheck
1616
from .history import History
1717
from .history_event import HistoryEvent
18-
from .history_event_parsed_output import HistoryEventParsedOutput
1918
from .history_event_prompt import HistoryEventPrompt
2019
from .history_event_reasks_item import HistoryEventReasksItem
21-
from .history_event_validated_output import HistoryEventValidatedOutput
2220
from .http_error import HttpError
2321
from .http_error_fields import HttpErrorFields
2422
from .ingestion import Ingestion
@@ -59,10 +57,8 @@
5957
"HealthCheck",
6058
"History",
6159
"HistoryEvent",
62-
"HistoryEventParsedOutput",
6360
"HistoryEventPrompt",
6461
"HistoryEventReasksItem",
65-
"HistoryEventValidatedOutput",
6662
"HttpError",
6763
"HttpErrorFields",
6864
"Ingestion",

guard-rails-api-client/guard_rails_api_client/models/history_event.py

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union
1+
from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast
22

33
from attrs import define as _attrs_define
44
from attrs import field as _attrs_field
55

66
from ..types import UNSET, Unset
77

88
if TYPE_CHECKING:
9-
from ..models.history_event_parsed_output import HistoryEventParsedOutput
9+
from ..models.any_object import AnyObject
1010
from ..models.history_event_prompt import HistoryEventPrompt
1111
from ..models.history_event_reasks_item import HistoryEventReasksItem
12-
from ..models.history_event_validated_output import HistoryEventValidatedOutput
1312

1413

1514
T = TypeVar("T", bound="HistoryEvent")
@@ -21,28 +20,34 @@ class HistoryEvent:
2120
Attributes:
2221
instructions (Union[Unset, str]):
2322
output (Union[Unset, str]):
24-
parsed_output (Union[Unset, HistoryEventParsedOutput]):
23+
parsed_output (Union['AnyObject', Unset, str]):
2524
prompt (Union[Unset, HistoryEventPrompt]):
2625
reasks (Union[Unset, List['HistoryEventReasksItem']]):
27-
validated_output (Union[Unset, HistoryEventValidatedOutput]):
26+
validated_output (Union['AnyObject', Unset, str]):
2827
"""
2928

3029
instructions: Union[Unset, str] = UNSET
3130
output: Union[Unset, str] = UNSET
32-
parsed_output: Union[Unset, "HistoryEventParsedOutput"] = UNSET
31+
parsed_output: Union["AnyObject", Unset, str] = UNSET
3332
prompt: Union[Unset, "HistoryEventPrompt"] = UNSET
3433
reasks: Union[Unset, List["HistoryEventReasksItem"]] = UNSET
35-
validated_output: Union[Unset, "HistoryEventValidatedOutput"] = UNSET
34+
validated_output: Union["AnyObject", Unset, str] = UNSET
3635
additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict)
3736

3837
def to_dict(self) -> Dict[str, Any]:
38+
from ..models.any_object import AnyObject
39+
3940
instructions = self.instructions
4041

4142
output = self.output
4243

43-
parsed_output: Union[Unset, Dict[str, Any]] = UNSET
44-
if not isinstance(self.parsed_output, Unset):
44+
parsed_output: Union[Dict[str, Any], Unset, str]
45+
if isinstance(self.parsed_output, Unset):
46+
parsed_output = UNSET
47+
elif isinstance(self.parsed_output, AnyObject):
4548
parsed_output = self.parsed_output.to_dict()
49+
else:
50+
parsed_output = self.parsed_output
4651

4752
prompt: Union[Unset, Dict[str, Any]] = UNSET
4853
if not isinstance(self.prompt, Unset):
@@ -55,9 +60,13 @@ def to_dict(self) -> Dict[str, Any]:
5560
reasks_item = reasks_item_data.to_dict()
5661
reasks.append(reasks_item)
5762

58-
validated_output: Union[Unset, Dict[str, Any]] = UNSET
59-
if not isinstance(self.validated_output, Unset):
63+
validated_output: Union[Dict[str, Any], Unset, str]
64+
if isinstance(self.validated_output, Unset):
65+
validated_output = UNSET
66+
elif isinstance(self.validated_output, AnyObject):
6067
validated_output = self.validated_output.to_dict()
68+
else:
69+
validated_output = self.validated_output
6170

6271
field_dict: Dict[str, Any] = {}
6372
field_dict.update(self.additional_properties)
@@ -79,22 +88,29 @@ def to_dict(self) -> Dict[str, Any]:
7988

8089
@classmethod
8190
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
82-
from ..models.history_event_parsed_output import HistoryEventParsedOutput
91+
from ..models.any_object import AnyObject
8392
from ..models.history_event_prompt import HistoryEventPrompt
8493
from ..models.history_event_reasks_item import HistoryEventReasksItem
85-
from ..models.history_event_validated_output import HistoryEventValidatedOutput
8694

8795
d = src_dict.copy()
8896
instructions = d.pop("instructions", UNSET)
8997

9098
output = d.pop("output", UNSET)
9199

92-
_parsed_output = d.pop("parsedOutput", UNSET)
93-
parsed_output: Union[Unset, HistoryEventParsedOutput]
94-
if isinstance(_parsed_output, Unset):
95-
parsed_output = UNSET
96-
else:
97-
parsed_output = HistoryEventParsedOutput.from_dict(_parsed_output)
100+
def _parse_parsed_output(data: object) -> Union["AnyObject", Unset, str]:
101+
if isinstance(data, Unset):
102+
return data
103+
try:
104+
if not isinstance(data, dict):
105+
raise TypeError()
106+
parsed_output_type_0 = AnyObject.from_dict(data)
107+
108+
return parsed_output_type_0
109+
except: # noqa: E722
110+
pass
111+
return cast(Union["AnyObject", Unset, str], data)
112+
113+
parsed_output = _parse_parsed_output(d.pop("parsedOutput", UNSET))
98114

99115
_prompt = d.pop("prompt", UNSET)
100116
prompt: Union[Unset, HistoryEventPrompt]
@@ -110,12 +126,20 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
110126

111127
reasks.append(reasks_item)
112128

113-
_validated_output = d.pop("validatedOutput", UNSET)
114-
validated_output: Union[Unset, HistoryEventValidatedOutput]
115-
if isinstance(_validated_output, Unset):
116-
validated_output = UNSET
117-
else:
118-
validated_output = HistoryEventValidatedOutput.from_dict(_validated_output)
129+
def _parse_validated_output(data: object) -> Union["AnyObject", Unset, str]:
130+
if isinstance(data, Unset):
131+
return data
132+
try:
133+
if not isinstance(data, dict):
134+
raise TypeError()
135+
validated_output_type_0 = AnyObject.from_dict(data)
136+
137+
return validated_output_type_0
138+
except: # noqa: E722
139+
pass
140+
return cast(Union["AnyObject", Unset, str], data)
141+
142+
validated_output = _parse_validated_output(d.pop("validatedOutput", UNSET))
119143

120144
history_event = cls(
121145
instructions=instructions,

guard-rails-api-client/guard_rails_api_client/models/history_event_parsed_output.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

guard-rails-api-client/guard_rails_api_client/models/history_event_validated_output.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

guard-rails-api-client/guard_rails_api_client/types.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
""" Contains some shared types for properties """
1+
"""Contains some shared types for properties"""
2+
23
from http import HTTPStatus
34
from typing import BinaryIO, Generic, Literal, MutableMapping, Optional, Tuple, TypeVar
45

guard-rails-api-client/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name="guard-rails-api-client",
10-
version="0.0.0",
10+
version="0.0.2",
1111
description="A client library for accessing GuardRails API",
1212
long_description=long_description,
1313
long_description_content_type="text/markdown",

open-api-spec.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -703,9 +703,9 @@ components:
703703
output:
704704
type: string
705705
parsedOutput:
706-
type: object
707-
properties: {}
708-
additionalProperties: {}
706+
oneOf:
707+
- $ref: "#/components/schemas/AnyObject"
708+
- type: string
709709
prompt:
710710
type: object
711711
properties:
@@ -718,9 +718,9 @@ components:
718718
properties: {}
719719
additionalProperties: {}
720720
validatedOutput:
721-
type: object
722-
properties: {}
723-
additionalProperties: {}
721+
oneOf:
722+
- $ref: "#/components/schemas/AnyObject"
723+
- type: string
724724
additionalProperties: {}
725725
Reask:
726726
type: object

0 commit comments

Comments
 (0)