csiadat commited on
Commit
3987b27
·
verified ·
1 Parent(s): dcf203d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -9,19 +9,14 @@ 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 create_new_valentines_day_card(theme: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 generates a custom Valentine's Day card based on a given theme.
15
  Args:
16
  theme: A string representing the theme for the Valentine's Day card.
17
  """
18
  try:
19
- imageGenTool = Tool.from_space(
20
- "black-forest-labs/FLUX.1-schnell",
21
- name = "image generator",
22
- description = "Generate image from prompt"
23
- )
24
- imageGenTool(theme)
25
  except Exception as e:
26
  return f"Error creating image for theme '{theme}': {str(e)}"
27
 
@@ -58,12 +53,13 @@ custom_role_conversions=None,
58
  # Import tool from Hub
59
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
60
 
 
61
  with open("prompts.yaml", 'r') as stream:
62
  prompt_templates = yaml.safe_load(stream)
63
 
64
  agent = CodeAgent(
65
  model=model,
66
- tools=[create_new_valentines_day_card, final_answer], ## add your tools here (don't remove final answer)
67
  max_steps=6,
68
  verbosity_level=1,
69
  grammar=None,
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def create_new_vday_card_tool(theme: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 generates a custom Valentine's Day card based on a given theme.
15
  Args:
16
  theme: A string representing the theme for the Valentine's Day card.
17
  """
18
  try:
19
+ image_generation_tool(theme)
 
 
 
 
 
20
  except Exception as e:
21
  return f"Error creating image for theme '{theme}': {str(e)}"
22
 
 
53
  # Import tool from Hub
54
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
55
 
56
+
57
  with open("prompts.yaml", 'r') as stream:
58
  prompt_templates = yaml.safe_load(stream)
59
 
60
  agent = CodeAgent(
61
  model=model,
62
+ tools=[final_answer, create_new_vday_card_tool, image_generation_tool] ## add your tools here (don't remove final answer)
63
  max_steps=6,
64
  verbosity_level=1,
65
  grammar=None,