mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
19 lines
662 B
Python
19 lines
662 B
Python
"""Integration test for self ask with search."""
|
|
from langchain.agents.self_ask_with_search.base import SelfAskWithSearchChain
|
|
from langchain.llms.openai import OpenAI
|
|
from langchain.serpapi import SerpAPIWrapper
|
|
|
|
|
|
def test_self_ask_with_search() -> None:
|
|
"""Test functionality on a prompt."""
|
|
question = "What is the hometown of the reigning men's U.S. Open champion?"
|
|
chain = SelfAskWithSearchChain(
|
|
llm=OpenAI(temperature=0),
|
|
search_chain=SerpAPIWrapper(),
|
|
input_key="q",
|
|
output_key="a",
|
|
)
|
|
answer = chain.run(question)
|
|
final_answer = answer.split("\n")[-1]
|
|
assert final_answer == "El Palmar, Spain"
|