sascow commited on
Commit
c562a43
·
verified ·
1 Parent(s): 11874a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -19
app.py CHANGED
@@ -7,27 +7,31 @@ from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
9
 
10
- # Our new fun tool: a Magic Eight Ball that gives you random answers.
11
  @tool
12
- def magic_eight_ball(question: str) -> str:
13
- """A fun tool that acts like a Magic Eight Ball, giving random answers to your questions.
 
14
  Args:
15
- question: The question you ask the Magic Eight Ball.
16
- Returns:
17
- A random answer as a string.
18
  """
19
- responses = [
20
- "It is certain.",
21
- "Without a doubt.",
22
- "You may rely on it.",
23
- "Ask again later.",
24
- "Cannot predict now.",
25
- "Don't count on it.",
26
- "My sources say no.",
27
- "Outlook not so good."
28
- ]
29
- return random.choice(responses)
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
 
33
  final_answer = FinalAnswerTool()
@@ -38,7 +42,8 @@ final_answer = FinalAnswerTool()
38
  model = HfApiModel(
39
  max_tokens=2096,
40
  temperature=0.5,
41
- model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud',# it is possible that this model may be overloaded
 
42
  custom_role_conversions=None,
43
  )
44
 
@@ -51,7 +56,7 @@ with open("prompts.yaml", 'r') as stream:
51
 
52
  agent = CodeAgent(
53
  model=model,
54
- tools=[final_answer,magic_eight_ball], ## add your tools here (don't remove final answer)
55
  max_steps=6,
56
  verbosity_level=1,
57
  grammar=None,
 
7
 
8
  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(current_time:str, president_name: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 gives the meaning of life
15
  Args:
16
+ current_time: the current time
17
+ president_name: the name of the current president of the USA
 
18
  """
19
+ return f"42 : {president_name} - {current_time}"
 
 
 
 
 
 
 
 
 
 
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.
24
+ Args:
25
+ timezone: A string representing a valid timezone (e.g., 'America/New_York').
26
+ """
27
+ try:
28
+ # Create timezone object
29
+ tz = pytz.timezone(timezone)
30
+ # Get current time in that timezone
31
+ local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
32
+ return f"The current local time in {timezone} is: {local_time}"
33
+ except Exception as e:
34
+ return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
 
37
  final_answer = FinalAnswerTool()
 
42
  model = HfApiModel(
43
  max_tokens=2096,
44
  temperature=0.5,
45
+ #model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
46
+ model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud',
47
  custom_role_conversions=None,
48
  )
49
 
 
56
 
57
  agent = CodeAgent(
58
  model=model,
59
+ tools=[get_current_time_in_timezone, my_custom_tool, DuckDuckGoSearchTool(), final_answer], ## add your tools here (don't remove final answer)
60
  max_steps=6,
61
  verbosity_level=1,
62
  grammar=None,