mandrea98 commited on
Commit
5f46a6b
·
verified ·
1 Parent(s): 493d969

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -11,20 +11,20 @@ from Gradio_UI import GradioUI
11
  @tool
12
  def protein_intake_calculator(fullname:str, weight:int, metric:str)-> str: #it's import to specify the return type
13
  #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that calculates the protein intake of the user. It will do so by verifying which metric the weight
15
- is in and then returning the correct calculation
16
  Args:
17
  fullname: the first argument that takes in a user's full name, so first and last name
18
  weight: the second argument that takes the input weight of a user.
19
  metric: the third argument that takes the input metric of a user.
20
  """
 
21
  try:
22
  # Check which metric the weight is using
23
- if weight.lower() == "kg" or weight.lower() == "kilograms":
24
- protein_intake = weight * 0.8
25
- elif metric.lower() == "lb" or weight.lower() == "pounds":
26
- protein_intake = weight * 0.36
27
- return f"Hello, {fullname}, your recommended protein intake is {str(protein_intake)}"
28
  except Exception as e:
29
  return f"Error reading in metric being used: '{metric}' is not valid."
30
 
@@ -45,6 +45,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
45
 
46
 
47
  final_answer = FinalAnswerTool()
 
48
 
49
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
50
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
 
11
  @tool
12
  def protein_intake_calculator(fullname:str, weight:int, metric:str)-> str: #it's import to specify the return type
13
  #Keep this format for the description / args / args description but feel free to modify the tool
14
+ """A tool that calculates the protein intake of the user. It will do so by verifying the protein
15
+ intake from the first 3 search results
16
  Args:
17
  fullname: the first argument that takes in a user's full name, so first and last name
18
  weight: the second argument that takes the input weight of a user.
19
  metric: the third argument that takes the input metric of a user.
20
  """
21
+ task = f"find the top 3 protein intake recommendations based on {metric}"
22
  try:
23
  # Check which metric the weight is using
24
+ search_tool = DuckDuckGoSearchTool()
25
+ results = search_tool(query=f"Protein intake for {str(weight)} {metric}")
26
+ time.sleep(2)
27
+ return f"Search Results:\n{results}"
 
28
  except Exception as e:
29
  return f"Error reading in metric being used: '{metric}' is not valid."
30
 
 
45
 
46
 
47
  final_answer = FinalAnswerTool()
48
+ search_tool = DuckDuckGoSearchTool()
49
 
50
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
51
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'