handy_assistant/chat_tools.py
2025-04-26 21:58:22 +08:00

60 lines
2.0 KiB
Python

import bot_util
tools = [
{
"type": "function",
"function": {
"name": "write_file",
"description": "write content to a file, creating directories if they do not exist. If the file already exists, it will be overwritten.",
"parameters": {
"type": "object",
"properties": {
"file_path": {
"type": "string",
"description": "the path with file name to write to. it can be relative path. e.g. 'test_data/output/test.md'",
},
"content": {
"type": "string",
"description": "the content to write to the file.",
},
},
"required": ["file_path","content"],
},
},
},
{
"type": "function",
"function": {
"name": "write_file_batch",
"description": "write contents files, creating directories if they do not exist. If the file already exists, it will be overwritten.",
"parameters": {
"type": "object",
"properties": {
"file_paths": {
"type": "array",
"description": "the path with file name to write to. it can be relative path. e.g. '[test_data/output/test.md]'",
},
"contents": {
"type": "array",
"description": "the contents to write to the files.",
},
},
"required": ["file_paths","contents"],
},
}
},
]
class ChatTools:
def __init__(self, tools, util):
self.tools = tools
self.names = util.__all__
self.util = util
def get_tools(self):
return self.tools
def get_chat_tools():
chat_tools = ChatTools(tools, bot_util)
return chat_tools