mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-08 22:42:05 +00:00
@@ -1,13 +1,18 @@
|
||||
"""Integration test for self ask with search."""
|
||||
|
||||
from langchain.chains.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."""
|
||||
llm = OpenAI(temperature=0)
|
||||
react = ReActChain(llm=llm)
|
||||
question = "Were Scott Derrickson and Ed Wood of the same nationality?"
|
||||
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 == "yes"
|
||||
assert output == "Bill Clinton"
|
||||
|
@@ -1,6 +1,6 @@
|
||||
"""Unit tests for ReAct."""
|
||||
|
||||
from typing import List, Optional, Tuple
|
||||
from typing import List, Optional, Union
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -39,10 +39,10 @@ class FakeListLLM(LLM):
|
||||
class FakeDocstore(Docstore):
|
||||
"""Fake docstore for testing purposes."""
|
||||
|
||||
def search(self, search: str) -> Tuple[str, Optional[Document]]:
|
||||
def search(self, search: str) -> Union[str, Document]:
|
||||
"""Return the fake document."""
|
||||
document = Document(page_content=_PAGE_CONTENT)
|
||||
return document.summary, document
|
||||
return document
|
||||
|
||||
|
||||
def test_predict_until_observation_normal() -> None:
|
||||
|
Reference in New Issue
Block a user