BioCodeFusion commited on
Commit
5c2b81b
·
verified ·
1 Parent(s): 97b0074

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py CHANGED
@@ -18,6 +18,32 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
18
  """
19
  return "What magic will you build ?"
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
23
  """A tool that fetches the current local time in a specified timezone.
@@ -36,6 +62,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
36
 
37
  final_answer = FinalAnswerTool()
38
 
 
39
  # 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:
40
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
41
 
 
18
  """
19
  return "What magic will you build ?"
20
 
21
+ @tool
22
+ def grocery_info(version=1, grocery_id=1, sprak=2) -> str:
23
+ """A tool that fetches the grocery information from the Swedish Food Agency api
24
+ Args:
25
+ version: version of tool argument.
26
+ grocery_id: The id of the grocery (e.g, and int expected)
27
+ language: Choose between Swedish or English language: (1 for Swedish, set to two for English)
28
+
29
+ """
30
+
31
+ base_url = "https://dataportal.livsmedelsverket.se/livsmedel"
32
+ grocery_api_url = f"{base_url}/api/v{version}/livsmedel/{grocery_id}?sprak={sprak}"
33
+
34
+ response = requests.get(grocery_api_url)
35
+ data = response.json()
36
+
37
+ if response.status_code == 200:
38
+ data = response.json()
39
+ grocery_description = data.get("namn")
40
+ grocery_ingredients = data.get("links")[2]['href']
41
+ return grocery_description, grocery_ingredients_link
42
+ else:
43
+ return "Error: Unable to find grocery data."
44
+
45
+
46
+
47
  @tool
48
  def get_current_time_in_timezone(timezone: str) -> str:
49
  """A tool that fetches the current local time in a specified timezone.
 
62
 
63
  final_answer = FinalAnswerTool()
64
 
65
+
66
  # 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:
67
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
68