Skip to content

Commit 6c309b6

Browse files
Allow fine tune hyperparams non-string values (#136)
1 parent dbc97a7 commit 6c309b6

File tree

4 files changed

+261
-116
lines changed

4 files changed

+261
-116
lines changed

launch/api_client/model/create_fine_tune_request.py

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,74 @@ class MetaOapg:
4040
class properties:
4141
class hyperparameters(schemas.DictSchema):
4242
class MetaOapg:
43-
additional_properties = schemas.StrSchema
43+
class additional_properties(
44+
schemas.ComposedSchema,
45+
):
46+
class MetaOapg:
47+
any_of_0 = schemas.StrSchema
48+
any_of_1 = schemas.IntSchema
49+
any_of_2 = schemas.NumberSchema
50+
51+
@classmethod
52+
@functools.lru_cache()
53+
def any_of(cls):
54+
# we need this here to make our import statements work
55+
# we must store _composed_schemas in here so the code is only run
56+
# when we invoke this method. If we kept this at the class
57+
# level we would get an error because the class level
58+
# code would be run when this module is imported, and these composed
59+
# classes don't exist yet because their module has not finished
60+
# loading
61+
return [
62+
cls.any_of_0,
63+
cls.any_of_1,
64+
cls.any_of_2,
65+
]
66+
67+
def __new__(
68+
cls,
69+
*_args: typing.Union[
70+
dict,
71+
frozendict.frozendict,
72+
str,
73+
date,
74+
datetime,
75+
uuid.UUID,
76+
int,
77+
float,
78+
decimal.Decimal,
79+
bool,
80+
None,
81+
list,
82+
tuple,
83+
bytes,
84+
io.FileIO,
85+
io.BufferedReader,
86+
],
87+
_configuration: typing.Optional[schemas.Configuration] = None,
88+
**kwargs: typing.Union[
89+
schemas.AnyTypeSchema,
90+
dict,
91+
frozendict.frozendict,
92+
str,
93+
date,
94+
datetime,
95+
uuid.UUID,
96+
int,
97+
float,
98+
decimal.Decimal,
99+
None,
100+
list,
101+
tuple,
102+
bytes,
103+
],
104+
) -> "additional_properties":
105+
return super().__new__(
106+
cls,
107+
*_args,
108+
_configuration=_configuration,
109+
**kwargs,
110+
)
44111

45112
def __getitem__(
46113
self,
@@ -64,7 +131,22 @@ def __new__(
64131
_configuration: typing.Optional[schemas.Configuration] = None,
65132
**kwargs: typing.Union[
66133
MetaOapg.additional_properties,
134+
dict,
135+
frozendict.frozendict,
67136
str,
137+
date,
138+
datetime,
139+
uuid.UUID,
140+
int,
141+
float,
142+
decimal.Decimal,
143+
bool,
144+
None,
145+
list,
146+
tuple,
147+
bytes,
148+
io.FileIO,
149+
io.BufferedReader,
68150
],
69151
) -> "hyperparameters":
70152
return super().__new__(

launch/api_client/model/create_fine_tune_request.pyi

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,73 @@ class CreateFineTuneRequest(schemas.DictSchema):
3838
class properties:
3939
class hyperparameters(schemas.DictSchema):
4040
class MetaOapg:
41-
additional_properties = schemas.StrSchema
41+
class additional_properties(
42+
schemas.ComposedSchema,
43+
):
44+
class MetaOapg:
45+
any_of_0 = schemas.StrSchema
46+
any_of_1 = schemas.IntSchema
47+
any_of_2 = schemas.NumberSchema
48+
49+
@classmethod
50+
@functools.lru_cache()
51+
def any_of(cls):
52+
# we need this here to make our import statements work
53+
# we must store _composed_schemas in here so the code is only run
54+
# when we invoke this method. If we kept this at the class
55+
# level we would get an error because the class level
56+
# code would be run when this module is imported, and these composed
57+
# classes don't exist yet because their module has not finished
58+
# loading
59+
return [
60+
cls.any_of_0,
61+
cls.any_of_1,
62+
cls.any_of_2,
63+
]
64+
def __new__(
65+
cls,
66+
*_args: typing.Union[
67+
dict,
68+
frozendict.frozendict,
69+
str,
70+
date,
71+
datetime,
72+
uuid.UUID,
73+
int,
74+
float,
75+
decimal.Decimal,
76+
bool,
77+
None,
78+
list,
79+
tuple,
80+
bytes,
81+
io.FileIO,
82+
io.BufferedReader,
83+
],
84+
_configuration: typing.Optional[schemas.Configuration] = None,
85+
**kwargs: typing.Union[
86+
schemas.AnyTypeSchema,
87+
dict,
88+
frozendict.frozendict,
89+
str,
90+
date,
91+
datetime,
92+
uuid.UUID,
93+
int,
94+
float,
95+
decimal.Decimal,
96+
None,
97+
list,
98+
tuple,
99+
bytes,
100+
],
101+
) -> "additional_properties":
102+
return super().__new__(
103+
cls,
104+
*_args,
105+
_configuration=_configuration,
106+
**kwargs,
107+
)
42108
def __getitem__(
43109
self,
44110
name: typing.Union[str,],
@@ -59,7 +125,22 @@ class CreateFineTuneRequest(schemas.DictSchema):
59125
_configuration: typing.Optional[schemas.Configuration] = None,
60126
**kwargs: typing.Union[
61127
MetaOapg.additional_properties,
128+
dict,
129+
frozendict.frozendict,
62130
str,
131+
date,
132+
datetime,
133+
uuid.UUID,
134+
int,
135+
float,
136+
decimal.Decimal,
137+
bool,
138+
None,
139+
list,
140+
tuple,
141+
bytes,
142+
io.FileIO,
143+
io.BufferedReader,
63144
],
64145
) -> "hyperparameters":
65146
return super().__new__(

0 commit comments

Comments
 (0)