mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
Harrison/error zero tools (#6340)
Co-authored-by: Juhee Kim <46583939+juppytt@users.noreply.github.com>
This commit is contained in:
parent
eef62bf4e9
commit
42a28ac1ba
@ -124,6 +124,10 @@ class ZeroShotAgent(Agent):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def _validate_tools(cls, tools: Sequence[BaseTool]) -> None:
|
def _validate_tools(cls, tools: Sequence[BaseTool]) -> None:
|
||||||
validate_tools_single_input(cls.__name__, tools)
|
validate_tools_single_input(cls.__name__, tools)
|
||||||
|
if len(tools) == 0:
|
||||||
|
raise ValueError(
|
||||||
|
f"Got no tools for {cls.__name__}. At least one tool must be provided."
|
||||||
|
)
|
||||||
for tool in tools:
|
for tool in tools:
|
||||||
if tool.description is None:
|
if tool.description is None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
@ -3,12 +3,19 @@ from tempfile import TemporaryDirectory
|
|||||||
|
|
||||||
from langchain.agents.agent_types import AgentType
|
from langchain.agents.agent_types import AgentType
|
||||||
from langchain.agents.initialize import initialize_agent, load_agent
|
from langchain.agents.initialize import initialize_agent, load_agent
|
||||||
|
from langchain.agents.tools import Tool
|
||||||
from langchain.llms.fake import FakeListLLM
|
from langchain.llms.fake import FakeListLLM
|
||||||
|
|
||||||
|
|
||||||
def test_mrkl_serialization() -> None:
|
def test_mrkl_serialization() -> None:
|
||||||
agent = initialize_agent(
|
agent = initialize_agent(
|
||||||
[],
|
[
|
||||||
|
Tool(
|
||||||
|
name="Test tool",
|
||||||
|
func=lambda x: x,
|
||||||
|
description="Test description",
|
||||||
|
)
|
||||||
|
],
|
||||||
FakeListLLM(responses=[]),
|
FakeListLLM(responses=[]),
|
||||||
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
|
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
Loading…
Reference in New Issue
Block a user