ddeng1990 commited on
Commit
2c70cc8
·
verified ·
1 Parent(s): 417dfe8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -19,22 +19,24 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
19
  return "What magic will you build ?"
20
 
21
  @tool
22
- def reverse_and_add_magic_number(text: str, magic_number: int) -> int:
23
- """Reverses the given text, converts it to an integer, and adds a magic number.
 
 
 
 
 
24
 
25
  Args:
26
- text: The string to reverse and convert.
27
- magic_number: The number to add.
28
 
29
  Returns:
30
  The resulting integer.
31
  """
32
- try:
33
- reversed_text = text[::-1]
34
- reversed_int = int(reversed_text)
35
- return reversed_int + magic_number
36
- except ValueError:
37
- return None # Handle cases where the reversed string is not a valid integer
38
 
39
 
40
  @tool
@@ -78,7 +80,7 @@ agent = CodeAgent(
78
  tools=[final_answer,
79
  get_current_time_in_timezone,
80
  image_generation_tool,
81
- reverse_and_add_magic_number], ## add your tools here (don't remove final answer)
82
  max_steps=6,
83
  verbosity_level=1,
84
  grammar=None,
 
19
  return "What magic will you build ?"
20
 
21
  @tool
22
+ def apply_glurb_transformation(input_string: str, glurb_factor: int) -> int:
23
+ """Applies a 'glurb' transformation to a string.
24
+
25
+ The 'glurb' transformation involves:
26
+ 1. Converting each character to its ASCII value.
27
+ 2. Multiplying each ASCII value by the 'glurb_factor'.
28
+ 3. Summing the resulting values.
29
 
30
  Args:
31
+ input_string: The string to transform.
32
+ glurb_factor: The factor to multiply ASCII values by.
33
 
34
  Returns:
35
  The resulting integer.
36
  """
37
+ ascii_values = [ord(char) for char in input_string]
38
+ multiplied_values = [value * glurb_factor for value in ascii_values]
39
+ return sum(multiplied_values)
 
 
 
40
 
41
 
42
  @tool
 
80
  tools=[final_answer,
81
  get_current_time_in_timezone,
82
  image_generation_tool,
83
+ apply_glurb_transformation], ## add your tools here (don't remove final answer)
84
  max_steps=6,
85
  verbosity_level=1,
86
  grammar=None,