Skip to content

yasio90/meetoptics-ex3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Exercise 3: Gemini Agent - Supplier Category Finder

This project implements a Python-based agent that uses Google's Gemini model to determine the most relevant MEETOPTICS category for a given product.

Architectural Approach

The agent's logic is split into a sequential, two-stage process. This approach was chosen to work around a limitation in the Gemini API that prevents the use of native (GoogleSearch) and custom tools in a single API call.

The process is as follows:

  1. Discoverer Chat: A Gemini chat instance is created with access to only the Google Search tool. It is given the user's question and tasked with finding a technical description of the product.

  2. Categorizer Chat: A second, independent chat instance is created with access to only the custom search_meetoptics_categories tool. It is given the description from the first phase and tasked with finding the best matching category from the MEETOPTICS database.


How to Run

Prerequisites

  • Python 3.10+
  • We recommend creating and activating a new virtual environment.

1. Setup

1. Configure your API Key: Rename .env.example to .env and add your GOOGLE_API_KEY.

2. Install Dependencies: Install the required packages from the requirements.txt lock file.

pip install -r requirements.txt

2. Running the Agent

To run the agent, execute the agent.py script.

Default Usage: This will run the agent with the default example question ("What is the category from MEETOPTICS that best describes the product Lampo from Bright Solutions?").

python agent.py

Custom Question: To specify a different product, provide the question as a command-line argument.

python agent.py "What is the category for the product ABC from company XYZ?"

3. Testing the Custom Tool

To test the search_meetoptics_categories tool in isolation, you can use the test-tool command followed by a descriptive phrase.

# Usage
python agent.py test-tool <search_phrase>

# Example
python agent.py test-tool "high power femtosecond laser"

Project Outputs

Upon successful execution, the script will:

  • Print the final, categorized answer to the console.
  • Save a detailed execution log to logs/agent_run.log.
  • Save a full JSON trace of the agent's interactions to logs/agent_trace.json, which can be used for debugging and monitoring.

About

Small Python agent that uses Gemini and determines the most relevant MEETOPTICS category for a given product

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages