From a6fca53b51f07f8429ee205702faa2f6deb15620 Mon Sep 17 00:00:00 2001 From: Kumi Date: Wed, 29 Nov 2023 11:33:24 +0100 Subject: [PATCH] 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. --- src/gptbot/tools/wikipedia.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gptbot/tools/wikipedia.py b/src/gptbot/tools/wikipedia.py index ae4b266..0d2aef7 100644 --- a/src/gptbot/tools/wikipedia.py +++ b/src/gptbot/tools/wikipedia.py @@ -57,6 +57,6 @@ class Wikipedia(BaseTool): elif 'revisions' in page: return f"**{page['title']}**\n{page['revisions'][0]['*']}" else: - raise Exception('No results found.') + raise Exception(f'No results for {query} found in Wikipedia.') else: raise Exception(f'Could not connect to Wikipedia API: {response.status} {response.reason}') \ No newline at end of file