This project implements a Python-based agent that uses Google's Gemini model to determine the most relevant MEETOPTICS category for a given product.
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:
-
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.
-
Categorizer Chat: A second, independent chat instance is created with access to only the custom
search_meetoptics_categoriestool. It is given the description from the first phase and tasked with finding the best matching category from the MEETOPTICS database.
- Python 3.10+
- We recommend creating and activating a new virtual environment.
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.txtTo 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.pyCustom 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?"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"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.