consolidate run functions (#126)

consolidating logic for when a chain is able to run with single input
text, single output text

open to feedback on naming, logic, usefulness
This commit is contained in:
Harrison Chase
2022-11-13 18:14:35 -08:00
committed by GitHub
parent 1fe3a4f724
commit f23b3ceb49
20 changed files with 39 additions and 143 deletions

View File

@@ -22,7 +22,7 @@ class FakeChain(Chain, BaseModel):
"""Output key of bar."""
return ["bar"]
def _run(self, inputs: Dict[str, str]) -> Dict[str, str]:
def _call(self, inputs: Dict[str, str]) -> Dict[str, str]:
if self.be_correct:
return {"bar": "baz"}
else:

View File

@@ -26,7 +26,7 @@ def test_proper_inputs() -> None:
nat_bot_chain = NatBotChain(llm=FakeLLM(), objective="testing")
url = "foo" * 10000
browser_content = "foo" * 10000
output = nat_bot_chain.run(url, browser_content)
output = nat_bot_chain.execute(url, browser_content)
assert output == "bar"
@@ -39,5 +39,5 @@ def test_variable_key_naming() -> None:
input_browser_content_key="b",
output_key="c",
)
output = nat_bot_chain.run("foo", "foo")
output = nat_bot_chain.execute("foo", "foo")
assert output == "bar"

View File

@@ -92,18 +92,6 @@ def test_react_chain() -> None:
inputs = {"question": "when was langchain made"}
output = react_chain(inputs)
assert output["answer"] == "2022"
expected_full_output = (
"when was langchain made\n"
"Thought 1:I should probably search\n"
"Action 1: Search[langchain]\n"
"Observation 1: This is a page about LangChain.\n"
"Thought 2:I should probably lookup\n"
"Action 2: Lookup[made]\n"
"Observation 2: (Result 1/1) Made in 2022.\n"
"Thought 3:Ah okay now I know the answer\n"
"Action 3: Finish[2022]"
)
assert output["full_logic"] == expected_full_output
def test_react_chain_bad_action() -> None: