@@ -874,8 +874,18 @@ def save_image_to_cache(base64_data, filename, image_info, ignore_info=False):
874874async def response_json (response ):
875875 text = await response .text ()
876876 if response .status >= 400 :
877- _dbg (f"HTTP { response .status } { response .reason } : { text } " )
878- raise HTTPError (response .status , reason = response .reason , body = text , headers = dict (response .headers ))
877+ message = "HTTP " + str (response .status ) + " " + response .reason
878+ _dbg (f"HTTP { response .status } { response .reason } \n { dict (response .headers )} \n { text } " )
879+ try :
880+ body = json .loads (text )
881+ if "message" in body :
882+ message = body ["message" ]
883+ elif "error" in body :
884+ message = body ["error" ]
885+ except Exception :
886+ if text :
887+ message += ": " + text [:100 ]
888+ raise Exception (message )
879889 response .raise_for_status ()
880890 body = json .loads (text )
881891 return body
@@ -1946,12 +1956,11 @@ async def g_chat_completion(chat, context=None):
19461956 first_exception = e
19471957 context ["stackTrace" ] = traceback .format_exc ()
19481958 _err (f"Provider { provider_name } failed" , first_exception )
1949- await g_app .on_chat_error (e , context )
1950-
19511959 continue
19521960
19531961 # If we get here, all providers failed
19541962 if first_exception :
1963+ await g_app .on_chat_error (first_exception , context or {"chat" : chat })
19551964 raise first_exception
19561965
19571966 e = Exception ("All providers failed" )
@@ -3871,9 +3880,9 @@ async def update_extensions(extension_name):
38713880 asyncio .run (update_extensions (cli_args .update ))
38723881 return ExitCode .SUCCESS
38733882
3883+ g_app .add_allowed_directory (tempfile .gettempdir ()) # add temp directory
38743884 g_app .add_allowed_directory (home_llms_path (".agent" )) # info for agents, e.g: skills
38753885 g_app .add_allowed_directory (os .getcwd ()) # add current directory
3876- g_app .add_allowed_directory (tempfile .gettempdir ()) # add temp directory
38773886
38783887 g_app .extensions = install_extensions ()
38793888
0 commit comments