Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,10 +3,26 @@ import datetime
|
|
| 3 |
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 my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
@@ -23,6 +39,8 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 23 |
"""A tool that fetches the current local time in a specified timezone.
|
| 24 |
Args:
|
| 25 |
timezone: A string representing a valid timezone (e.g., 'America/New_York').
|
|
|
|
|
|
|
| 26 |
"""
|
| 27 |
try:
|
| 28 |
# Create timezone object
|
|
@@ -55,7 +73,9 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[
|
|
|
|
|
|
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
+
import random
|
| 7 |
from tools.final_answer import FinalAnswerTool
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
+
@tool
|
| 12 |
+
def get_icebreaker_question() -> str:
|
| 13 |
+
"""
|
| 14 |
+
Generate a random icebreaker question.
|
| 15 |
+
|
| 16 |
+
Returns:
|
| 17 |
+
str: A fun, thought-provoking question to start a conversation.
|
| 18 |
+
"""
|
| 19 |
+
prompts = [
|
| 20 |
+
"What's a skill you’ve always wanted to learn?",
|
| 21 |
+
"If you could time travel, where would you go?",
|
| 22 |
+
"What’s the most spontaneous thing you’ve done?"
|
| 23 |
+
]
|
| 24 |
+
return random.choice(prompts)
|
| 25 |
+
|
| 26 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 27 |
@tool
|
| 28 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
|
|
| 39 |
"""A tool that fetches the current local time in a specified timezone.
|
| 40 |
Args:
|
| 41 |
timezone: A string representing a valid timezone (e.g., 'America/New_York').
|
| 42 |
+
Returns:
|
| 43 |
+
str: The current local time as a string that contains it.
|
| 44 |
"""
|
| 45 |
try:
|
| 46 |
# Create timezone object
|
|
|
|
| 73 |
|
| 74 |
agent = CodeAgent(
|
| 75 |
model=model,
|
| 76 |
+
tools=[get_icebreaker_question,
|
| 77 |
+
get_current_time_in_timezone,
|
| 78 |
+
final_answer], ## add your tools here (don't remove final answer)
|
| 79 |
max_steps=6,
|
| 80 |
verbosity_level=1,
|
| 81 |
grammar=None,
|