Aditya57 commited on
Commit
af6db42
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -6
app.py CHANGED
@@ -9,14 +9,42 @@ 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 my_custom_tool(arg1:str, arg2:int)-> 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 does nothing yet
15
  Args:
16
- arg1: the first argument
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:
@@ -33,7 +61,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
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:
@@ -55,7 +83,7 @@ with open("prompts.yaml", 'r') as 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,
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def searching(search: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 does nothing yet
15
  Args:
16
+ search: A string representing a valid search (e.g., 'what is the capital of India?/what is the capital of Australia?').
 
17
  """
18
+ #instantiating DuckDuckgo search tool
19
+ duckduckgo_tool=DuckDuckGoSearchTool()
20
+ try:
21
+ #here we are creating a searchresult object
22
+ results=duckduckgo_tool.run(search)
23
+ if results:
24
+ return f"Search Result using DuckDuckgo:\n{results}"
25
+ else:
26
+ return f"No Result Found"
27
+ except Exception as e:
28
+ return f"something went wrong:\n {str(e)}"
29
+
30
+
31
+ @tool
32
+ def image_generator_(prompt:str)-> str: #it's import to specify the return type
33
+ #Keep this format for the description / args / args description but feel free to modify the tool
34
+ """"Generates an image from a prompt using a Hugging Face image generation tool.
35
+
36
+ Args:
37
+ prompt: A text prompt describing the image to generate.
38
+ Returns:
39
+ A URL pointing to the generated image.
40
+ """
41
+ try:
42
+ #creating a image object
43
+ image=image_generation_tool.run(prompt)
44
+ return f"Here is the link for the generated image using the prompt:\n{image}"
45
+ except Exception as e:
46
+ return f"we couldnt create image for the above prompt:\n{str(e)} try giving another prompt"
47
+
48
 
49
  @tool
50
  def get_current_time_in_timezone(timezone: str) -> str:
 
61
  except Exception as e:
62
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
63
 
64
+ current_time = get_current_time_in_timezone(timezone)
65
  final_answer = FinalAnswerTool()
66
 
67
  # 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:
 
83
 
84
  agent = CodeAgent(
85
  model=model,
86
+ tools=[final_answer,searching,image_generator_,current_time]## add your tools here (don't remove final answer)
87
  max_steps=6,
88
  verbosity_level=1,
89
  grammar=None,