`tools` in plugin directory is called **Toolset**. It contains many **Toolkit**, Toolkit is similar with **Packages** in Python in structure. It need `__init__.py` file and `tools.json` definition file in it. They are used to store and define functions.
- **Toolset Directory** is named as `marshoai-xxxxx`, its name is the name of Toolset. Please follow this naming standard.
- ***Tool Module* could contain many callable **Asynchronous** function, it could have parameters or be parameterless and the return value should be supported by AI model. Generally speaking, the `str` type is accepted to most model.
- **Function Definition File** is for AI model to know how to call these function.
In this example, we define two functions, `get_weather` and `get_current_time`. The former accepts a `str` typed parameter. Let AI to know the existence of these funxtions, you shuold write **Function Definition File**
"description": "Get the weather of a specified locatin.", # Description, it need to descripte the usage of this Functin
"parameters": { # Define the parameters
"type": "object",
"properties": {
"location": { # 'location' is the name that _init__.py had defined.
"type": "string", # the Type of patameters
"description": "City or district. Such as Beijing, Hangzhou, Yuhang District" # Description,it need to descripte the type or example of Actual Parameter
}
}
},
"required": [ # Define the Required Parameters
"location"
]
}
},
{
"type": "function",
"function": {
"name": "marshoai-example__get_current_time",
"description": "Get time",
"parameters": {} # No parameter requried, so it is blanked
In this file, we defined tow function. This Function Definition File will be typed into AI model, for letting AI to know when and how to call these function.
**Function Call Name** is specific required. Using weather-getting as an example, this Function Call Name, `marshoai-example__get_weather`, contain these information.
Using this Naming Standard, it could be compatible with more APIs in the standard format of OpenAI. So don't use two underscores as the name of Toolkit or Function.
### Function Testing
After developing the Tools, start the Bot. There loading information of Toolkit in Nonebot Logs.