shrewd-agent / README.md
Romaric
doc: README with project details and setup instructions
6846067

A newer version of the Gradio SDK is available: 5.34.2

Upgrade
metadata
title: Shrewd Agent
emoji: πŸ”₯
colorFrom: red
colorTo: indigo
sdk: gradio
sdk_version: 5.31.0
app_file: app.py
license: mit
pinned: false
hf_oauth: true
hf_oauth_expiration_minutes: 480
short_description: Agent for the final hands-on assignment of the Agents course

ShrewdAgent - AI agent implementation

Welcome to the repository of our AI agent designed to meet the challenges of GAIA Benchmark Level.

This project is the culmination of Hugging Face's Agent Courses efforts, which you can explore here.

Overview

The GAIA benchmark serves as a rigorous evaluation tool for AI assistants, focusing on real-world tasks that require a blend of reasoning, multimodal understanding, web browsing, and proficient tool use. It was introduced in the paper "GAIA: A Benchmark for General AI Assistants" and features 466 carefully curated questions that, while conceptually simple for humans, present significant challenges for current AI systems.

Dataset

For our implementation, we used a dataset comprising 20 questions extracted from the Level 1 validation set of GAIA. These questions were meticulously filtered by the Hugging Face team based on the number of tools and steps required to arrive at a solution. Our goal is to achieve the best success rate on these Level 1 questions.

GAIA's Core Principles

GAIA is built around several key principles:

  • Real-world Difficulty: Tasks require multistep reasoning, multimodal understanding, and interaction with various tools.
  • Human Interpretability: While challenging for AI, tasks remain straightforward and easy for humans to comprehend.
  • Non-gameability: Correct answers require complete task execution, rendering brute-force methods ineffective.
  • Simplicity of Evaluation: Answers are concise, factual, and unambiguous, making them ideal for benchmarking.

Difficulty Levels:

The GAIA tasks are categorized into three levels of increasing complexity:

  • Level 1: Requires fewer than 5 steps and minimal tool usage.
  • Level 2: Involves more complex reasoning and coordination between multiple tools, requiring 5-10 steps.
  • Level 3: Demands long-term planning and advanced integration of various tools.

Our AI agent is specifically designed to navigate the challenges presented at Level 1, which includes structured response formats, multimodal reasoning, and multi-hop retrieval of interdependent facts.

Core Agent Architecture

The system is built around an AI agent architecture that combines LangGraph and LangChain frameworks to create a flexible and powerful question-answering system.

Key Components

State Management

  • Implements a state-based processing system using StateGraph
  • Maintains conversation context through AgentState
  • Handles message flow between components

LLM Integration

  • Uses GPT-4.1 as the base language model
  • Configured for deterministic responses (temperature=0)
  • Tightly integrated with a suite of specialized tools

Tool Integration

  • Modular tool system for extensible functionality
  • Tools are dynamically bound to the LLM
  • Included capabilities:
    • Data Processing Tools
      • Converts Excel files to text representation
      • Alphabetically sorts word lists
      • Performs integer addition
    • AI/ML Tools
      • Converts speech to text using Whisper
      • Classifies foods as fruits or vegetables using GPT-4
    • Information Retrieval Tools
      • Searches Wikipedia
      • Extracts web page content
      • Gets YouTube video transcripts
      • General web search capability

Processing Flow

graph LR
 A[Start] --> B[Assistant Node]
 B --> C{Tools Condition}
 C -->|Tool Needed| D[Tool Node]
 D --> B
 C -->|No Tool Needed| E[Final Response]

Features

  • Multimodal Processing: Handles text, images, audio, and structured data
  • Contextual Understanding: Interprets questions in their proper context
  • Adaptive Tool Selection: Chooses the most appropriate tools for each task
  • Error Handling: Gracefully manages failed tool executions with retry mechanisms
  • Explanation Generation: Provides reasoning for answers when needed

Performance

The Shrewd Agent achieved a 70% success rate, successfully answering 14-out-of-20 questions. The agent demonstrates particular strength in:

  • Text-based information retrieval tasks
  • Audio transcription and processing
  • Logical reasoning

The agent faced main difficulties into:

  • Image analysis and reasoning
  • Computational problem-solving

Note: complex video analysis requiring frame-by-frame attention to several visual elements simultaneously has not been implemented.

Results

