File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -189,8 +189,14 @@ def rename_variable(self, response: str) -> None:
189189 raise TypeError ('No instruction was saved in the Agent instance.' )
190190 if response is None or response == '' :
191191 raise TypeError (f'No response was returned from OpenAI; got type { type (response )} .' )
192- # Get just one word from the response.
193- response = response .split ()[0 ]
192+ # Get just one word from the response. Remove spaces and quotes.
193+ try :
194+ response = response .split ()[0 ]
195+ response = response .replace (' ' , '' )
196+ response = response .replace ('"' , '' )
197+ response = response .replace ('\' ' , '' )
198+ except IndexError as error :
199+ raise IndexError (f'Could not split the response: `{ response } `.' ) from error
194200 # Assign the variable name to the response.
195201 log .log_debug (f'Renaming variable in expression { self .instruction } to { response } .' )
196202 self .instruction .dest .name = response
You can’t perform that action at this time.
0 commit comments