merveyvz commited on
Commit
6f80307
·
verified ·
1 Parent(s): 5255460

added ask_magic_8_ball function

Browse files
Files changed (1) hide show
  1. app.py +39 -7
app.py CHANGED
@@ -4,19 +4,49 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
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(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:
@@ -35,6 +65,8 @@ def get_current_time_in_timezone(timezone: str) -> str:
35
 
36
 
37
  final_answer = FinalAnswerTool()
 
 
38
  model = HfApiModel(
39
  max_tokens=2096,
40
  temperature=0.5,
@@ -51,7 +83,7 @@ with open("prompts.yaml", 'r') as stream:
51
 
52
  agent = CodeAgent(
53
  model=model,
54
- tools=[final_answer, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
55
  max_steps=6,
56
  verbosity_level=1,
57
  grammar=None,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ from random import choice
8
 
9
  from Gradio_UI import GradioUI
10
 
11
+
12
+
13
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
14
+
15
  @tool
16
+ def ask_magic_8_ball(question: str) -> str:
17
+ """A Magic 8 Ball tool that provides random answers to user's questions about situations.
 
18
  Args:
19
+ question: The situation or question the user wants advice about
 
20
  """
21
+ responses = [
22
+ "It is certain",
23
+ "It is decidedly so",
24
+ "Without a doubt",
25
+ "Yes - definitely",
26
+ "You may rely on it",
27
+ "As I see it, yes",
28
+ "Most likely",
29
+ "Outlook good",
30
+ "Yes",
31
+ "Signs point to yes",
32
+ "Reply hazy, try again",
33
+ "Ask again later",
34
+ "Better not tell you now",
35
+ "Cannot predict now",
36
+ "Concentrate and ask again",
37
+ "Don't count on it",
38
+ "My reply is no",
39
+ "My sources say no",
40
+ "Outlook not so good",
41
+ "Very doubtful"
42
+ ]
43
+
44
+ # Input validation
45
+ if not question or not isinstance(question, str):
46
+ return "Please provide a valid question or situation."
47
+
48
+ # Return random response
49
+ return choice(responses)
50
 
51
  @tool
52
  def get_current_time_in_timezone(timezone: str) -> str:
 
65
 
66
 
67
  final_answer = FinalAnswerTool()
68
+
69
+
70
  model = HfApiModel(
71
  max_tokens=2096,
72
  temperature=0.5,
 
83
 
84
  agent = CodeAgent(
85
  model=model,
86
+ tools=[final_answer, get_current_time_in_timezone, ask_magic_8_ball], ## add your tools here (don't remove final answer)
87
  max_steps=6,
88
  verbosity_level=1,
89
  grammar=None,