Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
eyurtsev committed Apr 18, 2024
1 parent 64642eb commit 1dad65a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
11 changes: 11 additions & 0 deletions langchain_benchmarks/tool_usage/agents/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import abc

from langchain_core.runnables import Runnable


class AgentFactory(abc.ABC):
"""Abstract class for agent factory"""

@abc.abstractmethod
def __call__(self) -> Runnable:
"""Create a new agent"""
3 changes: 2 additions & 1 deletion langchain_benchmarks/tool_usage/agents/runnable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

from langchain_benchmarks.schema import ToolUsageTask
from langchain_benchmarks.tool_usage.agents.adapters import apply_agent_executor_adapter
from langchain_benchmarks.tool_usage.agents.base import AgentFactory


class CustomRunnableAgentFactory:
class CustomRunnableAgentFactory(AgentFactory):
"""A factory for creating tool using agents.
A factory for agents that do not leverage any special JSON mode for
Expand Down
3 changes: 2 additions & 1 deletion langchain_benchmarks/tool_usage/agents/tool_using_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
from langchain_benchmarks.rate_limiting import RateLimiter, with_rate_limit
from langchain_benchmarks.schema import ToolUsageTask
from langchain_benchmarks.tool_usage.agents.adapters import apply_agent_executor_adapter
from langchain_benchmarks.tool_usage.agents.base import AgentFactory


class StandardAgentFactory:
class StandardAgentFactory(AgentFactory):
"""A standard agent factory.
Use this factory with chat models that support the standard LangChain tool
Expand Down
8 changes: 7 additions & 1 deletion tests/unit_tests/tool_usage/test_public_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@ def test_public_api() -> None:
# This test will also fail if __all__ is not sorted.
# Please keep it sorted!
assert __all__ == sorted(
["apply_agent_executor_adapter", "get_eval_config"], key=str.lower
[
"apply_agent_executor_adapter",
"get_eval_config",
"CustomRunnableAgentFactory",
"StandardAgentFactory",
],
key=str.lower,
)

0 comments on commit 1dad65a

Please sign in to comment.