Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,40 @@ 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
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +81,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 make_string_silly(text: str) -> str:
|
| 13 |
+
"""A tool that makes text silly by alternating letter case within each word.
|
| 14 |
+
Each word will start with a lowercase letter, followed by alternating uppercase and lowercase letters.
|
| 15 |
+
|
| 16 |
Args:
|
| 17 |
+
text: The input text string to be made silly
|
| 18 |
+
|
| 19 |
+
Example:
|
| 20 |
+
Input: "Hello World"
|
| 21 |
+
Output: "hElLo wOrLd"
|
| 22 |
"""
|
| 23 |
+
# Split the text into words
|
| 24 |
+
words = text.split()
|
| 25 |
+
|
| 26 |
+
# Process each word
|
| 27 |
+
silly_words = []
|
| 28 |
+
for word in words:
|
| 29 |
+
# Handle empty words or single characters
|
| 30 |
+
if len(word) <= 1:
|
| 31 |
+
silly_words.append(word.lower())
|
| 32 |
+
continue
|
| 33 |
+
|
| 34 |
+
# Convert the word to list of characters for easier manipulation
|
| 35 |
+
chars = list(word.lower()) # Start with all lowercase
|
| 36 |
+
|
| 37 |
+
# Capitalize every other letter starting from index 1
|
| 38 |
+
for i in range(1, len(chars), 2):
|
| 39 |
+
chars[i] = chars[i].upper()
|
| 40 |
+
|
| 41 |
+
# Join the characters back into a word
|
| 42 |
+
silly_words.append(''.join(chars))
|
| 43 |
+
|
| 44 |
+
# Join the words back together with spaces
|
| 45 |
+
return ' '.join(silly_words)
|
| 46 |
|
| 47 |
@tool
|
| 48 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 81 |
|
| 82 |
agent = CodeAgent(
|
| 83 |
model=model,
|
| 84 |
+
tools=[final_answer, get_current_time_in_timezone, make_string_silly], ## add your tools here (don't remove final answer)
|
| 85 |
max_steps=6,
|
| 86 |
verbosity_level=1,
|
| 87 |
grammar=None,
|