Skip to content

This project implements an AI agent that can interact with Google's Gemini model, fetch summaries from Wikipedia, and retrieve news articles

Notifications You must be signed in to change notification settings

Saketh1702/agentic-ai

Repository files navigation

Project Description

This project implements an AI agent that can interact with Google's Gemini model, fetch summaries from Wikipedia, and retrieve news articles.

Features

  • Gemini Integration: Uses Google's Gemini model to answer prompts and generate text.
  • Wikipedia Lookup: Fetches summaries from Wikipedia based on a given topic.
  • News Retrieval: Retrieves recent news articles related to a specified keyword using the News API.
  • Task History: Keeps track of executed tasks and their responses.

Prerequisites

  • Python 3.7 or higher
  • Install the required packages:
    pip install -r requirements.txt
  • Set the following environment variables:
    • GOOGLE_API_KEY: Your Google Gemini API key.
    • NEWS_API_KEY: Your News API key (optional, for news functionality).

Running the Application

  1. Clone the repository (if applicable).
  2. Navigate to the project directory.
  3. Create a .env file in the project root and add your API keys:
    GOOGLE_API_KEY=YOUR_GOOGLE_API_KEY
    NEWS_API_KEY=YOUR_NEWS_API_KEY
    
  4. Run the main script:
    python main.py

File Changes in main.py

  • Import Statements: Added necessary import statements for google.generativeai, requests, json, datetime, os, sys, dotenv, and typing.
  • Environment Variable Loading: Implemented loading of environment variables using dotenv to securely store API keys.
  • AdvancedAgent Class:
    • Added a class AdvancedAgent to encapsulate the AI agent's functionality.
    • Includes methods for interacting with Gemini (ask_gemini), fetching Wikipedia summaries (fetch_wikipedia_summary), fetching news articles (fetch_news), and executing tasks (execute_task).
    • Includes a task_log to store executed tasks and their responses.
    • Includes a _manage_memory method to manage the agent's memory.
  • Main Function:
    • Initializes the AI agent and handles user input.
    • Provides a command-line interface for interacting with the agent.
    • Handles exceptions and provides informative error messages.
  • Error Handling: Implemented comprehensive error handling throughout the code to catch potential issues with API requests, environment variables, and user input.

About

This project implements an AI agent that can interact with Google's Gemini model, fetch summaries from Wikipedia, and retrieve news articles

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published