Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,6 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
-
# Let's keep the example tool for the reference
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 12 |
@tool
|
| 13 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
@@ -19,30 +18,6 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 19 |
"""
|
| 20 |
return "What magic will you build ?"
|
| 21 |
|
| 22 |
-
# Letter counter tool
|
| 23 |
-
@tool
|
| 24 |
-
def letter_counter(sentence:str, char_to_search:str)-> str:
|
| 25 |
-
"""Counts the occurrences of a specified letter in a given sentence and returns a descriptive message.
|
| 26 |
-
|
| 27 |
-
Args:
|
| 28 |
-
sentence: The sentence in which to count the occurrences of the letter.
|
| 29 |
-
char_to_search: The letter to count within the sentence.
|
| 30 |
-
|
| 31 |
-
Returns:
|
| 32 |
-
A string message that describes how many times the specified letter appears in the sentence.
|
| 33 |
-
"""
|
| 34 |
-
try:
|
| 35 |
-
letter_count = 0
|
| 36 |
-
|
| 37 |
-
for char in sentence.lower():
|
| 38 |
-
|
| 39 |
-
if char == char_to_search.lower():
|
| 40 |
-
letter_count += 1
|
| 41 |
-
|
| 42 |
-
return str(letter_count)
|
| 43 |
-
except Exception as e:
|
| 44 |
-
return f"Error counting letters for '{char_to_search}' in '{sentence}': {str(e)}"
|
| 45 |
-
|
| 46 |
@tool
|
| 47 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 48 |
"""A tool that fetches the current local time in a specified timezone.
|
|
@@ -80,7 +55,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 80 |
|
| 81 |
agent = CodeAgent(
|
| 82 |
model=model,
|
| 83 |
-
tools=[final_answer
|
| 84 |
max_steps=6,
|
| 85 |
verbosity_level=1,
|
| 86 |
grammar=None,
|
|
|
|
| 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 my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
|
|
| 18 |
"""
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 23 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 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,
|