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
2
2
3
3
from attrs import define as _attrs_define
4
4
from attrs import field as _attrs_field
5
5
6
- from ..models .validate_payload_llm_api import ValidatePayloadLlmApi
7
6
from ..types import UNSET , Unset
8
7
9
8
if TYPE_CHECKING :
@@ -21,13 +20,26 @@ class ValidatePayload:
21
20
output.
22
21
num_reasks (Union[Unset, int]): An override for the number of re-asks to perform
23
22
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]):
25
27
"""
26
28
27
29
llm_output : Union [Unset , str ] = UNSET
28
30
num_reasks : Union [Unset , int ] = UNSET
29
31
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
31
43
additional_properties : Dict [str , Any ] = _attrs_field (init = False , factory = dict )
32
44
33
45
def to_dict (self ) -> Dict [str , Any ]:
@@ -39,9 +51,21 @@ def to_dict(self) -> Dict[str, Any]:
39
51
if not isinstance (self .prompt_params , Unset ):
40
52
prompt_params = self .prompt_params .to_dict ()
41
53
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
45
69
46
70
field_dict : Dict [str , Any ] = {}
47
71
field_dict .update (self .additional_properties )
@@ -73,12 +97,37 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
73
97
else :
74
98
prompt_params = ValidatePayloadPromptParams .from_dict (_prompt_params )
75
99
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 ))
82
131
83
132
validate_payload = cls (
84
133
llm_output = llm_output ,
0 commit comments