forked from langchain-ai/langchain
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix breaking tags (langchain-ai#6765)
Fix tags change that broke old way of initializing agent Closes langchain-ai#6756
- Loading branch information
1 parent
fd2b574
commit 4299e9d
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Test the initialize module.""" | ||
|
||
from langchain.agents.agent_types import AgentType | ||
from langchain.agents.initialize import initialize_agent | ||
from langchain.tools.base import tool | ||
from tests.unit_tests.llms.fake_llm import FakeLLM | ||
|
||
|
||
@tool | ||
def my_tool(query: str) -> str: | ||
"""A fake tool.""" | ||
return "fake tool" | ||
|
||
|
||
def test_initialize_agent_with_str_agent_type() -> None: | ||
"""Test initialize_agent with a string.""" | ||
fake_llm = FakeLLM() | ||
agent_executor = initialize_agent( | ||
[my_tool], fake_llm, "zero-shot-react-description" # type: ignore | ||
) | ||
assert agent_executor.agent._agent_type == AgentType.ZERO_SHOT_REACT_DESCRIPTION | ||
assert isinstance(agent_executor.tags, list) | ||
assert "zero-shot-react-description" in agent_executor.tags |