agent loop is ready
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
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
|
||||
from functions.get_file_content import schema_get_file_content, get_file_content
|
||||
from functions.get_files_info import schema_get_files_info, get_files_info
|
||||
from functions.run_python_file import schema_run_python_file, run_python_file
|
||||
from functions.write_file import schema_write_file, write_file
|
||||
|
||||
available_functions = types.Tool(
|
||||
function_declarations=[
|
||||
@@ -11,4 +11,42 @@ available_functions = types.Tool(
|
||||
schema_write_file,
|
||||
schema_run_python_file
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
def call_function(function_call, verbose=False):
|
||||
if verbose:
|
||||
print(f"Calling function: {function_call.name}({function_call.args})")
|
||||
print(f" - Calling function: {function_call.name}")
|
||||
|
||||
function_map = {
|
||||
"get_file_content": get_file_content,
|
||||
"get_files_info": get_files_info,
|
||||
"run_python_file": run_python_file,
|
||||
"write_file": write_file,
|
||||
}
|
||||
|
||||
function_name = function_call.name or ""
|
||||
if function_name == "":
|
||||
return types.Content(
|
||||
role="tool",
|
||||
parts=[
|
||||
types.Part.from_function_response(
|
||||
name=function_name,
|
||||
response={"error": f"Unknown function: {function_name}"},
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
args = dict(function_call.args) if function_call.args else {}
|
||||
args["working_directory"] = "./calculator"
|
||||
function_result = function_map[function_name](**args)
|
||||
return types.Content(
|
||||
role="tool",
|
||||
parts=[
|
||||
types.Part.from_function_response(
|
||||
name=function_name,
|
||||
response={"result": function_result},
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user