Spaces:
Sleeping
Sleeping
Feat: First tool, character's quotes
Browse filesI'm using Star Trek theme for my first smolagent
app.py
CHANGED
|
@@ -4,19 +4,41 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
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 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
-
"""
|
|
|
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +77,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,
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
import random
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 12 |
@tool
|
| 13 |
+
def get_star_trek_quote(character: str)-> str: #it's import to specify the return type
|
| 14 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 15 |
+
"""
|
| 16 |
+
Fetches a quote from a Star Trek character.
|
| 17 |
Args:
|
| 18 |
+
character: The name of the character whose quote is requested (e.g., "Seven of Nine", "Spock", "Picard", "Data").
|
| 19 |
+
|
| 20 |
+
Returns:
|
| 21 |
+
A quote from the specified Star Trek character.
|
| 22 |
"""
|
| 23 |
+
quotes = {
|
| 24 |
+
"Seven of Nine": [
|
| 25 |
+
"It is unsettling. You say that I am a human being and yet, I am also Borg... Part of me not unlike your replicator... Not unlike the Doctor. Will you one day choose to abandon me as well?",
|
| 26 |
+
"Fun will now commence."
|
| 27 |
+
],
|
| 28 |
+
"Spock": [
|
| 29 |
+
"Live and prosper.",
|
| 30 |
+
"The needs of the many outweigh the needs of the few."
|
| 31 |
+
],
|
| 32 |
+
"Picard": [
|
| 33 |
+
"Make it so",
|
| 34 |
+
"Earth was once a violent planet too. At times, the chaos threatened the very fabric of life. But like you, we evolved. We found better ways to handle our conflicts. But I think noone can deny that the seed of violence remains within each of us, We must recognise that, because that violence is capable of consuming each of us."
|
| 35 |
+
],
|
| 36 |
+
"Data": [
|
| 37 |
+
"It is interesting that people try to find meaningful patterns in things that are essentially random. I have noticed that the images they percieve sometimes suggest what they are thinking about at that particular moment. Besides, it is clearly a bunny rabbit.",
|
| 38 |
+
"One is my name. The other is not."
|
| 39 |
+
]
|
| 40 |
+
}
|
| 41 |
+
return quotes.get(character, ["Sorry, no quotes available for this character"])[0]
|
| 42 |
|
| 43 |
@tool
|
| 44 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 77 |
|
| 78 |
agent = CodeAgent(
|
| 79 |
model=model,
|
| 80 |
+
tools=[final_answer, get_star_trek_quote], ## add your tools here (don't remove final answer)
|
| 81 |
max_steps=6,
|
| 82 |
verbosity_level=1,
|
| 83 |
grammar=None,
|