Tbaberca commited on
Commit
b879404
·
verified ·
1 Parent(s): 8c5c24b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -17,6 +17,19 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
17
  arg2: the second argument
18
  """
19
  return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -34,7 +47,8 @@ def get_current_time_in_timezone(timezone: str) -> str:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
 
37
- final_answer = FinalAnswerTool()
 
38
 
39
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
40
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
@@ -50,12 +64,13 @@ custom_role_conversions=None,
50
  # Import tool from Hub
51
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
52
 
 
53
  with open("prompts.yaml", 'r') as stream:
54
  prompt_templates = yaml.safe_load(stream)
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
@@ -64,6 +79,3 @@ agent = CodeAgent(
64
  description=None,
65
  prompt_templates=prompt_templates
66
  )
67
-
68
-
69
- GradioUI(agent).launch()
 
17
  arg2: the second argument
18
  """
19
  return "What magic will you build ?"
20
+
21
+ @tool
22
+ def generate_cat_image(description: str = "a cute cat sitting on a windowsill", size: str = "512x512") -> str:
23
+ """
24
+ Generates an image of a cat based on a text prompt.
25
+
26
+ Args:
27
+ description: Description of the cat image.
28
+ size: Image resolution, e.g., "512x512".
29
+ """
30
+ image_result = image_generation_tool(prompt=description, size=size)
31
+ # Assuming the tool returns a URL or displayable image path
32
+ return image_result
33
 
34
  @tool
35
  def get_current_time_in_timezone(timezone: str) -> str:
 
47
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
48
 
49
 
50
+ tools=[final_answer, generate_cat_image],
51
+
52
 
53
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
54
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
 
64
  # Import tool from Hub
65
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
66
 
67
+ # Load system prompt from prompt.yaml file
68
  with open("prompts.yaml", 'r') as stream:
69
  prompt_templates = yaml.safe_load(stream)
70
 
71
  agent = CodeAgent(
72
  model=model,
73
+ tools=[final_answer, generate_cat_image], # Updated to include the image generation tool
74
  max_steps=6,
75
  verbosity_level=1,
76
  grammar=None,
 
79
  description=None,
80
  prompt_templates=prompt_templates
81
  )