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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -8,6 +8,29 @@ from tools.final_answer import FinalAnswerTool
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  @tool
12
  def my_custom_tool(arg1:str, arg2:int)-> 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
 
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