hackmebroo commited on
Commit
ab006a4
·
verified ·
1 Parent(s): 4fc7f04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -15,10 +15,13 @@ def my_custom_tool(arg1: str, arg2: str) -> str:
15
  arg1: The input text to search.
16
  arg2: The letter to count (e.g., 'a').
17
  """
18
- if len(arg2) != 1 or not arg2.isalpha():
19
- return "Error: arg2 must be a single alphabet letter."
20
- count = arg1.count(arg2)
21
- return f"The letter '{arg2}' appears {count} time(s) in the text."
 
 
 
22
 
23
  @tool
24
  def get_current_time_in_timezone(timezone: str) -> str:
 
15
  arg1: The input text to search.
16
  arg2: The letter to count (e.g., 'a').
17
  """
18
+ try:
19
+ if len(arg2) != 1 or not arg2.isalpha():
20
+ return "Error: arg2 must be a single alphabet letter."
21
+ count = arg1.count(arg2)
22
+ return f"The letter '{arg2}' appears {count} time(s) in the text."
23
+ except Exception as e:
24
+ return f"Error: {str(e)}"
25
 
26
  @tool
27
  def get_current_time_in_timezone(timezone: str) -> str: