JayosChaos commited on
Commit
72c91b0
·
verified ·
1 Parent(s): 8ea4bd1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -15
app.py CHANGED
@@ -7,30 +7,29 @@ from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
9
 
10
- # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
 
12
  @tool
13
- def generate_huggingface_image(prompt: str, model: str = "stabilityai/stable-diffusion-2") -> str:
14
- """A tool that generates images using Hugging Face's HfApiModel.
15
 
16
  Args:
17
- prompt: The text description of the image to generate.
18
- model: The model to use for image generation (default: stabilityai/stable-diffusion-2).
19
 
20
  Returns:
21
- URL of the generated image.
22
  """
23
-
24
- # Send the prompt to the Hugging Face model
25
- response = client.text_to_image(model=model, prompt=prompt)
26
 
27
- # Save the response image
28
- image_path = "generated_image.png"
29
- with open(image_path, "wb") as f:
30
- f.write(response)
31
 
32
- return image_path
 
 
 
 
33
 
 
34
  @tool
35
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
36
  #Keep this format for the description / args / args description but feel free to modify the tool
@@ -78,7 +77,7 @@ with open("prompts.yaml", 'r') as stream:
78
 
79
  agent = CodeAgent(
80
  model=model,
81
- tools=[final_answer], ## add your tools here (don't remove final answer)
82
  max_steps=6,
83
  verbosity_level=1,
84
  grammar=None,
 
7
 
8
  from Gradio_UI import GradioUI
9
 
 
10
 
11
  @tool
12
+ def get_nbp_exchange_rate(currency: str) -> float:
13
+ """A tool that fetches the exchange rate of a given currency from the National Bank of Poland (NBP).
14
 
15
  Args:
16
+ currency: The currency code (e.g., "USD", "EUR") to fetch the exchange rate for.
 
17
 
18
  Returns:
19
+ The exchange rate of the specified currency in PLN.
20
  """
21
+ import requests
 
 
22
 
23
+ url = f"https://api.nbp.pl/api/exchangerates/rates/A/{currency}/?format=json"
24
+ response = requests.get(url)
 
 
25
 
26
+ if response.status_code == 200:
27
+ data = response.json()
28
+ return data["rates"][0]["mid"]
29
+ else:
30
+ raise ValueError(f"Failed to fetch exchange rate for {currency}. HTTP Status: {response.status_code}")
31
 
32
+ # Below is an example of a tool that does nothing. Amaze us with your creativity !
33
  @tool
34
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
35
  #Keep this format for the description / args / args description but feel free to modify the tool
 
77
 
78
  agent = CodeAgent(
79
  model=model,
80
+ tools=[get_nbp_exchange_rate, get_current_time_in_timezone, image_generation_tool, final_answer], ## add your tools here (don't remove final answer)
81
  max_steps=6,
82
  verbosity_level=1,
83
  grammar=None,