2022-10-27 04:02:23 +00:00
|
|
|
"""Integration test for self ask with search."""
|
|
|
|
|
|
|
|
from langchain.chains.react.base import ReActChain
|
2022-11-01 04:18:52 +00:00
|
|
|
from langchain.docstore.wikipedia import Wikipedia
|
2022-10-27 04:02:23 +00:00
|
|
|
from langchain.llms.openai import OpenAI
|
|
|
|
|
|
|
|
|
|
|
|
def test_react() -> None:
|
|
|
|
"""Test functionality on a prompt."""
|
|
|
|
llm = OpenAI(temperature=0)
|
2022-11-01 04:18:52 +00:00
|
|
|
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?"
|
|
|
|
)
|
2022-10-27 04:02:23 +00:00
|
|
|
output = react.run(question)
|
2022-11-01 04:18:52 +00:00
|
|
|
assert output == "Bill Clinton"
|