Bobricha commited on
Commit
b9bf8b4
·
verified ·
1 Parent(s): 8c21a97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -3
app.py CHANGED
@@ -18,6 +18,28 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
18
  """
19
  return "What magic will you build ?"
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
23
  """A tool that fetches the current local time in a specified timezone.
@@ -39,6 +61,7 @@ final_answer = FinalAnswerTool()
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'
41
 
 
42
  model = HfApiModel(
43
  max_tokens=2096,
44
  temperature=0.5,
@@ -50,18 +73,20 @@ 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,
62
  planning_interval=None,
63
- name=None,
64
- description=None,
65
  prompt_templates=prompt_templates
66
  )
67
 
 
18
  """
19
  return "What magic will you build ?"
20
 
21
+ # tool which i creating. A tool for finding information about an animal
22
+ @tool
23
+ def search_animal_info(animal_name: str) -> str:
24
+ """A tool uses the DuckDuckGo Search Tool to find information about an animal by its name.
25
+ Args:
26
+ animal_name: A string representing the name of the animal to search for (e.g., 'cat').
27
+ """
28
+ search_tool = DuckDuckGoSearchTool()
29
+ search_result = search_tool.run(f"Information about {animal_name}")
30
+ return search_result
31
+
32
+ # tool which i creating. A tool for generating an animal image
33
+ @tool
34
+ def generate_animal_image(animal_description: str) -> str
35
+ """A tool generates an image based on the description of an animal.
36
+ Args:
37
+ animal_description: A string describing the animal to generate an image for.
38
+ """
39
+ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
40
+ image_url = image_generation_tool.run(animal_description)
41
+ return image_url
42
+
43
  @tool
44
  def get_current_time_in_timezone(timezone: str) -> str:
45
  """A tool that fetches the current local time in a specified timezone.
 
61
  # 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:
62
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
63
 
64
+ # configuring the model
65
  model = HfApiModel(
66
  max_tokens=2096,
67
  temperature=0.5,
 
73
  # Import tool from Hub
74
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
75
 
76
+ # Uploading Suggestion Templates
77
  with open("prompts.yaml", 'r') as stream:
78
  prompt_templates = yaml.safe_load(stream)
79
 
80
+ # creating an agent
81
  agent = CodeAgent(
82
  model=model,
83
+ tools=[final_answer, search_animal_info, generate_animal_image], ## add your tools here (don't remove final answer)
84
  max_steps=6,
85
  verbosity_level=1,
86
  grammar=None,
87
  planning_interval=None,
88
+ name="Animal Image Generator",
89
+ description="An AI agent that generates images of animals based on search results.",
90
  prompt_templates=prompt_templates
91
  )
92