Visionkambanje commited on
Commit
ce574a7
·
verified ·
1 Parent(s): 8c5c24b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -17,6 +17,21 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
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:
 
17
  arg2: the second argument
18
  """
19
  return "What magic will you build ?"
20
+ @tool
21
+ def translate_english_to_chinese(english_text: str) -> str:
22
+ """Translates English text to Chinese.
23
+ Args:
24
+ english_text: The English text to be translated to Chinese
25
+ """
26
+ try:
27
+ from googletrans import Translator
28
+ translator = Translator()
29
+ translation = translator.translate(english_text, src='en', dest='zh-cn')
30
+ return translation.text
31
+ except ImportError:
32
+ return "Error: googletrans library not installed. Please install it using 'pip install googletrans==4.0.0-rc1'"
33
+ except Exception as e:
34
+ return f"Translation error: {str(e)}"
35
 
36
  @tool
37
  def get_current_time_in_timezone(timezone: str) -> str: