Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,46 @@ 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 |
-
"""A tool that
|
| 15 |
Args:
|
| 16 |
-
arg1:
|
| 17 |
-
arg2:
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,13 +87,13 @@ 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,
|
| 62 |
planning_interval=None,
|
| 63 |
-
name=
|
| 64 |
-
description=
|
| 65 |
prompt_templates=prompt_templates
|
| 66 |
)
|
| 67 |
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def joke_generator(arg1:str, arg2:str)-> str: #it's import to specify the return type
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
+
"""A tool that generates random jokes
|
| 15 |
Args:
|
| 16 |
+
arg1: A dummy string arguement
|
| 17 |
+
arg2: A dummy string arguement
|
| 18 |
"""
|
| 19 |
+
Jokes = [
|
| 20 |
+
"Why don’t skeletons fight each other? They don’t have the guts!",
|
| 21 |
+
"Parallel lines have so much in common. It’s a shame they’ll never meet!",
|
| 22 |
+
"I told my computer I needed a break, and now it won’t stop sending me vacation ads!",
|
| 23 |
+
"Why did the scarecrow win an award? Because he was outstanding in his field!"
|
| 24 |
+
]
|
| 25 |
+
return random.choice(Jokes)
|
| 26 |
+
|
| 27 |
+
@tool
|
| 28 |
+
def generate_meme(args1:str , args2: int) -> str:
|
| 29 |
+
"""creates a meme with a given text
|
| 30 |
+
Args:
|
| 31 |
+
arg1: A text to be placed in the meme
|
| 32 |
+
arg2: A dummy string arguement
|
| 33 |
+
"""
|
| 34 |
+
hf_client = InferenceClient("https://some-hf-meme-model-url")
|
| 35 |
+
response = hf_client.text_to_image(arg1)
|
| 36 |
+
return response.get("image_url", "Failed to generate meme")
|
| 37 |
+
|
| 38 |
+
@tool
|
| 39 |
+
def random_fact(arg1: str, arg2: int) -> str:
|
| 40 |
+
"""Returns a random fun fact.
|
| 41 |
+
Args:
|
| 42 |
+
arg1: A dummy string argument.
|
| 43 |
+
arg2: A dummy integer argument.
|
| 44 |
+
"""
|
| 45 |
+
facts = [
|
| 46 |
+
"Honey never spoils. Archaeologists have found pots of honey in ancient Egyptian tombs that are over 3,000 years old and still perfectly good!",
|
| 47 |
+
"Bananas are berries, but strawberries aren’t!",
|
| 48 |
+
"A group of flamingos is called a ‘flamboyance’.",
|
| 49 |
+
"Octopuses have three hearts, and their blood is blue!"
|
| 50 |
+
]
|
| 51 |
+
return random.choice(facts)
|
| 52 |
|
| 53 |
@tool
|
| 54 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 87 |
|
| 88 |
agent = CodeAgent(
|
| 89 |
model=model,
|
| 90 |
+
tools=[final_answer,joke_generator,generate_meme,random_fact], ## add your tools here (don't remove final answer)
|
| 91 |
max_steps=6,
|
| 92 |
verbosity_level=1,
|
| 93 |
grammar=None,
|
| 94 |
planning_interval=None,
|
| 95 |
+
name=ChineseHumour,
|
| 96 |
+
description=A fun ai for college students related jokes,
|
| 97 |
prompt_templates=prompt_templates
|
| 98 |
)
|
| 99 |
|