MCPcopy Create free account
hub / github.com/HKUDS/AutoAgent / tool_dummy

Function tool_dummy

autoagent/tools/dummy_tool.py:6–40  ·  view source on GitHub ↗

[This is a dummy tool, it's used for demonstrating the usage of the autoagent, you should write your own tool instead of using this dummy tool, and the following docstring is just a template, you should modify it to fit your own tool.] The tool is used to ... Args: args1: ...

(args1, args2, context_variables)

Source from the content-addressed store, hash-verified

4
5@register_plugin_tool("tool_dummy") # the name of registry should be the same as the name of the tool
6def tool_dummy(args1, args2, context_variables)-> Union[str, Agent, Result]:
7 """
8 [This is a dummy tool, it's used for demonstrating the usage of the autoagent, you should write your own tool instead of using this dummy tool, and the following docstring is just a template, you should modify it to fit your own tool.]
9 The tool is used to ...
10
11 Args:
12 args1: ...
13 args2: ...
14 ...
15 Returns:
16 ...
17 Notes:
18 The return value can be a string, an agent, or an instance of Result.
19 1. The most common return value is a string, but the length of the string should not be too long, and you can save the result to a file if the length is too long.
20 2. If the tool is used to transfer the conversation context to an agent, you can return an instance of Agent, like:
21 ```python
22 sales_agent = Agent(name="sales_agent", instructions="You are a sales agent.")
23 def transfer_to_sales_agent():
24 return sales_agent
25 ```
26 3. If there is some complex operations inside the tool, you can return an instance of Result, for example, you should modify the context variables in the result.
27 ```python
28 def sales_agent_tool(recommendation: str, context_variables: dict):
29 '''
30 The tool is used to recommend products to the user.
31 '''
32 context_variables["recommendation"] = recommendation
33 return Result(value="I recommend the product: " + recommendation, agent=user_agent, context_variables=context_variables)
34
35 4. The value of Result class should be a string, if you want to return a json dictionary, you should convert it to string by json.dumps(result)
36 ```
37 5. The tools should be created in the python file in the `autoagent/autoagent/tools` folder.
38 """
39 ... # the implementation of the tool
40 return "..." # the return value of the tool.
41

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected