Improve Wikipedia error messages
Refined the exception details in the Wikipedia tool to include the search query when no results are found, enhancing the clarity of error outputs for end-users. This change helps in debugging by indicating the exact query that led to a no-results situation. Additionally, the existing failure-to-connect error message was left as-is, maintaining accurate API connectivity diagnostics.
This commit is contained in:
parent
c92828def1
commit
a6fca53b51
1 changed files with 1 additions and 1 deletions
|
@ -57,6 +57,6 @@ class Wikipedia(BaseTool):
|
||||||
elif 'revisions' in page:
|
elif 'revisions' in page:
|
||||||
return f"**{page['title']}**\n{page['revisions'][0]['*']}"
|
return f"**{page['title']}**\n{page['revisions'][0]['*']}"
|
||||||
else:
|
else:
|
||||||
raise Exception('No results found.')
|
raise Exception(f'No results for {query} found in Wikipedia.')
|
||||||
else:
|
else:
|
||||||
raise Exception(f'Could not connect to Wikipedia API: {response.status} {response.reason}')
|
raise Exception(f'Could not connect to Wikipedia API: {response.status} {response.reason}')
|
Loading…
Reference in a new issue