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