Learn Google ADK: Build a farming agent.

Meet NaijaFarmHand: Your AI Farming Buddy for Nigeria Ever felt overwhelmed starting a small farm? Wondering when the best time to plant your maize is, what you actually need to start raising chickens, or what the weather will be like tomorrow in your specific town? Getting practical, localized farming information can sometimes feel like searching for a needle in a haystack, especially when you're just starting out. Imagine having a helpful assistant, powered by Artificial Intelligence (like the technology behind ChatGPT or Google Gemini), specifically designed to answer your beginner farming questions within the Nigerian context. This project isn't about replacing experienced farmers or extension agents, but about providing a quick, accessible first point of contact for common queries. Built using Google's AI Development Kit (ADK) and running within a Kaggle Notebook environment (a popular platform for data science and AI projects), NaijaFarmHand aims to bridge the information gap for aspiring and early-stage farmers focusing on some of Nigeria's key agricultural products. Before we dive in, here’s a bit of background: this project was completed as part of the 5-Day Gen AI Intensive course by Google. If you want to jump straight to the code, find link to the kaggle notebook at the end of the article. What Can NaijaFarmHand Actually Do? Think of NaijaFarmHand as having a few specialized skills, like different tools in a farmer's toolkit. It's specifically focused on: Crops: Maize, Cassava, Yam, Groundnut, and Guinea Corn. Livestock: Poultry (Broiler and Layer Chickens). If you ask about growing strawberries or raising snails, it will politely tell you that's outside its current expertise but might try to find general information using Google Search. Here are its main "tools": WeatherTool - The Local Forecaster: What it does: Gets you the current weather conditions for a specific Nigerian location. Need to know if it's likely to rain in Ibadan today before planting? Ask NaijaFarmHand, and it will use this tool. Why it's important: Weather is critical for day-to-day farming decisions. This tool uses the OpenWeatherMap API (powered by a secret API key safely stored using Kaggle Secrets) to fetch real-time data. FarmPlannerTool - The Starter Checklist Generator: What it does: Provides a basic checklist of things to consider when starting a specific type of farm (from its focus list) at a particular scale (e.g., "small scale maize farm" or "50 broiler chickens"). Why it's important: Gives beginners a rough idea of requirements like land, basic capital estimates (with a big disclaimer that costs vary!), simple tools, and initial inputs. It helps structure initial planning. TimingAdvisorTool - The Seasonal Guide: What it does: Offers general advice on typical planting seasons and harvest times for its focus crops in different broad regions of Nigeria (North, Middle Belt, South). Why it's important: Helps understand the usual agricultural calendar. Crucially, NaijaFarmHand is programmed to always remind you that this is general advice and you MUST check the current local weather (using the WeatherTool) and talk to local farmers for precise timing. Climate varies! google_search_grounding - The Researcher: What it does: For questions that the other tools can't answer directly, NaijaFarmHand uses Google Search. This is used for finding details on specific crop varieties suitable for Nigeria, identifying pests/diseases, getting an idea of market prices (which fluctuate wildly!), or learning about government agricultural programs. Why it's important: Provides a way to access the vast information online, guided by the agent's instructions to find relevant answers for the user. How Does It All Work Together? You don't need to be an AI expert to understand the basics: The Brain: The project uses a powerful language model from Google ("gemini-1.5-pro") as the core intelligence. The Instructions: We give the AI very specific instructions (the agent_instructions block you saw) telling it who it is (NaijaFarmHand), what its job is, what topics it should cover, and how to use its tools. The Framework (Google ADK): This is like the plumbing and wiring. It provides the structure (Agent, Runner, SessionService) to define the agent, connect the tools, manage the conversation flow, and remember what was said previously in the chat (InMemorySessionService). The Interaction: You type a question (e.g., "What do I need for a small backyard poultry farm?"). The Runner passes this to the Agent (NaijaFarmHand). The Agent, guided by its instructions, decides which tool is best. In this case, probably the FarmPlannerTool. It calls the tool, gets the checklist back. It formats the checklist into a friendly response. The Runner delivers the response back to you. If you asked "What's the weather in Kano?", it would use the Weathe

Apr 20, 2025 - 06:40
 0
Learn Google ADK: Build a farming agent.

Meet NaijaFarmHand: Your AI Farming Buddy for Nigeria

Ever felt overwhelmed starting a small farm? Wondering when the best time to plant your maize is, what you actually need to start raising chickens, or what the weather will be like tomorrow in your specific town? Getting practical, localized farming information can sometimes feel like searching for a needle in a haystack, especially when you're just starting out.

Imagine having a helpful assistant, powered by Artificial Intelligence (like the technology behind ChatGPT or Google Gemini), specifically designed to answer your beginner farming questions within the Nigerian context. This project isn't about replacing experienced farmers or extension agents, but about providing a quick, accessible first point of contact for common queries.

