mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-09 06:53:59 +00:00
Harrison/return intermediate (#1633)
Co-authored-by: Mario Kostelac <mario@intercom.io>
This commit is contained in:
@@ -230,6 +230,36 @@ def test_agent_tool_return_direct() -> None:
|
||||
assert output == "misalignment"
|
||||
|
||||
|
||||
def test_agent_tool_return_direct_in_intermediate_steps() -> None:
|
||||
"""Test agent using tools that return directly."""
|
||||
tool = "Search"
|
||||
responses = [
|
||||
f"FooBarBaz\nAction: {tool}\nAction Input: misalignment",
|
||||
"Oh well\nAction: Final Answer\nAction Input: curses foiled again",
|
||||
]
|
||||
fake_llm = FakeListLLM(responses=responses)
|
||||
tools = [
|
||||
Tool(
|
||||
name="Search",
|
||||
func=lambda x: x,
|
||||
description="Useful for searching",
|
||||
return_direct=True,
|
||||
),
|
||||
]
|
||||
agent = initialize_agent(
|
||||
tools,
|
||||
fake_llm,
|
||||
agent="zero-shot-react-description",
|
||||
return_intermediate_steps=True,
|
||||
)
|
||||
|
||||
resp = agent("when was langchain made")
|
||||
assert resp["output"] == "misalignment"
|
||||
assert len(resp["intermediate_steps"]) == 1
|
||||
action, _action_intput = resp["intermediate_steps"][0]
|
||||
assert action.tool == "Search"
|
||||
|
||||
|
||||
def test_agent_with_new_prefix_suffix() -> None:
|
||||
"""Test agent initilization kwargs with new prefix and suffix."""
|
||||
fake_llm = FakeListLLM(
|
||||
|
Reference in New Issue
Block a user