dnguyen47 commited on
Commit
5dae27d
·
verified ·
1 Parent(s): 0a0b008

updated tools

Browse files
Files changed (1) hide show
  1. app.py +6 -36
app.py CHANGED
@@ -9,44 +9,14 @@ 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 get_weather(city:str)-> str:
13
- """A tool that gets the weather in a city
14
  Args:
15
- city: A string representing a valid city
16
  """
17
- if not city:
18
- return "enter a city"
19
 
20
- url = "https://api.openweathermap.org/data/2.5/weather"
21
-
22
- params = {
23
- "q": city,
24
- "appid": API_KEY,
25
- "units": "imperial"
26
- }
27
-
28
- response = requests.get(url, params=params)
29
-
30
- if response.status_code != 200:
31
- return "City not found or API error."
32
-
33
- data = response.json()
34
-
35
- temp = data["main"]["temp"]
36
- feels_like = data["main"]["feels_like"]
37
- humidity = data["main"]["humidity"]
38
- description = data["weather"][0]["description"]
39
-
40
- result = f"""
41
- Weather in {city.title()}:
42
-
43
- - Temperature: {temp} °F
44
- - Feels Like: {feels_like} °F
45
- - Humidity: {humidity}%
46
- - Condition: {description.title()}
47
- """
48
-
49
- return result
50
 
51
  @tool
52
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -85,7 +55,7 @@ with open("prompts.yaml", 'r') as stream:
85
 
86
  agent = CodeAgent(
87
  model=model,
88
- tools=[final_answer, get_weather, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
89
  max_steps=6,
90
  verbosity_level=1,
91
  grammar=None,
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def get_200_random_characters()-> str:
13
+ """A tool that returns a random string of characters
14
  Args:
15
+ none
16
  """
17
+ characters = string.ascii_letters + string.digits + string.punctuation
18
+ return ''.join(random.choice(characters) for _ in range(200))
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
 
55
 
56
  agent = CodeAgent(
57
  model=model,
58
+ tools=[final_answer, get_200_random_characters, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,