langchain/tests/integration_tests/chains/test_react.py

19 lines
641 B
Python
Raw Normal View History

"""Integration test for self ask with search."""
2022-11-22 14:16:26 +00:00
from langchain.agents.react.base import ReActChain
from langchain.docstore.wikipedia import Wikipedia
from langchain.llms.openai import OpenAI
def test_react() -> None:
"""Test functionality on a prompt."""
2022-12-19 02:51:23 +00:00
llm = OpenAI(temperature=0, model_name="text-davinci-002")
react = ReActChain(llm=llm, docstore=Wikipedia())
question = (
"Author David Chanoff has collaborated with a U.S. Navy admiral "
"who served as the ambassador to the United Kingdom under "
"which President?"
)
output = react.run(question)
assert output == "Bill Clinton"