vechism commited on
Commit
174cd57
·
verified ·
1 Parent(s): a4b7915

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -18
app.py CHANGED
@@ -9,26 +9,47 @@ from Gradio_UI import GradioUI
9
 
10
 
11
  @tool
12
- def mutant_unicorn(animal_name:str) -> str:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  """
14
- A tool that generates an image of a mutant unicorn given an animal name.
15
- Args:
16
- animal_name: A string containing the name of an animal, real or mytical. (e.g., 'lion, dragon, worm, etc')
17
- Returns:
18
- The generated image or an error message.
19
- """
20
- description = f"""Close-up photograph of a/an {animal_name} unicorn with butterfly wings holding
21
- a small brightfull orb with its tiny paws, looking at the center of the orb with a
22
- concentrated gaze. The unicorn is in a clearing in the forest on a moonlit night
23
- """
24
-
25
  try:
26
  # Import tool from Hub
 
 
 
 
 
 
 
27
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
28
- image = image_generation_tool(description)
29
  return final_answer(image)
30
  except Exception as e:
31
- return f"Error creating mutant animal '{description}': {str(e)}"
32
 
33
  final_answer = FinalAnswerTool()
34
 
@@ -42,10 +63,6 @@ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may
42
  custom_role_conversions=None,
43
  )
44
 
45
-
46
- # Import tool from Hub
47
- # image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
48
-
49
  with open("prompts.yaml", 'r') as stream:
50
  prompt_templates = yaml.safe_load(stream)
51
 
 
9
 
10
 
11
  @tool
12
+ #def mutant_unicorn(animal_name:str) -> str:
13
+ # """
14
+ # A tool that generates an image of a mutant unicorn given an animal name.
15
+ # Args:
16
+ # animal_name: A string containing the name of an animal, real or mytical. (e.g., 'lion, dragon, worm, etc')
17
+ # Returns:
18
+ # The generated image or an error message.
19
+ # """
20
+ # description = f"""Close-up photograph of a/an {animal_name} unicorn with butterfly wings holding
21
+ # a small brightfull orb with its tiny paws, looking at the center of the orb with a
22
+ # concentrated gaze. The unicorn is in a clearing in the forest on a moonlit night
23
+ # """
24
+ #
25
+ # try:
26
+ # # Import tool from Hub
27
+ # image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
28
+ # image = image_generation_tool(description)
29
+ # return final_answer(image)
30
+ # except Exception as e:
31
+ # return f"Error creating mutant animal '{description}': {str(e)}"
32
+ #
33
+ def mutant_unicorn(theme:str) -> str: #it's import to specify the return type
34
+ #Keep this format for the description / args / args description but feel free to modify the tool
35
+ """A tool that generates a custom Valentine's Day card based on a given theme.
36
+ Args:
37
+ theme: A string representing the theme for the Valentine's Day card.
38
  """
 
 
 
 
 
 
 
 
 
 
 
39
  try:
40
  # Import tool from Hub
41
+ '''
42
+ image_generation_tool = Tool.from_space(
43
+ space_id="black-forest-labs/FLUX.1-schnell",
44
+ name="generate-image",
45
+ description="Generate image from prompt"
46
+ )
47
+ '''
48
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
49
+ image = image_generation_tool(theme)
50
  return final_answer(image)
51
  except Exception as e:
52
+ return f"Error creating card for theme '{theme}': {str(e)}"
53
 
54
  final_answer = FinalAnswerTool()
55
 
 
63
  custom_role_conversions=None,
64
  )
65
 
 
 
 
 
66
  with open("prompts.yaml", 'r') as stream:
67
  prompt_templates = yaml.safe_load(stream)
68