mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-16 15:04:13 +00:00
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:
@@ -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:
|
||||
|
@@ -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"
|
||||
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user