RozzaCreat commited on
Commit
9c14e75
·
verified ·
1 Parent(s): 1d6e15c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -19
app.py CHANGED
@@ -10,39 +10,32 @@ from Gradio_UI import GradioUI
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
- def food_nutrition(food: str) -> str:
14
- """A tool that takes a food name as input and performs a web search
15
- to find its calories, fat, carbs, and protein per 100g.
16
  Args:
17
- food: A string representing a food item.
18
  Returns:
19
- A formatted string containing nutritional information.
20
  """
21
  try:
22
  search_tool = DuckDuckGoSearchTool() # Requires smolagents
23
- query = f"Nutritional facts per 100g of {food} (calories, fat, carbs, protein)"
24
  results = search_tool(query)
25
 
26
  if results:
27
- # You will need to extract actual values from the results.
28
  # For now, here are mock placeholders:
29
- calories = "XXX kcal"
30
- fat = "YY g"
31
- carbs = "ZZ g"
32
- protein = "WW g"
33
-
34
  return (
35
- f"Nutritional information for 100g of {food}:\n"
36
- f" * Calories: {calories}\n"
37
- f" * Fat: {fat}\n"
38
- f" * Carbs: {carbs}\n"
39
- f" * Protein: {protein}"
40
  )
41
  else:
42
- return f"Sorry, I couldn't find any nutritional data for {food}."
43
 
44
  except Exception as e:
45
- return f"Error fetching nutritional facts for '{food}': {e}. Please check the spelling or try anothr"
46
 
47
  '''
48
 
 
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
+ def name_poem(food: str) -> str:
14
+ """A tool that takes a name as input and performs a web search
15
+ to find funny poems containts this name.
16
  Args:
17
+ food: A string representing a name.
18
  Returns:
19
+ A formatted string containing poem with this name
20
  """
21
  try:
22
  search_tool = DuckDuckGoSearchTool() # Requires smolagents
23
+ query = f"Poem with {name} "
24
  results = search_tool(query)
25
 
26
  if results:
27
+ # You will need to extract poem from the results.
28
  # For now, here are mock placeholders:
29
+
 
 
 
 
30
  return (
31
+ f"Poem for {name}:\n"
32
+
 
 
 
33
  )
34
  else:
35
+ return f"Sorry, I couldn't find any poem {name}."
36
 
37
  except Exception as e:
38
+ return f"Error fetching poem for '{name}': {e}. Please check the spelling or try anothr"
39
 
40
  '''
41