Spaces:
Sleeping
Sleeping
Update app.py
Browse filesAñado acceso a las siguientes herramientas: image_generation_tool, duck_search_tool, get_current_time_in_timezone, codify_text.
app.py
CHANGED
|
@@ -9,14 +9,21 @@ 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 |
-
"""A tool that does nothing yet
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -34,6 +41,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
|
|
|
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
model = HfApiModel(
|
| 39 |
max_tokens=2096,
|
|
@@ -46,12 +54,15 @@ custom_role_conversions=None,
|
|
| 46 |
# Import tool from Hub
|
| 47 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 48 |
|
|
|
|
|
|
|
|
|
|
| 49 |
with open("prompts.yaml", 'r') as stream:
|
| 50 |
prompt_templates = yaml.safe_load(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,
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def codify_text(text:str, step:int)-> str:
|
| 13 |
+
"""A tool to encrypt the original text using the Caesar cipher technique, a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions (step) down the alphabet.
|
|
|
|
| 14 |
Args:
|
| 15 |
+
text: Original text
|
| 16 |
+
step: A integer with the number of positions to consider
|
| 17 |
"""
|
| 18 |
+
resultado = ""
|
| 19 |
+
for caracter in text:
|
| 20 |
+
if caracter.isalpha():
|
| 21 |
+
ascii_offset = ord('A') if caracter.isupper() else ord('a')
|
| 22 |
+
nuevo_caracter = chr((ord(caracter) - ascii_offset + step) % 26 + ascii_offset)
|
| 23 |
+
else:
|
| 24 |
+
nuevo_caracter = caracter
|
| 25 |
+
resultado += nuevo_caracter
|
| 26 |
+
return resultado
|
| 27 |
|
| 28 |
@tool
|
| 29 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 41 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 42 |
|
| 43 |
|
| 44 |
+
|
| 45 |
final_answer = FinalAnswerTool()
|
| 46 |
model = HfApiModel(
|
| 47 |
max_tokens=2096,
|
|
|
|
| 54 |
# Import tool from Hub
|
| 55 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 56 |
|
| 57 |
+
# PACO - tool importada de smolagents
|
| 58 |
+
duck_search_tool = DuckDuckGoSearchTool()
|
| 59 |
+
|
| 60 |
with open("prompts.yaml", 'r') as stream:
|
| 61 |
prompt_templates = yaml.safe_load(stream)
|
| 62 |
|
| 63 |
agent = CodeAgent(
|
| 64 |
model=model,
|
| 65 |
+
tools=[image_generation_tool, duck_search_tool, get_current_time_in_timezone, codify_text, final_answer], ## add your tools here (don't remove final answer)
|
| 66 |
max_steps=6,
|
| 67 |
verbosity_level=1,
|
| 68 |
grammar=None,
|