File size: 706 Bytes
e327cd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# vegetable_classifier_tool.py
from langchain.tools import tool

@tool
def vegetable_classifier_2022(question: str) -> str:
    """
    Classifies common grocery items from a 2022 Wikipedia-based classification.
    Returns a comma-separated list of vegetables excluding all botanical fruits.
    """
    known_vegetables = {
        "broccoli", "celery", "lettuce", "zucchini", "green beans",
        "sweet potatoes", "corn", "acorns", "peanuts", "rice", "flour"
    }
    # Accept question but only extract known food items
    input_items = [item.strip().lower() for item in question.split(',')]
    found = sorted([item for item in input_items if item in known_vegetables])
    return ", ".join(found)