Built using Google's AI Development Kit (ADK) and running within a Kaggle Notebook environment (a popular platform for data science and AI projects), NaijaFarmHand aims to bridge the information gap for aspiring and early-stage farmers focusing on some of Nigeria's key agricultural products.

Before we dive in, here’s a bit of background: this project was completed as part of the 5-Day Gen AI Intensive course by Google.

If you want to jump straight to the code, find link to the kaggle notebook at the end of the article.

What Can NaijaFarmHand Actually Do?

Think of NaijaFarmHand as having a few specialized skills, like different tools in a farmer's toolkit. It's specifically focused on:

  • Crops: Maize, Cassava, Yam, Groundnut, and Guinea Corn.
  • Livestock: Poultry (Broiler and Layer Chickens).

If you ask about growing strawberries or raising snails, it will politely tell you that's outside its current expertise but might try to find general information using Google Search.

Here are its main "tools":

  1. WeatherTool - The Local Forecaster:

    • What it does: Gets you the current weather conditions for a specific Nigerian location. Need to know if it's likely to rain in Ibadan today before planting? Ask NaijaFarmHand, and it will use this tool.
    • Why it's important: Weather is critical for day-to-day farming decisions. This tool uses the OpenWeatherMap API (powered by a secret API key safely stored using Kaggle Secrets) to fetch real-time data.
  2. FarmPlannerTool - The Starter Checklist Generator:

    • What it does: Provides a basic checklist of things to consider when starting a specific type of farm (from its focus list) at a particular scale (e.g., "small scale maize farm" or "50 broiler chickens").
    • Why it's important: Gives beginners a rough idea of requirements like land, basic capital estimates (with a big disclaimer that costs vary!), simple tools, and initial inputs. It helps structure initial planning.
  3. TimingAdvisorTool - The Seasonal Guide:

    • What it does: Offers general advice on typical planting seasons and harvest times for its focus crops in different broad regions of Nigeria (North, Middle Belt, South).
    • Why it's important: Helps understand the usual agricultural calendar. Crucially, NaijaFarmHand is programmed to always remind you that this is general advice and you MUST check the current local weather (using the WeatherTool) and talk to local farmers for precise timing. Climate varies!
  4. google_search_grounding - The Researcher:

    • What it does: For questions that the other tools can't answer directly, NaijaFarmHand uses Google Search. This is used for finding details on specific crop varieties suitable for Nigeria, identifying pests/diseases, getting an idea of market prices (which fluctuate wildly!), or learning about government agricultural programs.
    • Why it's important: Provides a way to access the vast information online, guided by the agent's instructions to find relevant answers for the user.

How Does It All Work Together?

You don't need to be an AI expert to understand the basics:

  1. The Brain: The project uses a powerful language model from Google ("gemini-1.5-pro") as the core intelligence.
  2. The Instructions: We give the AI very specific instructions (the agent_instructions block you saw) telling it who it is (NaijaFarmHand), what its job is, what topics it should cover, and how to use its tools.
  3. The Framework (Google ADK): This is like the plumbing and wiring. It provides the structure (Agent, Runner, SessionService) to define the agent, connect the tools, manage the conversation flow, and remember what was said previously in the chat (InMemorySessionService).
  4. The Interaction:
    • You type a question (e.g., "What do I need for a small backyard poultry farm?").
    • The Runner passes this to the Agent (NaijaFarmHand).
    • The Agent, guided by its instructions, decides which tool is best. In this case, probably the FarmPlannerTool.
    • It calls the tool, gets the checklist back.
    • It formats the checklist into a friendly response.
    • The Runner delivers the response back to you.
    • If you asked "What's the weather in Kano?", it would use the WeatherTool. If you asked "Tell me about Fall Armyworm control in Maize," it would likely use the google_search_grounding tool.

Why Build Something Like NaijaFarmHand?

This project demonstrates how modern AI tools can be tailored to solve specific, localized problems. It's about:

  • Accessibility: Making basic farming information readily available through a simple chat interface.
  • Localization: Focusing specifically on Nigerian crops, conditions, and context.
  • Practicality: Integrating tools like weather and planning checklists directly into the conversation.
  • Learning: It's a great example of building agents with multiple tools using the Google ADK framework.

While NaijaFarmHand is a prototype running in a notebook, it showcases the potential for AI to support agriculture and empower individuals starting their farming journey in Nigeria. It emphasizes providing helpful guidance while always encouraging users to seek detailed, local expert advice for critical decisions.

Link to Kaglle Notebook: https://www.kaggle.com/code/stephennwankwo/naijafarmhand-agent

More about Google ADK: https://google.github.io/adk-docs/