handy_assistant/chat_tools.py

39 lines
1.1 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"],
},
}
},
]
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