Skip to main content

img.png

gemini-agents-toolkit

The project is an SDK for implementing Agent-Driven Development (ADD) applications. ADD is aimed to move routine code tasks to the LLM agents and concentrate on the algorithmic and fun part of the business logic implementation.

license discord youtube

⭐ Add a star for a duck!


How It Works  •  Requirements  •  Getting Started  •  Run Examples  •  How To Contribute


🚀How It Works

gemini-agents-toolkit is an SDK that creates LLM agents and enables their integration into pipelines for modifying generated responses.

See the picture describing the process:

img.png

The roles of every component are as follows:

  1. Application: Define custom functions to guide LLM executions, launch agents for task execution, and combine tasks into pipelines.
  2. gemini-agents-toolkit: A tool for creating agents, executing pipelines and interacting with Gemini.
  3. Vertex AI API: A Google API for interacting with Gemini models.
  4. Gemini: LLM models that generate text, code, or instructions to guide agent execution.

📝Requirements

❗️ The project uses Vertex AI API to access Gemini models, which is paid Google API ❗

You can find pricing here.

Agents request text generating only, which is paid for Text Input and Text Output. Running a pipeline will produce several requests depending on the pipeline's complexity.

========

Supported Python versions: Python 3.8 to 3.12 (gcloud requirement)


🤖Getting Started

Big Picture

This project uses Gemini via Google Cloud API. To use the project you must first set up the following:

  • Google Cloud account with Billing
  • Allow requesting LLM models via APIs (pricing)
  • Set up gcloud tool in your environment
  • Set up the project

Google Cloud account with Billing

  1. Go to Google AI Studio, select "Get API key" in the menu on the left. Click "Create API" key button and select Google Cloud project to associate API key with.
  2. Click suggestion to "Set up Billing" near your new API key and initialize your Google Billing account.
  3. [Optional] You can add a Budget for your account, which will email you when your spendings reach configured thresholds. Choose "Budgets & alerts" in the menu on the left in Billing console and follow the instruction.
  4. After this step, you should be able to test your Google Cloud project set up running curl command presented under the API keys table.

Allow requesting LLM models via APIs

  1. The project uses Vertex AI API to request Gemini models, Vertex AI API should be allowed in your Google cloud account. You need to allow it from the Google Cloud Vertex AI API product page.
  2. [Optional] With these instructions you can limit or increase your API requests quota.

Set up gcloud tool in your environment

Follow the Google instructions to install gcloud and to initialize it.

Set up the project

  1. Clone gemini-agents-toolkit repository.
  2. For the development process, you probably will need other repositories from the project. You can find other packages here. Currently, the project uses this list of other repositories:
Module Description Link
json-agent Agent to convert data formats to JSON link
  1. gemini-agents-toolkit uses several environment variables that you need to set up:
Env Variable Description Which Value To Set Command To Set Up
GOOGLE_PROJECT Project id from Google AI Studio Open Google AI studio and choose from the table with projects EXPORT GOOGLE_PROJECT=my-amazing-project
GOOGLE_API_KEY API key from Google AI Studio to request your project Find out the API key in the row with your project EXPORT GOOGLE_API_KEY=my-amazing-project
GOOGLE_REGION You can choose which region API to request You can ignore env for the default value us-west1, or find all available regions in Google Cloud docs EXPORT GOOGLE_REGION=my-amazing-project
  1. Now, you need to register custom Python modules to use them in examples:
export PYTHONPATH=/my/custom/module/path:$PYTHONPATH

Modules you need to register:

Module Description Link
config Using env variables and constants link
json-agent Agent to convert data formats to JSON link

❗ To have your variables set up permanently, register them in .bashrc (.zshrc etc, depending on your operational system and shell).


🎉Run Examples

Now it's time for fun!

Run examples/simple_example.py with

python examples/simple_example.py

In this example, you have created a custom function and gave Gemini ability to use your function:

