Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,16 +7,32 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
|
| 8 |
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:
|
|
@@ -51,7 +67,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 51 |
|
| 52 |
agent = CodeAgent(
|
| 53 |
model=model,
|
| 54 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 55 |
max_steps=6,
|
| 56 |
verbosity_level=1,
|
| 57 |
grammar=None,
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
|
|
| 10 |
@tool
|
| 11 |
+
def interweave_strings(string1: str, string2: str) -> str:
|
| 12 |
+
"""
|
| 13 |
+
Interweaves two strings character-by-character.
|
| 14 |
+
|
| 15 |
Args:
|
| 16 |
+
string1 (str): The first input string.
|
| 17 |
+
string2 (str): The second input string.
|
| 18 |
+
|
| 19 |
+
Returns:
|
| 20 |
+
str: A new string with characters from string1 and string2 interleaved.
|
| 21 |
+
If one string is longer, its remaining characters are appended at the end.
|
| 22 |
"""
|
| 23 |
+
# Build the interleaved string for the overlapping part.
|
| 24 |
+
interwoven_chars = []
|
| 25 |
+
for ch1, ch2 in zip(string1, string2):
|
| 26 |
+
interwoven_chars.append(ch1)
|
| 27 |
+
interwoven_chars.append(ch2)
|
| 28 |
+
|
| 29 |
+
# Append the remaining part of the longer string (if any).
|
| 30 |
+
if len(string1) > len(string2):
|
| 31 |
+
interwoven_chars.append(string1[len(string2):])
|
| 32 |
+
elif len(string2) > len(string1):
|
| 33 |
+
interwoven_chars.append(string2[len(string1):])
|
| 34 |
+
|
| 35 |
+
return "".join(interwoven_chars)
|
| 36 |
|
| 37 |
@tool
|
| 38 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 67 |
|
| 68 |
agent = CodeAgent(
|
| 69 |
model=model,
|
| 70 |
+
tools=[final_answer, get_current_time_in_timezone, interweave_strings, DuckDuckGoSearchTool, image_generation_tool], ## add your tools here (don't remove final answer)
|
| 71 |
max_steps=6,
|
| 72 |
verbosity_level=1,
|
| 73 |
grammar=None,
|