chore: skip unnecessary key checks prior to accessing a dictionary (#4497)

This commit is contained in:
Bowen Liang
2024-05-19 18:30:45 +08:00
committed by GitHub
parent aa13d14019
commit 04ad46dd31
30 changed files with 45 additions and 44 deletions

View File

@@ -48,7 +48,7 @@ class WolframAlphaTool(BuiltinTool):
if 'success' not in response_data['queryresult'] or response_data['queryresult']['success'] != True:
query_result = response_data.get('queryresult', {})
if 'error' in query_result and query_result['error']:
if query_result.get('error'):
if 'msg' in query_result['error']:
if query_result['error']['msg'] == 'Invalid appid':
raise ToolProviderCredentialValidationError('Invalid appid')