add the rest of schemas, update prompts

This commit is contained in:
2026-03-28 17:45:23 +01:00
parent 84196b582f
commit b3d068edf9
5 changed files with 82 additions and 5 deletions
+9 -1
View File
@@ -1,6 +1,14 @@
from google.genai import types
from functions.get_file_content import schema_get_file_content
from functions.get_files_info import schema_get_files_info
from functions.run_python_file import schema_run_python_file
from functions.write_file import schema_write_file
available_functions = types.Tool(
function_declarations=[schema_get_files_info],
function_declarations=[
schema_get_files_info,
schema_get_file_content,
schema_write_file,
schema_run_python_file
],
)
+21 -2
View File
@@ -1,5 +1,5 @@
import os
from google.genai import types
def get_file_content(working_directory, file_path):
abs_dir_path = os.path.abspath(working_directory)
@@ -18,4 +18,23 @@ def get_file_content(working_directory, file_path):
file_content_string += f'[...File "{file_path}" truncated at {MAX_CHARS} characters]'
except Exception as e:
return f"Error: {e}"
return file_content_string
return file_content_string
schema_get_file_content = types.FunctionDeclaration(
name="get_file_content",
description="Open and read file content",
parameters=types.Schema(
type=types.Type.OBJECT,
properties={
"working_directory": types.Schema(
type=types.Type.STRING,
description="Directory path to list files from, relative to the working directory (default is the working directory itself)",
),
"file_path": types.Schema(
type=types.Type.STRING,
description="File path",
),
},
required=["file_path"]
),
)
+25 -1
View File
@@ -1,5 +1,6 @@
import os
import subprocess
from google.genai import types
def run_python_file(working_directory, file_path, args=None):
try:
@@ -36,4 +37,27 @@ def run_python_file(working_directory, file_path, args=None):
output.append(f"STDERR: {completed_process.stderr}")
return "\n".join(output)
except Exception as e:
return f"Error: executing Python file: {e}"
return f"Error: executing Python file: {e}"
schema_run_python_file = types.FunctionDeclaration(
name="run_python_file",
description="Run the file provided in the path",
parameters=types.Schema(
type=types.Type.OBJECT,
properties={
"working_directory": types.Schema(
type=types.Type.STRING,
description="Directory path to list files from, relative to the working directory (default is the working directory itself)",
),
"file_path": types.Schema(
type=types.Type.STRING,
description="File path",
),
"args": types.Schema(
type=types.Type.ARRAY,
items=types.Schema(type=types.Type.STRING),
description="Optional arguments to run subprocess",
),
},
),
)
+24 -1
View File
@@ -1,4 +1,5 @@
import os
from google.genai import types
def write_file(working_directory, file_path, content):
abs_path = os.path.abspath(working_directory)
@@ -15,4 +16,26 @@ def write_file(working_directory, file_path, content):
f.write(content)
except Exception as e:
return f"Error: {e}"
return f'Successfully wrote to "{file_path}" ({len(content)} characters written)'
return f'Successfully wrote to "{file_path}" ({len(content)} characters written)'
schema_write_file = types.FunctionDeclaration(
name="write_file",
description="Open file and write content into",
parameters=types.Schema(
type=types.Type.OBJECT,
properties={
"working_directory": types.Schema(
type=types.Type.STRING,
description="Directory path to list files from, relative to the working directory (default is the working directory itself)",
),
"file_path": types.Schema(
type=types.Type.STRING,
description="File path",
),
"content": types.Schema(
type=types.Type.STRING,
description="Content what should have been written to the file",
),
},
),
)