Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,15 +21,18 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 21 |
Returns:
|
| 22 |
The ciphered string after performing a rotX transformation.
|
| 23 |
"""
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
return chr((ord(c) - ord('a') + shift) % 26 + ord('a'))
|
| 27 |
-
elif 'A' <= c <= 'Z':
|
| 28 |
-
return chr((ord(c) - ord('A') + shift) % 26 + ord('A'))
|
| 29 |
-
else:
|
| 30 |
-
return c
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
@tool
|
|
|
|
| 21 |
Returns:
|
| 22 |
The ciphered string after performing a rotX transformation.
|
| 23 |
"""
|
| 24 |
+
if arg2 is None:
|
| 25 |
+
raise ValueError("arg2 must be an integer, not None")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
result = []
|
| 28 |
+
for char in arg1:
|
| 29 |
+
if char.isalpha():
|
| 30 |
+
base = ord('A') if char.isupper() else ord('a')
|
| 31 |
+
rotated = chr((ord(char) - base + arg2) % 26 + base)
|
| 32 |
+
result.append(rotated)
|
| 33 |
+
else:
|
| 34 |
+
result.append(char)
|
| 35 |
+
return ''.join(result)
|
| 36 |
|
| 37 |
|
| 38 |
@tool
|