-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: Dynamic generate agent #2540
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
base: master
Are you sure you want to change the base?
Conversation
I'm considering add a tool_rag_selector. It can search suitable tools by rag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @Yuujee ,I did a preliminary quick review,left some comment
self.tool_selector = tool_selector | ||
|
||
def generate_prompt(self, task_content: str) -> dict: | ||
prompt = TextPrompt( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add more docstring below these function in dynamic_agent?
thanks @Yuujee ,i think there are some papers related to tool rag with graph etc,it would be better to do some prestudy.If you need help, feel free to tell us,thanks |
Thanks for your comment @zjrwtx ! I will fix the code recently. And I will do some prestudy about tool_rag. Maybe we could open another issue about it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @Yuujee's contribution, left some comments below, could we also add this dynamic agent building feature into workforce class as default setting?
from typing import Any, List | ||
|
||
from camel.toolkits import ACIToolkit | ||
from examples.toolkits.aci_toolkit import LINKED_ACCOUNT_OWNER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'd better set the variable directly, instead of importing from example code
r""" | ||
Abstract base class for all tool selectors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docstring format
r""" | |
Abstract base class for all tool selectors. | |
r"""Abstract base class for all tool selectors. |
def select_tools(self, task_content: str) -> list: | ||
r""" | ||
Searches for functions via ACI Toolkit based on the task intent. | ||
|
||
Args: | ||
task_content (str): Description of the task for function discovery. | ||
|
||
Returns: | ||
List[FunctionTool]: A list of matched function tools. | ||
""" | ||
return self.aci_toolkit.get_tools() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems now we just returned all the toolkits instead of selecting the tool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. ACIFunctionToolSelector provides a way to finish the task by aciToolkit. And I will add a mcpToolSelector later. Through the mcpToolSelector we can select McpTools, but it's can only for the mcp. Maybe I could open another issue to realize a rag_tool_selector to support internal toolkits search from camel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for now maybe we could refer to https://docs.camel-ai.org/cookbooks/advanced_features/agents_with_MCP#mcp-search-agents to implement it, we also have example code for aci.dev here: https://github.com/camel-ai/camel/blob/master/examples/agents/mcp_agent/mcp_agent_using_registry.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a little confused.If we use McpAgent to search the tools we need, then we need to use it to call the tools.So why not use McpAgent directly?
model_config_dict = ChatGPTConfig(temperature=0.0).as_dict() | ||
model = ModelFactory.create( | ||
model_platform=ModelPlatformType.DEFAULT, | ||
model_type=ModelType.DEFAULT, | ||
model_config_dict=model_config_dict, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe better support take agent as argument instead of hard coding the model
) | ||
|
||
agent = ChatAgent(system_message=prompt, model=model) | ||
response = agent.step(task_content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use structured output feature? refer: https://github.com/camel-ai/camel/blob/master/examples/structured_response/json_format_response.py
# Step 3: Build model configuration | ||
model_config_dict = ChatGPTConfig( | ||
tools=tools, | ||
temperature=0.0 | ||
).as_dict() | ||
|
||
model = ModelFactory.create( | ||
model_platform=ModelPlatformType.DEFAULT, | ||
model_type=ModelType.DEFAULT, | ||
model_config_dict=model_config_dict, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above, don't hard code the model type
…amic_generate_agent
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Description
Describe your changes in detail (optional if the linked issue already contains a detailed description of the changes).
Checklist
Go over all the following points, and put an
x
in all the boxes that apply.Fixes #issue-number
in the PR description (required)pyproject.toml
anduv lock
If you are unsure about any of these, don't hesitate to ask. We are here to help!