giving functions to use for AI
This commit is contained in:
@@ -1,5 +1,21 @@
|
||||
import os
|
||||
from functions.config import MAX_FILE_CONTENT_CHARS
|
||||
from google.genai import types
|
||||
|
||||
schema_get_file_content = types.FunctionDeclaration(
|
||||
name="get_file_content",
|
||||
description="Reads and returns the contents of a file, truncated if too large, constrained to the working directory.",
|
||||
parameters=types.Schema(
|
||||
type=types.Type.OBJECT,
|
||||
properties={
|
||||
"file_path": types.Schema(
|
||||
type=types.Type.STRING,
|
||||
description="Path to the file, relative to the working directory.",
|
||||
),
|
||||
},
|
||||
required=["file_path"],
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def get_file_content(working_directory, file_path):
|
||||
|
||||
@@ -1,4 +1,19 @@
|
||||
import os
|
||||
from google.genai import types
|
||||
|
||||
schema_get_files_info = types.FunctionDeclaration(
|
||||
name="get_files_info",
|
||||
description="Lists files in the specified directory along with their sizes, constrained to the working directory.",
|
||||
parameters=types.Schema(
|
||||
type=types.Type.OBJECT,
|
||||
properties={
|
||||
"directory": types.Schema(
|
||||
type=types.Type.STRING,
|
||||
description="The directory to list files from, relative to the working directory. If not provided, lists files in the working directory itself.",
|
||||
),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
def get_files_info(working_directory, directory="."):
|
||||
try:
|
||||
|
||||
@@ -1,6 +1,26 @@
|
||||
import os
|
||||
import subprocess
|
||||
from google.genai import types
|
||||
|
||||
schema_run_python_file = types.FunctionDeclaration(
|
||||
name="run_python_file",
|
||||
description="Executes a Python file with optional arguments, constrained to the working directory.",
|
||||
parameters=types.Schema(
|
||||
type=types.Type.OBJECT,
|
||||
properties={
|
||||
"file_path": types.Schema(
|
||||
type=types.Type.STRING,
|
||||
description="Path to the Python file, relative to the working directory.",
|
||||
),
|
||||
"args": types.Schema(
|
||||
type=types.Type.ARRAY,
|
||||
description="List of arguments to pass to the Python script.",
|
||||
items=types.Schema(type=types.Type.STRING),
|
||||
),
|
||||
},
|
||||
required=["file_path"],
|
||||
),
|
||||
)
|
||||
|
||||
def run_python_file(working_directory, file_path, args=[]):
|
||||
try:
|
||||
|
||||
@@ -1,4 +1,24 @@
|
||||
import os
|
||||
from google.genai import types
|
||||
|
||||
schema_write_file = types.FunctionDeclaration(
|
||||
name="write_file",
|
||||
description="Writes or overwrites file contents within the working directory.",
|
||||
parameters=types.Schema(
|
||||
type=types.Type.OBJECT,
|
||||
properties={
|
||||
"file_path": types.Schema(
|
||||
type=types.Type.STRING,
|
||||
description="Path to the file relative to the working directory.",
|
||||
),
|
||||
"content": types.Schema(
|
||||
type=types.Type.STRING,
|
||||
description="The text content to write into the file.",
|
||||
),
|
||||
},
|
||||
required=["file_path", "content"],
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def write_file(working_directory, file_path, content):
|
||||
|
||||
Reference in New Issue
Block a user