BenyaAronov commited on
Commit
3f7b23f
·
verified ·
1 Parent(s): 8c5c24b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -7
app.py CHANGED
@@ -9,15 +9,48 @@ 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:
23
  """A tool that fetches the current local time in a specified timezone.
@@ -55,7 +88,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def my_local_name_generator(arg1: str, arg2: str) -> str:
13
+ """A tool that generates a localized version of the given name for the specified country.
14
+
15
  Args:
16
+ arg1: A string representing the user's first name (e.g. David)
17
+ arg2: A string representing a country (e.g. Algeria)
18
+
19
+ Returns:
20
+ A localized variant of the name if available, otherwise a fallback message.
21
  """
22
+ localized_names = {
23
+ "David": {
24
+ "France": "David",
25
+ "Russia": "Davit",
26
+ "Israel": "Dovid",
27
+ "Spain": "David",
28
+ "Algeria": "Dawud",
29
+ "Italy": "Davide"
30
+ },
31
+ "John": {
32
+ "France": "Jean",
33
+ "Russia": "Ivan",
34
+ "Spain": "Juan",
35
+ "Italy": "Giovanni",
36
+ "Germany": "Johann"
37
+ }
38
+ }
39
+
40
+ try:
41
+ name_variants = localized_names.get(arg1)
42
+ if not name_variants:
43
+ return f"Sorry, I don't have localized versions for the name '{arg1}'."
44
 
45
+ localized_name = name_variants.get(arg2)
46
+ if not localized_name:
47
+ return f"No localized variant found for '{arg1}' in {arg2}."
48
+
49
+ return f"In {arg2}, '{arg1}' is commonly known as '{localized_name}'."
50
+
51
+ except Exception as e:
52
+ return f"An error occurred: {str(e)}"
53
+
54
  @tool
55
  def get_current_time_in_timezone(timezone: str) -> str:
56
  """A tool that fetches the current local time in a specified timezone.
 
88
 
89
  agent = CodeAgent(
90
  model=model,
91
+ tools=[final_answer, image_generation_tool, DuckDuckGoSearchTool, get_current_time_in_timezone, ], ## add your tools here (don't remove final answer)
92
  max_steps=6,
93
  verbosity_level=1,
94
  grammar=None,