Generative AI

Step Guide for a Step to Make AI GOYSE AGAIN BY Google Adk

Agent Development Kit (Adk) Open Python frame that helps his developers, treat, and send more agents systems. It is designed to be model and variable, making it easier to use in both simple and difficult apps based on agent.

In this lesson, we will create a simple AI agent using Adk. The agent will be able to access the two tools:

Google API key

To use Google AI services, you will need API key:

Alphancantage API key

By receiving financial data, we will use Aplan VanConte API:

  • Go to
  • Click “Get your free API locker key” or visit this direct link
  • Enter your email and follow the instructions
  • Once you have received your API key, Copy and save it safely. We will use it to ensure financial completion requests.

Python Information Librars

We need only one package:

Set your project folder through the following structure:

parent_folder/
│
└───multi_agent/
    ├── __init__.py
    ├── agent.py
    └── .env

__iinit__.py

Attach the following code Multi_agent / __ iintan__.py:

.een

Create a .env file within a variety of folder and attach the following:

GOOGLE_GENAI_USE_VERTEXAI=FALSE
GOOGLE_API_KEY=""
ALPHA_VANTAGE_API_KEY="

Locate Local owners with your actual API buttons

Agent.uppy

Attach the following code in file for angent.py:

from google.adk.agents import Agent
import requests
import os
from typing import Optional

ALPHA_VANTAGE_API_KEY = os.getenv("ALPHA_VANTAGE_API_KEY")

def get_company_overview(symbol: str) -> dict:
    """
    Get comprehensive company information and financial metrics
   
    Args:
        symbol: Stock ticker symbol (e.g., IBM)
   
    Returns:
        dict: Company overview data or error
    """
    if not ALPHA_VANTAGE_API_KEY:
        return {"status": "error", "error": "Missing API key"}
   
    base_url = "query"
    params = {
        "function": "OVERVIEW",
        "symbol": symbol,
        "apikey": ALPHA_VANTAGE_API_KEY
    }
   
    try:
        response = requests.get(base_url, params=params)
        response.raise_for_status()
        data = response.json()
       
        if "Error Message" in data:
            return {"status": "error", "error": data["Error Message"]}
           
        # Filter key metrics
        key_metrics = {
            "Description": data.get("Description"),
            "Sector": data.get("Sector"),
            "MarketCap": data.get("MarketCapitalization"),
            "PERatio": data.get("PERatio"),
            "ProfitMargin": data.get("ProfitMargin"),
            "52WeekHigh": data.get("52WeekHigh"),
            "52WeekLow": data.get("52WeekLow")
        }
       
        return {
            "status": "success",
            "symbol": symbol,
            "overview": key_metrics
        }
       
    except Exception as e:
        return {"status": "error", "error": str(e)}

def get_earnings(symbol: str) -> dict:
    """
    Get annual and quarterly earnings (EPS) data with analyst estimates and surprises
   
    Args:
        symbol: Stock ticker symbol (e.g., IBM)
   
    Returns:
        dict: Earnings data with estimates or error message
    """
    if not ALPHA_VANTAGE_API_KEY:
        return {"status": "error", "error": "Missing API key"}
   
    base_url = "query"
    params = {
        "function": "EARNINGS",
        "symbol": symbol,
        "apikey": ALPHA_VANTAGE_API_KEY
    }
   
    try:
        response = requests.get(base_url, params=params)
        response.raise_for_status()
        data = response.json()
       
        if "Error Message" in data:
            return {"status": "error", "error": data["Error Message"]}
           
        # Process annual and quarterly earnings
        annual_earnings = data.get("annualEarnings", [])[:5]  # Last 5 years
        quarterly_earnings = data.get("quarterlyEarnings", [])[:4]  # Last 4 quarters
       
        # Format surprise percentages
        for q in quarterly_earnings:
            if "surprisePercentage" in q:
                q["surprise"] = f"{q['surprisePercentage']}%"
       
        return {
            "status": "success",
            "symbol": symbol,
            "annual_earnings": annual_earnings,
            "quarterly_earnings": quarterly_earnings,
            "metrics": {
                "latest_eps": quarterly_earnings[0]["reportedEPS"] if quarterly_earnings else None
            }
        }
       
    except Exception as e:
        return {"status": "error", "error": str(e)}
   
   
root_agent = Agent(
    name="Financial_analyst_agent",
    model="gemini-2.0-flash",
    description=(
        "Agent to give company overviews with key financial metrics."
    ),
    instruction=(
        "You are a helpful AI agent that provides company overviews and earnings information"
    ),
    tools=[get_company_overview, get_earnings],
)

In this document, it describes a financial analytical agent using Google Agent Development Kit (Adk). The agent has been designed to answer user questions by accessing the actual financial data by Alpha Vantage API. Specially, disclose two tools: Get_comput_vophunview and get_earnings. Get_company_ovie_Oview Retraueves Information Company information such as the Sector, Market Sales, IP / e average, and lower 52 weeks. The Get_earnings work provides for year's leading details and quarter, including the percentages and percentage of surprise.

Starting agent, goes to the Directory of your agent project (eg using CD ..)

parent_folder/      ← Navigate to this directory in your terminal
│
└───multi_agent/
    ├── __init__.py     # Initializes the module
    ├── agent.py        # Contains the agent logic and tools
    └── .env            # Stores your API keys securely

After roaming, run the following code:

Open the provided URL (usually or directly in your browser.

Additionally, you can check each agent consultation step by clicking Verb. This allows you to view:

  • Tools called
  • Input and exit for each employee
  • Answers generated by the language model

You can find the entire code and folder structure in this link:


I am the student of the community engineering (2022) from Jamia Millia Islamia, New Delhi, and I am very interested in data science, especially neural networks and their application at various locations.

🚨 Build a GENAI you can trust them. ⭐️ Parliant is your open-sound engine of the Open-sound engine interacts controlled, compliant, and purpose AI – Star Parlont on Gitity! (Updated)

Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button