rsynak commited on
Commit
dc896bc
·
verified ·
1 Parent(s): 44aa919

update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -5
app.py CHANGED
@@ -9,16 +9,38 @@ 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(state:str, altitude: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 fetchs the state capital and its altitude
15
  Args:
16
- state: A string representing the state who's capital we need to identify
17
- altitude: The altitude of the state capital we've identified
18
  """
19
- return f"The altitude of '{state}'s capital is '{altitude}'"
20
 
 
 
 
 
 
 
 
 
 
 
21
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  @tool
24
  def get_current_time_in_timezone(timezone: str) -> str:
 
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
15
  Args:
16
+ arg1: A string
17
+ arg2: another string
18
  """
19
+ return f"we did nothing'"
20
 
21
+ @tool
22
+ def fetch_state_capital_and_altitude(state: str) -> str:
23
+ """A tool that fetches the capital and altitude of a US state using DuckDuckGo search.
24
+ Args:
25
+ state: A US state name.
26
+ """
27
+ try:
28
+ # Query capital
29
+ capital_query = f"What is the capital of {state}?"
30
+ capital_result = duckduckgo_tool(capital_query)
31
 
32
+ # Extract a simple capital name from the result
33
+ # In a real-world case, you'd want better parsing here
34
+ capital = capital_result[:100] # crude truncation for demonstration
35
+
36
+ # Query altitude
37
+ altitude_query = f"What is the altitude of {capital}?"
38
+ altitude_result = duckduckgo_tool(altitude_query)
39
+ altitude = altitude_result[:100] # crude again
40
+
41
+ return f"The capital of {state} is {capital}. Its altitude is {altitude}."
42
+ except Exception as e:
43
+ return f"Error fetching info for {state}: {str(e)}"
44
 
45
  @tool
46
  def get_current_time_in_timezone(timezone: str) -> str: