alamanna commited on
Commit
599ec5e
·
verified ·
1 Parent(s): 71efd02

Update functionalities.py

Browse files
Files changed (1) hide show
  1. functionalities.py +32 -0
functionalities.py CHANGED
@@ -4,6 +4,38 @@ from bs4 import BeautifulSoup
4
  import re
5
  from typing import Dict
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  # Tool with valid docstring and input description
8
  @tool
9
  def find_commutativity_counterexample_elements(_: str) -> str:
 
4
  import re
5
  from typing import Dict
6
 
7
+ @tool
8
+ def get_botanical_vegetables(items: str) -> str:
9
+ """
10
+ Filters and returns botanical vegetables from a comma-separated grocery list.
11
+ Excludes botanical fruits and other plant reproductive parts.
12
+
13
+ Args:
14
+ items (str): Comma-separated list of grocery items.
15
+
16
+ Returns:
17
+ str: Comma-separated list of botanical vegetables, sorted alphabetically.
18
+ """
19
+ vegetable_terms = {
20
+ "acorns", # seed-like, starchy food
21
+ "basil", # leaf
22
+ "broccoli", # flower buds/stalk
23
+ "celery", # stem
24
+ "lettuce", # leaf
25
+ "peanuts", # underground legumes
26
+ "sweet potatoes" # root
27
+ }
28
+
29
+ # Normalize items by removing common modifiers
30
+ def normalize(item: str) -> str:
31
+ tokens = item.lower().strip().split()
32
+ keywords = [word for word in tokens if word not in {"fresh", "whole", "bean"}]
33
+ return " ".join(keywords)
34
+
35
+ parsed = [normalize(item) for item in items.split(",")]
36
+ veg = sorted(item for item in parsed if item in vegetable_terms)
37
+ return ", ".join(veg)
38
+
39
  # Tool with valid docstring and input description
40
  @tool
41
  def find_commutativity_counterexample_elements(_: str) -> str: