Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

ADK Streaming Quickstart

This project demonstrates a simple web application using the Google Agent Development Kit (ADK) to stream responses from a Gemini agent backed by Google Search.

Folder Structure

.
├── .env                  # API keys and configuration (ignored by git)
├── .gitignore            # Specifies intentionally untracked files that Git should ignore
├── README.md             # This file
├── app/                  # Main application folder
│   ├── __init__.py       # Makes 'app' a Python package
│   ├── main.py           # FastAPI application entrypoint
│   ├── google_search_agent/ # Contains the agent logic
│   │   ├── __init__.py   # Makes 'google_search_agent' a Python package
│   │   └── agent.py      # Defines the search agent
│   └── static/           # Static files (HTML, CSS, JS)
│       └── index.html    # Frontend HTML
└── .venv/                # Python virtual environment (ignored by git)

(Note: A potentially redundant .env file might exist in app/google_search_agent/)

Setup

  1. Clone the repository (if applicable)

    # git clone <repository-url>
    # cd adk_streaming_quickstart
  2. Create and Activate Virtual Environment: It's recommended to use a virtual environment to manage dependencies.

    # Create the virtual environment
    python3 -m venv .venv
    
    # Activate the virtual environment
    # On macOS/Linux:
    source .venv/bin/activate
    # On Windows:
    # .venv\Scripts\activate
  3. Install Dependencies: (Create a requirements.txt file with dependencies like fastapi, uvicorn[standard], google-generativeai, python-dotenv, websockets, google-cloud-aiplatform (if using Vertex) and run:)

    pip install -r requirements.txt
  4. Configure Environment Variables: Create a file named .env in the root directory of the project (/Users/jairo/Projects/adk_streaming_quickstart/.env). Add the following content, replacing the placeholder with your actual Google API Key:

    # .env
    GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY_HERE"
    GOOGLE_GENAI_USE_VERTEXAI="False" # Use "True" for Vertex AI, "False" for AI Studio/MakerSuite
    • Get your API key from Google AI Studio.
    • The .env file is included in .gitignore and should not be committed to version control.

Running the Application

  1. Navigate to the app directory:

    cd app
    export SSL_CERT_FILE=$(python3 -m certifi)
    adk web
  2. Start the FastAPI server:

    uvicorn main:app --reload

    The --reload flag automatically restarts the server when code changes are detected.

  3. Access the application: Open your web browser and go to http://127.0.0.1:8000.

About

With this quickstart, you'll learn to create a simple agent and use ADK Streaming to enable audio and video communication with it. We will install ADK, set up a basic "Google Search" agent, try running the agent with Streaming with adk web tool, and then explain how to build a simple asynchronous web app by yourself using ADK Streaming and FastAPI.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages