Fix incorrect wikipage summaries (#2169)

Creating a page using the title causes a wikipedia search with
autocomplete set to true. This frequently causes the summaries to be
unrelated to the actual page found.

See:
1554943e8a/wikipedia/wikipedia.py (L254-L280)
This commit is contained in:
Rui Ferreira 2023-03-30 06:13:03 +01:00 committed by GitHub
parent 6be67279fb
commit f83c36d8fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,7 +47,7 @@ class WikipediaAPIWrapper(BaseModel):
def fetch_formatted_page_summary(self, page: str) -> Optional[str]: def fetch_formatted_page_summary(self, page: str) -> Optional[str]:
try: try:
wiki_page = self.wiki_client.page(title=page) wiki_page = self.wiki_client.page(pageid=page)
return f"Page: {page}\nSummary: {wiki_page.summary}" return f"Page: {page}\nSummary: {wiki_page.summary}"
except ( except (
self.wiki_client.exceptions.PageError, self.wiki_client.exceptions.PageError,