Toolkit For Creating Gemini Based Agents
Project description
SDK For Simplified usage of Gemini Agents. Give Gemini Ability to use your custom functions in seveal code lines:
from gemini_agents_toolkit import agent
import vertexai
def say_to_duck(say: str):
"""say something to a duck"""
return f"duck answer is: duck duck {say} duck duck duck"
vertexai.init(project="gemini-trading-backend", location="us-west1")
all_functions = [say_to_duck]
duck_comms_agent = agent.create_agent_from_functions_list(functions=all_functions, model_name="gemini-1.5-flash")
print(duck_comms_agent.send_message("say to the duck message: I am hungry"))
Here is more complex example of several agents that delegating tasks to each other:
from gemini_agents_toolkit import agent
import vertexai
vertexai.init(project="gemini-trading-backend", location="us-west1")
def generate_duck_comms_agent():
def say_to_duck(say: str):
"""say something to a duck"""
return f"duck answer is: duck duck {say} duck duck duck"
return agent.create_agent_from_functions_list(
functions=[say_to_duck],
delegation_function_prompt="Agent can communicat to ducks and can say something to them. And provides the answer from the duck.",
model_name="gemini-1.5-flash")
def generate_time_checker_agent():
def get_local_time():
"""get the current local time"""
import datetime
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return agent.create_agent_from_functions_list(
functions=[get_local_time],
delegation_function_prompt="Agent can provide the current local time.",
model_name="gemini-1.5-flash")
duck_comms_agent = generate_duck_comms_agent()
time_checker_agent = generate_time_checker_agent()
main_agent = agent.create_agent_from_functions_list(delegates=[time_checker_agent, duck_comms_agent], model_name="gemini-1.5-flash")
print(main_agent.send_message("say to the duck message: I am hungry"))
print(main_agent.send_message("can you tell me what time it is?"))
Example of how you can call periodic task:
from gemini_agents_toolkit import agent
import time
import vertexai
def say_to_duck(say: str):
"""say something to a duck"""
return f"duck answer is: duck duck {say} duck duck duck"
def print_msg_from_agent(msg: str):
print(msg)
vertexai.init(project="gemini-trading-backend", location="us-west1")
all_functions = [say_to_duck]
duck_comms_agent = agent.create_agent_from_functions_list(functions=all_functions, model_name="gemini-1.5-flash", add_scheduling_functions=True, on_message=print_msg_from_agent)
# no need to print result directly since we passed to agent on_message
duck_comms_agent.send_message("can you be saying, each minute, to the duck that I am hungry")
# wait 3 min to see results
time.sleep(180)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for gemini_agents_toolkit-2.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | db54c143d55e6faa86d588ebd24b58725ad0cc2508df8bf4b1d2338c12415217 |
|
MD5 | 57b48fa08b6032ce8ce2d9db39e11957 |
|
BLAKE2b-256 | b56f110aac6a26c91549380f9321aa177ea305c11aef1784b4f9abe506d0a579 |
Close
Hashes for gemini_agents_toolkit-2.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02e473472e006ce6478deae19afbc67c4e2a7631e3e98582aaac43568e6b8e00 |
|
MD5 | 6d5f0ab3ad93a05e0110464fe7cda3a0 |
|
BLAKE2b-256 | 75ee17d23d34705209967495968ad1323ac1298cda51d7496f465b6e83b2038d |