File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
patchwork/steps/CallOpenAI Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ def __init__(self, inputs: dict):
2727 raise ValueError (f'Missing required data: "{ self .required_keys } "' )
2828
2929 self .model = inputs ["model" ]
30+ self .allow_trunctated = inputs .get ("allow_truncated" , False )
3031 self .model_args = {key [len ("model_" ) :]: value for key , value in inputs .items () if key .startswith ("model_" )}
3132 self .client_args = {key [len ("client_" ) :]: value for key , value in inputs .items () if key .startswith ("client_" )}
3233
@@ -81,8 +82,11 @@ def run(self) -> dict:
8182 logger .error (f"No response choice given" )
8283 contents .append ("" )
8384 elif completion .choices [0 ].finish_reason == "length" :
84- logger .error (f"Response truncated because of finish reason = length" )
85- contents .append ("" )
85+ if self .allow_trunctated :
86+ contents .append (completion .choices [0 ].message .content )
87+ else :
88+ logger .error (f"Response truncated because of finish reason = length. Use --allow_truncated option to process truncated responses." )
89+ contents .append ("" )
8690 else :
8791 logger .debug (f"Response received: \n { indent (completion .choices [0 ].message .content , ' ' )} " )
8892 contents .append (completion .choices [0 ].message .content )
You can’t perform that action at this time.
0 commit comments