1- from typing import TYPE_CHECKING , Any , Dict , List , Type , TypeVar , Union
1+ from typing import TYPE_CHECKING , Any , Dict , List , Literal , Type , TypeVar , Union , cast
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
76from ..types import UNSET , Unset
87
98if TYPE_CHECKING :
@@ -21,13 +20,26 @@ class ValidatePayload:
2120 output.
2221 num_reasks (Union[Unset, int]): An override for the number of re-asks to perform
2322 prompt_params (Union[Unset, ValidatePayloadPromptParams]): additional params for llm prompts
24- llm_api (Union[Unset, ValidatePayloadLlmApi]):
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]):
2527 """
2628
2729 llm_output : Union [Unset , str ] = UNSET
2830 num_reasks : Union [Unset , int ] = UNSET
2931 prompt_params : Union [Unset , "ValidatePayloadPromptParams" ] = UNSET
30- llm_api : Union [Unset , ValidatePayloadLlmApi ] = 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
3143 additional_properties : Dict [str , Any ] = _attrs_field (init = False , factory = dict )
3244
3345 def to_dict (self ) -> Dict [str , Any ]:
@@ -39,9 +51,21 @@ def to_dict(self) -> Dict[str, Any]:
3951 if not isinstance (self .prompt_params , Unset ):
4052 prompt_params = self .prompt_params .to_dict ()
4153
42- llm_api : Union [Unset , str ] = UNSET
43- if not isinstance (self .llm_api , Unset ):
44- llm_api = self .llm_api .value
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
4569
4670 field_dict : Dict [str , Any ] = {}
4771 field_dict .update (self .additional_properties )
@@ -73,12 +97,37 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
7397 else :
7498 prompt_params = ValidatePayloadPromptParams .from_dict (_prompt_params )
7599
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 )
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 ))
82131
83132 validate_payload = cls (
84133 llm_output = llm_output ,
0 commit comments