Last active
April 20, 2023 21:55
-
-
Save idontcalculate/3c810df5f844697558086a675a31a870 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from langchain.llms import OpenAI | |
from langchain.docstore.wikipedia import Wikipedia | |
from langchain.agents.react.base import DocstoreExplorer | |
from langchain.agents import Tool | |
from langchain.agents import initialize_agent | |
docstore = DocstoreExplorer(Wikipedia()) | |
tools = [ | |
Tool( | |
name="Search", | |
func=docstore.search, | |
description='search wikipedia' | |
), | |
Tool( | |
name="Lookup", | |
func=docstore.lookup, | |
description='lookup a term in wikipedia' | |
) | |
] | |
#intializing the agent | |
llm = OpenAI(temperature=0) | |
docstore_agent=initialize_agent( | |
tools, | |
llm, | |
agent="react-docstore", | |
verbose=True, | |
max_iterations=3 | |
) | |
docstore_agent("Why Emperor Napoleon abandoned his plans to invade England?") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment