Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Toolkits Refactoring #940

Open
1 of 2 tasks
WHALEEYE opened this issue Sep 13, 2024 · 3 comments
Open
1 of 2 tasks

[Feature Request] Toolkits Refactoring #940

WHALEEYE opened this issue Sep 13, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request P0 Task with high level priority Refactor
Milestone

Comments

@WHALEEYE
Copy link
Collaborator

Required prerequisites

Motivation

The current style of toolkits is quite chaotic, we need to make it more standardized to ensure the code quality and also for the ease of adding future tools.

Solution

No response

Alternatives

No response

Additional context

No response

@WHALEEYE WHALEEYE added the enhancement New feature or request label Sep 13, 2024
@WHALEEYE WHALEEYE self-assigned this Sep 13, 2024
@WHALEEYE WHALEEYE added this to the Sprint 13 milestone Sep 23, 2024
@WHALEEYE WHALEEYE added Refactor P0 Task with high level priority labels Sep 23, 2024
@Wendong-Fan Wendong-Fan modified the milestones: Sprint 13, Sprint 14 Oct 7, 2024
@ZackYule
Copy link
Collaborator

I have a couple of detail questions regarding the Toolkits refactoring that might be worth considering:

Q1: Would it make sense to replace BaseToolkit classes that don’t require any configuration with functional tools instead? This way, we could avoid exposing classes without actual tool methods in the ToolManager, streamlining the structure.

Q2: I think it might be better if the tool list returned by ToolManager is List[str] when intended for user interaction, and list[OpenAIFunction] when used by the agent. Since list_toolkits is primarily for users, it seems reasonable for it to return List[str]. As for search_toolkits, should it be designed for user use or for the agent?

@ZackYule
Copy link
Collaborator

ZackYule commented Oct 14, 2024

Below are the current ways we use tools, and I believe it would be helpful to consider unifying these approaches while also supporting developers in customizing their own tools.

There’s also one more point to consider: the OpenAPIToolkit doesn’t currently support the management approach used by toolkits_manager.

Perhaps it would be a good idea to revisit and discuss these details again. @lightaime @yiyiyi0817 @zhiyu-01

1. Without toolkit_manager

No configuration needed

tools_list = [
  *SEARCH_FUNCS,
  *MathToolkit().get_tools(),
]

Configuration needed

toolkit = GithubToolkit(repo_name=repo_name)

tools_list = [
  *SEARCH_FUNCS,
  *WEATHER_FUNCS,
  *toolkit.get_tools(),
]

2. With toolkits_manager

No configuration needed

tools_list = manager.get_toolkits(names=manager.search_toolkits('weather'))

Configuration needed

camel_github_toolkit = GithubToolkit(repo_name='camel-ai/camel')

tools_list = manager.register_tool([camel_github_toolkit, ])

Custom tools

def div(a: int, b: int) -> float:
    r"""Divides two numbers.
    Args:
        a (int): The dividend in the division.
        b (int): The divisor in the division.
    Returns:
        float: The quotient of the division.
    Raises:
        ValueError: If the divisor is zero.
    """
    if b == 0:
        raise ValueError("Division by zero is not allowed.")
    return a / b
  
tools_list = manager.register_tool([div, ])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P0 Task with high level priority Refactor
Projects
Status: No status
Development

No branches or pull requests

6 participants