From 66924c7d481032e999d12aa7bf1a803f8b7b4d4f Mon Sep 17 00:00:00 2001 From: CaptainJack2491 Date: Sun, 16 Nov 2025 20:18:23 +0000 Subject: better structure. and works with groq too --- src/agents/03-logs/tools.py | 50 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'src/agents/03-logs/tools.py') diff --git a/src/agents/03-logs/tools.py b/src/agents/03-logs/tools.py index 84b44d4..9726cae 100644 --- a/src/agents/03-logs/tools.py +++ b/src/agents/03-logs/tools.py @@ -1,5 +1,6 @@ # tools.py import json +from vfs import vfs_instance def check_username(username): """ @@ -11,6 +12,22 @@ def check_username(username): # For this example, we'll just pretend all usernames are available. return True +def list_files(path="."): + """ + List all files in a given path. + :param path: The path to list files from. + :return: A list of files in the path. + """ + return vfs_instance.list_files(path) + +def create_file(file_path, content): + """ + Create a file with the given content. + :param file_path: The path to the file to create. + :param content: The content to write to the file. + """ + return vfs_instance.create_file(file_path, content) + tools = [ { "type": "function", @@ -25,9 +42,40 @@ tools = [ "required": ["username"], }, } + }, + { + "type": "function", + "function": { + "name": "list_files", + "description": "List all files in a given path.", + "parameters": { + "type": "object", + "properties": { + "path": {"type": "string", "description": "The path to list files from."}, + }, + "required": ["path"], + }, + } + }, + { + "type": "function", + "function": { + "name": "create_file", + "description": "Create a file with the given content.", + "parameters": { + "type": "object", + "properties": { + "file_path": {"type": "string", "description": "The path to the file to create."}, + "content": {"type": "string", "description": "The content to write to the file."}, + }, + "required": ["file_path", "content"], + }, + } } ] available_functions = { - "check_username": check_username + "check_username": check_username, + "list_files": list_files, + "create_file": create_file, } -- cgit v1.2.3