See code
import vertexai
from config import (PROJECT_ID, REGION, SIMPLE_MODEL)
from gemini_agents_toolkit import agent


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=PROJECT_ID, location=REGION)

all_functions = [say_to_duck]
duck_comms_agent = agent.create_agent_from_functions_list(functions=all_functions,
                                                          model_name=SIMPLE_MODEL)

print(duck_comms_agent.send_message("say to the duck message: I am hungry"))

=>>>><<<<=

You can create several agents, which will delegate functions execution to each other:

python examples/multi_agent_example.py
See code
import datetime
import vertexai
from config import (PROJECT_ID, REGION, SIMPLE_MODEL, DEFAULT_MODEL)
from gemini_agents_toolkit import agent
from gemini_agents_toolkit.history_utils import summarize

vertexai.init(project=PROJECT_ID, location=REGION)


def generate_duck_comms_agent():
    """create an agent to say to a duck"""

    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=DEFAULT_MODEL)


def generate_time_checker_agent():
    """create an agent to get the time"""

    def get_local_time():
        """get the current local time"""
        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=SIMPLE_MODEL)


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=SIMPLE_MODEL)

result_say_operation, history_say_operation = main_agent.send_message("say to the duck message: I am hungry")
result_time_operation, history_time_operation = main_agent.send_message("can you tell me what time it is?")

print(result_say_operation)
print(result_time_operation)
print(summarize(agent=main_agent, history=history_say_operation + history_time_operation))

=>>>><<<<=

You can execute your code periodicaly:

python examples/simple_scheduler_example.py
See code
import time
import vertexai
from config import (PROJECT_ID, REGION, SIMPLE_MODEL)
from gemini_agents_toolkit import agent


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 message in console"""
    print(msg)


vertexai.init(project=PROJECT_ID, location=REGION)

all_functions = [say_to_duck]
duck_comms_agent = agent.create_agent_from_functions_list(functions=all_functions,
                                                          model_name=SIMPLE_MODEL,
                                                          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)

Find more advanced examples in the examples directory.


💡How To Contribute

If you want to be a code contributor

  • Just pick up a task from the Issues in this repository, assign it to you and raise a pull request with proposed changes.
  • If you need help, join the Discord and ask for help. The contributors team will be happy to see you!

If you want to contribute ideas or participate discussions

Feel free to join our Discord, where you can discuss the project with the contributors and probably impact on the way the project evolves.


Back to top

Release files for gemini-agents-toolkit 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gemini-agents-toolkit 4.0.0
File Size Uploaded
gemini_agents_toolkit-4.0.0.tar.gz 18.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gemini-agents-toolkit 4.0.0
File Interpreter ABI Platform
gemini_agents_toolkit-4.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.7 kB

Release files / gemini_agents_toolkit-4.0.0.tar.gz

Download URL gemini_agents_toolkit-4.0.0.tar.gz
Size 18.1 kB
Tags Source
SHA-256 checksum
How to use checksums
74f4368c981bf1ff5ed4e342418fbba35ac1af37ad20c4c0f87dfc2d2f05f4bc
BLAKE2b-256 checksum
How to use checksums
6b83ac6b5241d3baed1bfaae931abae54170338b5860efeae817df62fefc9157
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / gemini_agents_toolkit-4.0.0-py3-none-any.whl

Download URL gemini_agents_toolkit-4.0.0-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ac591ec663dab3f1ec728d3043ae82a35ec4b0d8f51431fd5ae55e0f9a12ebf
BLAKE2b-256 checksum
How to use checksums
192560e2bcfa2f428ae12646369095fe4188babd9220050d2c6d144bbf897f1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

4.0.0 This release

2 release files

3.8.3

2 release files

3.8.2

2 release files

3.8.1

2 release files

3.8.0

2 release files

3.7.2

2 release files

3.7.1

2 release files

3.7.0

2 release files

3.6.0

2 release files

3.5.0

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page