DragonProgrammer commited on
Commit
c0846ad
·
verified ·
1 Parent(s): 631ad2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -3
app.py CHANGED
@@ -12,7 +12,7 @@ from Gradio_UI import GradioUI
12
  # Sous chef that will fetch recipes off the web for you, given a food.
13
  @tool
14
  def sous_chef(food:str)-> str: #it's import to specify the return type
15
- """A tool that fetches recipes off the web for you
16
  Args:
17
  food: the food that you want a recipe for
18
  """
@@ -21,8 +21,23 @@ def sous_chef(food:str)-> str: #it's import to specify the return type
21
  search_results = search(query, num_results=5)
22
 
23
  for url in search_results:
24
- if "allrecipes.com" in url:
25
- print("Here's the top result:" + url)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  # Tutorial tool that fetches the time in a timezone.
28
  @tool
 
12
  # Sous chef that will fetch recipes off the web for you, given a food.
13
  @tool
14
  def sous_chef(food:str)-> str: #it's import to specify the return type
15
+ """A tool that, given a recipe, will attempt to fetch a result off of well-known recipe sites.
16
  Args:
17
  food: the food that you want a recipe for
18
  """
 
21
  search_results = search(query, num_results=5)
22
 
23
  for url in search_results:
24
+ if f"seriouseats.com/search?q={food}" in url:
25
+ return f"Here's a result from Serious Eats: {url} "
26
+ elif f"allrecipes.com/?q={food}" in url:
27
+ return f"Here's a result from allrecipes.com: {url} "
28
+ elif f"pinchofyum.com/?s={food}" in url:
29
+ return f"Here's a result from Pinch of Yum: {url} "
30
+ elif f"budgetbytes.com/?s={food}" in url:
31
+ return f"Here's a result from Budget Bytes: {url} "
32
+ elif f"chefspencil.com/?s={food}" in url:
33
+ return f"Here's a result from Chef's Pencil: {url} "
34
+ else:
35
+ return "Could not find result on major platforms."
36
+
37
+ except Exception as e:
38
+ return f"Error fetching recipe for '{food}': {str(e)}"
39
+
40
+
41
 
42
  # Tutorial tool that fetches the time in a timezone.
43
  @tool