Skip to content

Bug: Feature Request: Add a Generative AI (Gemini) Agent Example #144

@Neelr1912

Description

@Neelr1912

Summary

Currently, many of the basic examples focus on simple ping-pong messaging or fetching static APIs. You can propose adding an agent that integrates with a modern LLM API to process natural language.

How to build it: Create a Python agent using the uagents framework that imports the google-generativeai package. The agent would receive a text prompt via a message protocol, query the Gemini API, and return the synthesized response to the sender.

Why it stands out: Fetch.ai is all about AI agents, but many beginners struggle to bridge the gap between the communication framework and actual Large Language Models. This provides a plug-and-play template.

Steps to reproduce

🔄 Steps to Reproduce / Execute the Example

To verify the integration and see the Generative AI agent in action, a user would follow these steps:

  1. Navigate to the new example directory:
    cd innovation-lab-examples/gemini_ai_assistant

  2. Install the required dependencies:
    pip install -r requirements.txt
    (Dependencies will include uagents and google-generativeai)

  3. Set up the Gemini API Key:
    export GEMINI_API_KEY="your_actual_api_key_here"

  4. Run the agent scripts:

    • Open two terminal windows.
    • In Terminal 1, start the user proxy agent:
      python user_agent.py
    • In Terminal 2, start the Gemini AI assistant agent:
      python gemini_agent.py
  5. Observe the interaction:

    • The user_agent sends a message payload containing a natural language prompt (e.g., "Explain quantum computing in simple terms").
    • The gemini_agent receives the message, invokes the Google Gemini API using the securely configured environment variable, gets the response, and replies back to the user_agent.

🎯 Expected Behavior

  • The agents should successfully register on the local or testnet Almanac contract.
  • The communication between the two agents must remain entirely asynchronous using the uagents native messaging protocol.
  • The response received from the Gemini API should print clearly in the user_agent logs without truncation or authentication failures.

Expected behavior

When the new Generative AI example is executed, a user should be able to send a natural language prompt via a user_agent. The gemini_agent will receive this message, query the Google Gemini API, and successfully return the AI-generated response back to the user agent via the uagents messaging protocol.

Actual behavior

Currently, the repository lacks an example demonstrating how to integrate modern Large Language Models (like Google Gemini) with the uagents framework. Developers looking to build AI-driven agents must build the integration architecture from scratch without a reference example.

Affected file or folder path

No response

Logs / traceback

Environment

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions