How to Connect Wikipedia with ChatGPT and LangChain
ChatGPT integration with Wikipedia using LangChain
2 min readAug 11, 2023
ChatGPT’s knowledge is limited to its training data, which has the cutoff year of 2021. This implies that we cannot extract information for cases that have occurred after the cutoff year. However, we can integrate Wikipedia with ChatGPT. We will go straightforward with an example. Our goal is to extract information about Juancho Hernangomez, the new star of Panathinaikos BC.
The wikipedia Python Package
We will need to install the wikipedia
python package by running:
pip install wikipedia
From the wikipedia
package, we will use the WikipediaLoader
that has the following arguments
query
: you query to wikipedia- optional
lang
: the language where the default is "en". - optional load_max_docs: default=100. You specify the number of downloaded documents.
- optional
load_all_available_meta
: default=False. By default only the most important fields downloaded such as the published date of the wikipedia document the title and a summary.