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
33from attrs import define as _attrs_define
44from attrs import field as _attrs_field
55
6+ from ..models .validate_payload_llm_api import ValidatePayloadLlmApi
67from ..types import UNSET , Unset
78
89if 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 ,
0 commit comments