Skip to content

Commit 66fb05c

Browse files
authored
Merge pull request #10 from guardrails-ai/demo-fixes
Fixes from E2E Testing
2 parents ad51873 + f276aa4 commit 66fb05c

File tree

5 files changed

+53
-27
lines changed

5 files changed

+53
-27
lines changed

guardrails-api-client/guardrails_api_client/client.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ class Client:
3535
"""
3636

3737
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
38-
_base_url: str
39-
_cookies: Dict[str, str] = field(factory=dict, kw_only=True)
40-
_headers: Dict[str, str] = field(factory=dict, kw_only=True)
41-
_timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True)
42-
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True)
43-
_follow_redirects: bool = field(default=False, kw_only=True)
44-
_httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True)
38+
_base_url: str = field(alias="base_url")
39+
_cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
40+
_headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
41+
_timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")
42+
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")
43+
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
44+
_httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
4545
_client: Optional[httpx.Client] = field(default=None, init=False)
4646
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
4747

@@ -165,13 +165,13 @@ class AuthenticatedClient:
165165
"""
166166

167167
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
168-
_base_url: str
169-
_cookies: Dict[str, str] = field(factory=dict, kw_only=True)
170-
_headers: Dict[str, str] = field(factory=dict, kw_only=True)
171-
_timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True)
172-
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True)
173-
_follow_redirects: bool = field(default=False, kw_only=True)
174-
_httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True)
168+
_base_url: str = field(alias="base_url")
169+
_cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
170+
_headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
171+
_timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")
172+
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")
173+
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
174+
_httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
175175
_client: Optional[httpx.Client] = field(default=None, init=False)
176176
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
177177

guardrails-api-client/guardrails_api_client/models/schema_element.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SchemaElement:
1717
"""
1818
Attributes:
1919
type (str):
20-
name (str):
20+
name (Union[Unset, str]):
2121
description (Union[Unset, str]):
2222
strict (Union[Unset, bool]):
2323
date_format (Union[Unset, str]):
@@ -28,7 +28,7 @@ class SchemaElement:
2828
"""
2929

3030
type: str
31-
name: str
31+
name: Union[Unset, str] = UNSET
3232
description: Union[Unset, str] = UNSET
3333
strict: Union[Unset, bool] = UNSET
3434
date_format: Union[Unset, str] = UNSET
@@ -67,9 +67,10 @@ def to_dict(self) -> Dict[str, Any]:
6767
field_dict.update(
6868
{
6969
"type": type,
70-
"name": name,
7170
}
7271
)
72+
if name is not UNSET:
73+
field_dict["name"] = name
7374
if description is not UNSET:
7475
field_dict["description"] = description
7576
if strict is not UNSET:
@@ -94,7 +95,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
9495
d = src_dict.copy()
9596
type = d.pop("type")
9697

97-
name = d.pop("name")
98+
name = d.pop("name", UNSET)
9899

99100
description = d.pop("description", UNSET)
100101

guardrails-api-client/guardrails_api_client/models/validation_output.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
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.any_object import AnyObject
910
from ..models.history import History
1011

1112

@@ -17,21 +18,29 @@ class ValidationOutput:
1718
"""
1819
Attributes:
1920
result (bool): Whether the validation passed or failed
20-
validated_output (Union[Unset, str]):
21+
validated_output (Union['AnyObject', Unset, str]):
2122
session_history (Union[Unset, List['History']]):
2223
raw_llm_response (Union[Unset, str]):
2324
"""
2425

2526
result: bool
26-
validated_output: Union[Unset, str] = UNSET
27+
validated_output: Union["AnyObject", Unset, str] = UNSET
2728
session_history: Union[Unset, List["History"]] = UNSET
2829
raw_llm_response: Union[Unset, str] = UNSET
2930
additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict)
3031

3132
def to_dict(self) -> Dict[str, Any]:
33+
from ..models.any_object import AnyObject
34+
3235
result = self.result
3336

34-
validated_output = self.validated_output
37+
validated_output: Union[Dict[str, Any], Unset, str]
38+
if isinstance(self.validated_output, Unset):
39+
validated_output = UNSET
40+
elif isinstance(self.validated_output, AnyObject):
41+
validated_output = self.validated_output.to_dict()
42+
else:
43+
validated_output = self.validated_output
3544

3645
session_history: Union[Unset, List[Dict[str, Any]]] = UNSET
3746
if not isinstance(self.session_history, Unset):
@@ -60,12 +69,26 @@ def to_dict(self) -> Dict[str, Any]:
6069

6170
@classmethod
6271
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
72+
from ..models.any_object import AnyObject
6373
from ..models.history import History
6474

6575
d = src_dict.copy()
6676
result = d.pop("result")
6777

68-
validated_output = d.pop("validatedOutput", UNSET)
78+
def _parse_validated_output(data: object) -> Union["AnyObject", Unset, str]:
79+
if isinstance(data, Unset):
80+
return data
81+
try:
82+
if not isinstance(data, dict):
83+
raise TypeError()
84+
validated_output_type_0 = AnyObject.from_dict(data)
85+
86+
return validated_output_type_0
87+
except: # noqa: E722
88+
pass
89+
return cast(Union["AnyObject", Unset, str], data)
90+
91+
validated_output = _parse_validated_output(d.pop("validatedOutput", UNSET))
6992

7093
session_history = []
7194
_session_history = d.pop("sessionHistory", UNSET)

open-api-spec.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,6 @@ components:
656656
model:
657657
type: string
658658
required:
659-
- name
660659
- type
661660
OnFail:
662661
type: object
@@ -678,7 +677,9 @@ components:
678677
type: boolean
679678
description: Whether the validation passed or failed
680679
validatedOutput:
681-
type: string
680+
oneOf:
681+
- $ref: "#/components/schemas/AnyObject"
682+
- type: string
682683
sessionHistory:
683684
type: array
684685
items:

service-specs/guardrails-service-spec.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ components:
358358
model:
359359
type: string
360360
required:
361-
- name
362361
- type
363362
OnFail:
364363
type: object
@@ -388,7 +387,9 @@ components:
388387
type: boolean
389388
description: Whether the validation passed or failed
390389
validatedOutput:
391-
type: string
390+
oneOf:
391+
- $ref: "#/components/schemas/AnyObject"
392+
- type: string
392393
sessionHistory:
393394
type: array
394395
items:

0 commit comments

Comments
 (0)