Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,22 @@ 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:
|
|
@@ -52,10 +60,15 @@ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_co
|
|
| 52 |
|
| 53 |
with open("prompts.yaml", 'r') as stream:
|
| 54 |
prompt_templates = yaml.safe_load(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 reverse_string(text: str) -> str:
|
| 13 |
+
"""A tool that reverses the given string.
|
| 14 |
+
|
| 15 |
Args:
|
| 16 |
+
text (str): The input string.
|
| 17 |
+
|
| 18 |
+
Returns:
|
| 19 |
+
str: The reversed string.
|
| 20 |
"""
|
| 21 |
+
try:
|
| 22 |
+
reversed_text = text[::-1]
|
| 23 |
+
return f"Reversed string: {reversed_text}"
|
| 24 |
+
|
| 25 |
+
except Exception as e:
|
| 26 |
+
return f"Error reversing string: {str(e)}"
|
| 27 |
+
|
| 28 |
|
| 29 |
@tool
|
| 30 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 60 |
|
| 61 |
with open("prompts.yaml", 'r') as stream:
|
| 62 |
prompt_templates = yaml.safe_load(stream)
|
| 63 |
+
|
| 64 |
+
custom_tools=[
|
| 65 |
+
get_current_time_in_timezone,
|
| 66 |
+
reverse_string,
|
| 67 |
+
]
|
| 68 |
+
|
| 69 |
agent = CodeAgent(
|
| 70 |
model=model,
|
| 71 |
+
tools=[final_answer]+custom_tools, ## add your tools here (don't remove final answer)
|
| 72 |
max_steps=6,
|
| 73 |
verbosity_level=1,
|
| 74 |
grammar=None,
|