csiadat commited on
Commit
08b4e15
·
verified ·
1 Parent(s): da3c86e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -3,6 +3,7 @@ import datetime
3
  import requests
4
  import pytz
5
  import yaml
 
6
  from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
@@ -24,11 +25,14 @@ def create_new_vday_card_tool(theme:str) -> str: #it's import to specify the ret
24
  description="Generate image from prompt"
25
  )
26
  '''
27
- image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
28
- image = image_generation_tool(theme)
29
- return final_answer(image)
 
 
 
30
  except Exception as e:
31
- return f"Error creating image for theme '{theme}': {str(e)}"
32
 
33
  '''
34
  @tool
 
3
  import requests
4
  import pytz
5
  import yaml
6
+ import re
7
  from tools.final_answer import FinalAnswerTool
8
 
9
  from Gradio_UI import GradioUI
 
25
  description="Generate image from prompt"
26
  )
27
  '''
28
+ if re.search("Valentine's Day card", prompt) != None:
29
+ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
30
+ image = image_generation_tool(theme)
31
+ return final_answer(image)
32
+ else:
33
+ return f"You did not prompt the agent for a Valentine's Day card, please try again"
34
  except Exception as e:
35
+ return f"Error creating card for theme '{theme}': {str(e)}"
36
 
37
  '''
38
  @tool