add schema_get_files_info and call_function
This commit is contained in:
@@ -4,8 +4,8 @@ import os
|
||||
from dotenv import load_dotenv
|
||||
from google import genai
|
||||
from google.genai import types
|
||||
|
||||
from prompts import system_prompt
|
||||
from functions.call_function import available_functions
|
||||
|
||||
load_dotenv()
|
||||
api_key = os.environ.get("GEMINI_API_KEY")
|
||||
@@ -22,7 +22,10 @@ messages = [types.Content(role="user", parts=[types.Part(text=args.user_prompt)]
|
||||
response = client.models.generate_content(
|
||||
model="gemini-2.5-flash",
|
||||
contents=messages,
|
||||
config=types.GenerateContentConfig(system_instruction=system_prompt),
|
||||
config=types.GenerateContentConfig(
|
||||
system_instruction=system_prompt,
|
||||
tools=[available_functions],
|
||||
),
|
||||
)
|
||||
if not response.usage_metadata:
|
||||
raise RuntimeError("Cannot get usage metadata")
|
||||
@@ -31,4 +34,10 @@ if args.verbose:
|
||||
print(f"User prompt: {args.user_prompt}")
|
||||
print(f"Prompt tokens: {response.usage_metadata.prompt_token_count}")
|
||||
print(f"Response tokens: {response.usage_metadata.candidates_token_count}")
|
||||
print(response.text)
|
||||
|
||||
function_calls = response.function_calls
|
||||
if function_calls:
|
||||
for function_call in function_calls:
|
||||
print(f"Calling function: {function_call.name}({function_call.args})")
|
||||
else:
|
||||
print(response.text)
|
||||
|
||||
Reference in New Issue
Block a user