Skip to content

Commit 263c0f1

Browse files
committed
update generated sdk
1 parent f1e6774 commit 263c0f1

File tree

4 files changed

+32
-90
lines changed

4 files changed

+32
-90
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from .schema_element import SchemaElement
3434
from .status import Status
3535
from .validate_payload import ValidatePayload
36+
from .validate_payload_llm_api import ValidatePayloadLlmApi
3637
from .validate_payload_prompt_params import ValidatePayloadPromptParams
3738
from .validation_output import ValidationOutput
3839
from .validator_metrics import ValidatorMetrics
@@ -74,6 +75,7 @@
7475
"SchemaElement",
7576
"Status",
7677
"ValidatePayload",
78+
"ValidatePayloadLlmApi",
7779
"ValidatePayloadPromptParams",
7880
"ValidationOutput",
7981
"ValidatorMetrics",

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

Lines changed: 13 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Type, TypeVar, Union, cast
1+
from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union
22

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

6+
from ..models.validate_payload_llm_api import ValidatePayloadLlmApi
67
from ..types import UNSET, Unset
78

89
if TYPE_CHECKING:
@@ -20,26 +21,13 @@ class ValidatePayload:
2021
output.
2122
num_reasks (Union[Unset, int]): An override for the number of re-asks to perform
2223
prompt_params (Union[Unset, ValidatePayloadPromptParams]): additional params for llm prompts
23-
llm_api (Union[Literal['litellm.acompletion'], Literal['litellm.completion'],
24-
Literal['openai.ChatCompletion.acreate'], Literal['openai.ChatCompletion.create'],
25-
Literal['openai.Completion.acreate'], Literal['openai.Completion.create'],
26-
Literal['openai.chat.completions.create'], Literal['openai.completions.create'], Unset]):
24+
llm_api (Union[Unset, ValidatePayloadLlmApi]):
2725
"""
2826

2927
llm_output: Union[Unset, str] = UNSET
3028
num_reasks: Union[Unset, int] = UNSET
3129
prompt_params: Union[Unset, "ValidatePayloadPromptParams"] = UNSET
32-
llm_api: Union[
33-
Literal["litellm.acompletion"],
34-
Literal["litellm.completion"],
35-
Literal["openai.ChatCompletion.acreate"],
36-
Literal["openai.ChatCompletion.create"],
37-
Literal["openai.Completion.acreate"],
38-
Literal["openai.Completion.create"],
39-
Literal["openai.chat.completions.create"],
40-
Literal["openai.completions.create"],
41-
Unset,
42-
] = UNSET
30+
llm_api: Union[Unset, ValidatePayloadLlmApi] = UNSET
4331
additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict)
4432

4533
def to_dict(self) -> Dict[str, Any]:
@@ -51,21 +39,9 @@ def to_dict(self) -> Dict[str, Any]:
5139
if not isinstance(self.prompt_params, Unset):
5240
prompt_params = self.prompt_params.to_dict()
5341

54-
llm_api: Union[
55-
Literal["litellm.acompletion"],
56-
Literal["litellm.completion"],
57-
Literal["openai.ChatCompletion.acreate"],
58-
Literal["openai.ChatCompletion.create"],
59-
Literal["openai.Completion.acreate"],
60-
Literal["openai.Completion.create"],
61-
Literal["openai.chat.completions.create"],
62-
Literal["openai.completions.create"],
63-
Unset,
64-
]
65-
if isinstance(self.llm_api, Unset):
66-
llm_api = UNSET
67-
else:
68-
llm_api = self.llm_api
42+
llm_api: Union[Unset, str] = UNSET
43+
if not isinstance(self.llm_api, Unset):
44+
llm_api = self.llm_api.value
6945

7046
field_dict: Dict[str, Any] = {}
7147
field_dict.update(self.additional_properties)
@@ -97,37 +73,12 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
9773
else:
9874
prompt_params = ValidatePayloadPromptParams.from_dict(_prompt_params)
9975

100-
def _parse_llm_api(
101-
data: object,
102-
) -> Union[
103-
Literal["litellm.acompletion"],
104-
Literal["litellm.completion"],
105-
Literal["openai.ChatCompletion.acreate"],
106-
Literal["openai.ChatCompletion.create"],
107-
Literal["openai.Completion.acreate"],
108-
Literal["openai.Completion.create"],
109-
Literal["openai.chat.completions.create"],
110-
Literal["openai.completions.create"],
111-
Unset,
112-
]:
113-
if isinstance(data, Unset):
114-
return data
115-
return cast(
116-
Union[
117-
Literal["litellm.acompletion"],
118-
Literal["litellm.completion"],
119-
Literal["openai.ChatCompletion.acreate"],
120-
Literal["openai.ChatCompletion.create"],
121-
Literal["openai.Completion.acreate"],
122-
Literal["openai.Completion.create"],
123-
Literal["openai.chat.completions.create"],
124-
Literal["openai.completions.create"],
125-
Unset,
126-
],
127-
data,
128-
)
129-
130-
llm_api = _parse_llm_api(d.pop("llmApi", UNSET))
76+
_llm_api = d.pop("llmApi", UNSET)
77+
llm_api: Union[Unset, ValidatePayloadLlmApi]
78+
if isinstance(_llm_api, Unset):
79+
llm_api = UNSET
80+
else:
81+
llm_api = ValidatePayloadLlmApi(_llm_api)
13182

13283
validate_payload = cls(
13384
llm_output=llm_output,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from enum import Enum
2+
3+
4+
class ValidatePayloadLlmApi(str, Enum):
5+
LITELLM_ACOMPLETION = "litellm.acompletion"
6+
LITELLM_COMPLETION = "litellm.completion"
7+
OPENAI_CHATCOMPLETION_ACREATE = "openai.ChatCompletion.acreate"
8+
OPENAI_CHATCOMPLETION_CREATE = "openai.ChatCompletion.create"
9+
OPENAI_CHAT_COMPLETIONS_CREATE = "openai.chat.completions.create"
10+
OPENAI_COMPLETIONS_CREATE = "openai.completions.create"
11+
OPENAI_COMPLETION_ACREATE = "openai.Completion.acreate"
12+
OPENAI_COMPLETION_CREATE = "openai.Completion.create"
13+
14+
def __str__(self) -> str:
15+
return str(self.value)

open-api-spec.yml

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -763,33 +763,6 @@ components:
763763
oneOf:
764764
- $ref: "#/components/schemas/AnyObject"
765765
- $ref: "#/components/schemas/AnyPrimitive"
766-
LlmApi:
767-
type: string
768-
oneOf:
769-
- title: OPENAI_V0_COMPLETION_CREATE
770-
const: openai.Completion.create
771-
description: OpenAI V0 Completion Create
772-
- title: OPENAI_V1_COMPLETIONS_CREATE
773-
const: openai.completions.create
774-
description: OpenAI V1 Completions Create
775-
- title: OPENAI_V0_CHAT_COMPLETION_CREATE
776-
const: openai.ChatCompletion.create
777-
description: OpenAI V0 Chat Completion Create
778-
- title: OPENAI_V1_CHAT_COMPLETION_CREATE
779-
const: openai.chat.completions.create
780-
description: OpenAI V1 Chat Completions Create
781-
- title: OPENAI_V0_COMPLETION_ASYNC_CREATE
782-
const: openai.Completion.acreate
783-
description: OpenAI V0 Completion Async Create
784-
- title: OPENAI_V0_CHAT_COMPLETION_ASYNC_CREATE
785-
const: openai.ChatCompletion.acreate
786-
description: OpenAI V0 Chat Completion Async Create
787-
- title: LITELLM_COMPLETION
788-
const: litellm.completion
789-
description: LiteLLM Completion
790-
- title: LITELLM_ASYNC_COMPLETION
791-
const: litellm.acompletion
792-
description: LiteLLM Async Completion
793766
ValidatePayload:
794767
type: object
795768
properties:
@@ -806,7 +779,8 @@ components:
806779
properties: {}
807780
additionalProperties: {}
808781
llmApi:
809-
$ref: "#/components/schemas/LlmApi"
782+
type: string
783+
enum: ["openai.Completion.create", "openai.completions.create", "openai.ChatCompletion.create", "openai.chat.completions.create", "openai.Completion.acreate", "openai.ChatCompletion.acreate", "litellm.completion", "litellm.acompletion"]
810784
additionalProperties: {}
811785
Ingestion:
812786
type: object

0 commit comments

Comments
 (0)