Question Answer
How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia. βœ”
In the video https://www.youtube.com/watch?v=L1vXCYZAYYM, what is the highest number of bird species to be on camera simultaneously? ❌
.rewsna eht sa "tfel" drow eht fo etisoppo eht etirw ,ecnetnes siht dnatsrednu uoy fI βœ”
Review the chess position provided in the image. It is black's turn. Provide the correct next move for black which guarantees a win. Please provide your response in algebraic notation. ❌
Who nominated the only Featured Article on English Wikipedia about a dinosaur that was promoted in November 2016? βœ”
Given this table defining * on the set S = {a, b, c, d, e} provide the subset of S involved in any possible counter-examples that prove * is not commutative. Provide your answer as a comma separated list of the elements in the set in alphabetical order. ❌
Examine the video at https://www.youtube.com/watch?v=1htKBjuUWec. What does Teal'c say in response to the question "Isn't that hot?" βœ”
What is the surname of the equine veterinarian mentioned in 1.E Exercises from the chemistry materials licensed by Marisa Alviar-Agnew & Henry Agnew under the CK-12 license in LibreText's Introductory Chemistry materials as compiled 08/21/2023? βœ”
I'm making a grocery list for my mom, but she's a professor of botany and she's a real stickler when it comes to categorizing things. I need to add different foods to different categories on the grocery list, but if I make a mistake, she won't buy anything inserted in the wrong category. Here's the list I have so far:milk, eggs, flour, whole bean coffee, Oreos, sweet potatoes, fresh basil, plums, green beans, rice, corn, bell pepper, whole allspice, acorns, broccoli, celery, zucchini, lettuce, peanuts I need to make headings for the fruits and vegetables. Could you please create a list of just the vegetables from my list? If you could do that, then I can figure out how to categorize the rest of the list into the appropriate categories. But remember that my mom is a real stickler, so make sure that no botanical fruits end up on the vegetable list, or she won't get them when she's at the store. Please alphabetize the list of vegetables, and place each item in a comma separated list. βœ”
Hi, I'm making a pie but I could use some help with my shopping list. I have everything I need for the crust, but I'm not sure about the filling. I got the recipe from my friend Aditi, but she left it as a voice memo and the speaker on my phone is buzzing so I can't quite make out what she's saying. Could you please listen to the recipe and list all of the ingredients that my friend described? I only want the ingredients for the filling, as I have everything I need to make my favorite pie crust. I've attached the recipe as Strawberry pie.mp3. In your response, please only list the ingredients, not any measurements. So if the recipe calls for "a pinch of salt" or "two cups of ripe strawberries" the ingredients on the list would be "salt" and "ripe strawberries". Please format your response as a comma separated list of ingredients. Also, please alphabetize the ingredients. βœ”
Who did the actor who played Ray in the Polish-language version of Everybody Loves Raymond play in Magda M.? Give only the first name. βœ”
What is the final numeric output from the attached Python code? βœ”
How many at bats did the Yankee with the most walks in the 1977 regular season have that same season? βœ”
Hi, I was out sick from my classes on Friday, so I'm trying to figure out what I need to study for my Calculus mid-term next week. My friend from class sent me an audio recording of Professor Willowbrook giving out the recommended reading for the test, but my headphones are broken :(Could you please listen to the recording for me and tell me the page numbers I'm supposed to go over? I've attached a file called Homework.mp3 that has the recording. Please provide just the page numbers as a comma-delimited list. And please provide the list in ascending order. βœ”
On June 6, 2023, an article by Carolyn Collins Petersen was published in Universe Today. This article mentions a team that produced a paper about their observations, linked at the bottom of the article. Find this paper. Under what NASA award number was the work performed by R. G. Arendt supported by? βœ”
Where were the Vietnamese specimens described by Kuznetzov in Nedoshivina's 2010 paper eventually deposited? Just give me the city name without abbreviations. βœ”
What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer. βœ”
Who are the pitchers with the number before and after Taishō Tamai's number as of July 2023? Give them to me in the form Pitcher Before, Pitcher After, use their last names only, in Roman characters. βœ”
The attached Excel file contains the sales of menu items for a local fast-food chain. What were the total sales that the chain made from food (not including drinks)? Express your answer in USD with two decimal places. ❌
What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists? βœ”

Requirements

Prerequisites

  • Python 3.x
  • Virtual environment (recommended)

API Keys

This project requires the following API keys:

  • OpenAI API key for the ChatGPT model
  • Riza API key for executing Python code
  • Tavily API key for the websearching tool

Set them as environment variables:

export OPENAI_API_KEY='your-api-key'
export RIZA_API_KEY='your-api-key'
export TAVILY_API_KEY='your-api-key'

You can get the required API keys here:

Installation

  1. Clone the repository
  2. Create a virtual environment and activate it
  3. Install the required packages using pip install -r requirements.txt
  4. Set the environment variables (see Prerequisites section)
  5. Run the application using python app.py
  6. Open your web browser and navigate to http://localhost:7860

Acknowledgments

This project was developed as part of the Hugging Face Agents Course. We would like to thank:

  • The creators of the GAIA benchmark for providing a robust evaluation framework
  • Hugging Face for their excellent learning resources and platform
  • OpenAI, Tavily, and Riza for their powerful APIs
  • All contributors and testers who helped improve this project

License

This project is licensed under the MIT License.