RobotJelly commited on
Commit
6d7162b
·
verified ·
1 Parent(s): 44f9d47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -4,8 +4,6 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
- import PIL
8
- from PIL import Image
9
  from typing import Any, Optional
10
 
11
  #from Gradio_UI import GradioUI
@@ -13,20 +11,16 @@ from smolagents import GradioUI
13
 
14
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
15
  @tool
16
- def my_custom_tool(arg1:str, img: bool)-> Any: #it's import to specify the return type
17
  #Keep this format for the description / args / args description but feel free to modify the tool
18
- """A tool that uses 'DuckDuckGoSearchTool' tool to answer any query and 'image_generation_tool' tool to generate image.
19
  Args:
20
  arg1: string query to be used to search answer via given search tool.
21
- img: boolean value in TRUE/FALSE if TRUE then use `arg1` as prompt for generating image.
22
  """
23
  try:
24
  if img:
25
- # Import tool from Hub
26
- #image_generation_tool = load_tool("dwb2023/text-to-image", trust_remote_code=True)
27
- image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
28
- image_generation_tool(arg1)
29
- #launch_gradio_demo(image_generation_tool(arg1))
30
  else:
31
  search_obj = DuckDuckGoSearchTool()
32
  answer = search_obj(arg1)
@@ -64,14 +58,14 @@ custom_role_conversions=None,
64
 
65
 
66
  # # Import tool from Hub
67
- #image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
68
 
69
  with open("prompts.yaml", 'r') as stream:
70
  prompt_templates = yaml.safe_load(stream)
71
 
72
  agent = CodeAgent(
73
  model=model,
74
- tools=[final_answer,my_custom_tool,get_current_time_in_timezone], ## add your tools here (don't remove final answer)
75
  max_steps=6,
76
  verbosity_level=1,
77
  grammar=None,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
 
7
  from typing import Any, Optional
8
 
9
  #from Gradio_UI import GradioUI
 
11
 
12
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
13
  @tool
14
+ def my_custom_tool(arg1:str, img: bool)-> str: #it's import to specify the return type
15
  #Keep this format for the description / args / args description but feel free to modify the tool
16
+ """A tool that uses 'DuckDuckGoSearchTool' tool to answer any query.
17
  Args:
18
  arg1: string query to be used to search answer via given search tool.
19
+ img: boolean value in TRUE/FALSE if TRUE then use another tool.
20
  """
21
  try:
22
  if img:
23
+ return
 
 
 
 
24
  else:
25
  search_obj = DuckDuckGoSearchTool()
26
  answer = search_obj(arg1)
 
58
 
59
 
60
  # # Import tool from Hub
61
+ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
62
 
63
  with open("prompts.yaml", 'r') as stream:
64
  prompt_templates = yaml.safe_load(stream)
65
 
66
  agent = CodeAgent(
67
  model=model,
68
+ tools=[final_answer,my_custom_tool,image_generation_tool,get_current_time_in_timezone], ## add your tools here (don't remove final answer)
69
  max_steps=6,
70
  verbosity_level=1,
71
  grammar=None,