summaryrefslogtreecommitdiff
path: root/src/agents/03-logs/tools.py
diff options
context:
space:
mode:
authorCaptainJack2491 <jayrupnakawala@gmail.com>2025-11-16 20:18:23 +0000
committerCaptainJack2491 <jayrupnakawala@gmail.com>2025-11-16 20:18:23 +0000
commit66924c7d481032e999d12aa7bf1a803f8b7b4d4f (patch)
tree2c8001fcbdfd00e6785d363cfe98ebad13c14dfa /src/agents/03-logs/tools.py
parent70557afb1e09fc99e9488b69322a76c50dc98554 (diff)
better structure. and works with groq too
Diffstat (limited to 'src/agents/03-logs/tools.py')
-rw-r--r--src/agents/03-logs/tools.py50
1 files changed, 49 insertions, 1 deletions
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,
}