From 1bc25c331c554e21d048ec975a6a12672d789c6c Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Thu, 5 Oct 2023 12:47:40 +1100 Subject: [PATCH] `e.msg` may also be 'Unterminated string starting at' or other values --- pilot/utils/llm_connection.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pilot/utils/llm_connection.py b/pilot/utils/llm_connection.py index 8f3e19d..16255c2 100644 --- a/pilot/utils/llm_connection.py +++ b/pilot/utils/llm_connection.py @@ -158,10 +158,9 @@ def retry_on_exception(func): # If the specific error "context_length_exceeded" is present, simply return without retry if isinstance(e, json.JSONDecodeError): # codellama-34b-instruct seems to send incomplete JSON responses - if e.msg == 'Expecting value': - logger.info('Received incomplete JSON response from LLM. Asking for the rest...') - args[0]['function_buffer'] = e.doc - continue + logger.info('Received incomplete JSON response from LLM. Asking for the rest...') + args[0]['function_buffer'] = e.doc + continue elif isinstance(e, ValidationError): function_error_count = 1 if 'function_error' not in args[0] else args[0]['function_error_count'] + 1 args[0]['function_error_count'] = function_error_count