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

[CaptainAgent] Add executor injected with tools. #307

Merged
merged 2 commits into from
Dec 28, 2024
Merged

Conversation

LeoLjl
Copy link
Collaborator

@LeoLjl LeoLjl commented Dec 28, 2024

Current tools in ag2 can only be called via function calling/tool calling. This relies on the capability of the backend LLM. Another way of orchestrating tools is to use python coding to call and orchestrate the results. Introducing LocalExecutorWithTools, a customized executor that can call the functions underling the ag2 tools. The executor takes in a list of ag2 tools when instantiated, and extract the func field within them. An example usage is:

api_wrapper = WikipediaAPIWrapper(top_k_results=1, doc_content_chars_max=3000)
langchain_tool = WikipediaQueryRun(api_wrapper=api_wrapper)
interop = Interoperability()
ag2_tool = interop.convert_tool(tool=langchain_tool, type="langchain")

# `ag2_tool.name` is wikipedia
local_executor = LocalExecutorWithTools(tools=[ag2_tool], work_dir="./")

code = """
result = wikipedia(tool_input={"query":"Christmas"})
print(result)
"""
result = local_executor.execute_code_blocks(
    code_blocks=[
        CodeBlock(language="python", code=code),
    ]
)

On the side of agents, they just need to call the function with no declarations needed and the results will be provided. The provides a more LLM-friendly way of orchestrating tool usage.

This PR is the preliminary of integrating cross platform tool into CaptainAgent. This is because the agents in groupchat assembled by CaptainAgent use tools as freeform coding. In order to adapt the tool-calling based ag2 tools into CaptainAgent, an executor injected with the namspace of the tool names is needed.

Why are these changes needed?

Related issue number

#286

Roadmap

The next PR will add the full content of the integration code and the notebook demonstrating the usage.

Checks

Copy link
Collaborator

@skzhang1 skzhang1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@LeoLjl LeoLjl added this pull request to the merge queue Dec 28, 2024
Merged via the queue into main with commit 57f229d Dec 28, 2024
203 of 211 checks passed
@LeoLjl LeoLjl deleted the Tool_executor branch December 28, 2024 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants