@@ -181,9 +181,11 @@ def _generate(
181
181
# prepare the payload for a simple ping to the model
182
182
data = {"model" : model , "stream" : stream }
183
183
184
- if "format" in model_parameters :
185
- data ["format" ] = model_parameters ["format" ]
186
- del model_parameters ["format" ]
184
+ if format_schema := model_parameters .pop ("format" , None ):
185
+ try :
186
+ data ["format" ] = format_schema if format_schema == "json" else json .loads (format_schema )
187
+ except json .JSONDecodeError as e :
188
+ raise InvokeBadRequestError (f"Invalid format schema: { str (e )} " )
187
189
188
190
if "keep_alive" in model_parameters :
189
191
data ["keep_alive" ] = model_parameters ["keep_alive" ]
@@ -733,12 +735,12 @@ def get_customizable_model_schema(self, model: str, credentials: dict) -> AIMode
733
735
ParameterRule (
734
736
name = "format" ,
735
737
label = I18nObject (en_US = "Format" , zh_Hans = "返回格式" ),
736
- type = ParameterType .STRING ,
738
+ type = ParameterType .TEXT ,
739
+ default = "json" ,
737
740
help = I18nObject (
738
- en_US = "the format to return a response in. Currently the only accepted value is json ." ,
739
- zh_Hans = "返回响应的格式。目前唯一接受的值是json。 " ,
741
+ en_US = "the format to return a response in. Format can be `json` or a JSON schema ." ,
742
+ zh_Hans = "返回响应的格式。目前接受的值是字符串`json`或JSON schema. " ,
740
743
),
741
- options = ["json" ],
742
744
),
743
745
],
744
746
pricing = PriceConfig (
0 commit comments