2222
2323logger = logging .getLogger (__name__ )
2424
25- ERROR_MESSAGE_ON_JSON_ADAPTER_FAILURE = (
26- "Both structured output format and JSON mode failed. Please choose a model that supports "
27- "`response_format` argument. Original error: {}"
28- )
29-
3025
3126def _has_open_ended_mapping (signature : SignatureMeta ) -> bool :
3227 """
@@ -72,13 +67,8 @@ def __call__(
7267 return super ().__call__ (lm , lm_kwargs , signature , demos , inputs )
7368 except Exception :
7469 logger .warning ("Failed to use structured output format, falling back to JSON mode." )
75- try :
76- lm_kwargs ["response_format" ] = {"type" : "json_object" }
77- return super ().__call__ (lm , lm_kwargs , signature , demos , inputs )
78- except AdapterParseError as e :
79- raise e
80- except Exception as e :
81- raise RuntimeError (ERROR_MESSAGE_ON_JSON_ADAPTER_FAILURE .format (e )) from e
70+ lm_kwargs ["response_format" ] = {"type" : "json_object" }
71+ return super ().__call__ (lm , lm_kwargs , signature , demos , inputs )
8272
8373 async def acall (
8474 self ,
@@ -98,13 +88,8 @@ async def acall(
9888 return await super ().acall (lm , lm_kwargs , signature , demos , inputs )
9989 except Exception :
10090 logger .warning ("Failed to use structured output format, falling back to JSON mode." )
101- try :
102- lm_kwargs ["response_format" ] = {"type" : "json_object" }
103- return await super ().acall (lm , lm_kwargs , signature , demos , inputs )
104- except AdapterParseError as e :
105- raise e
106- except Exception as e :
107- raise RuntimeError (ERROR_MESSAGE_ON_JSON_ADAPTER_FAILURE .format (e )) from e
91+ lm_kwargs ["response_format" ] = {"type" : "json_object" }
92+ return await super ().acall (lm , lm_kwargs , signature , demos , inputs )
10893
10994 def _call_preprocess (
11095 self ,
0 commit comments