Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,30 @@ 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 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -35,6 +51,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 35 |
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
|
|
|
| 38 |
|
| 39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
| 40 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def magic_8_ball(question:str, mood:int)-> str: #it's import to specify the return type
|
| 13 |
+
"""
|
| 14 |
+
Simulates a Magic 8 Ball based on mood.
|
| 15 |
+
|
| 16 |
+
Parameters:
|
| 17 |
+
question (str): The user's question.
|
| 18 |
+
mood (int): The current mood (1=positive, 2=neutral, 3=negative).
|
| 19 |
+
|
| 20 |
+
Returns:
|
| 21 |
+
str: A prediction ("Yes", "No", or ambiguous).
|
| 22 |
"""
|
| 23 |
+
if not question.strip().endswith('?'):
|
| 24 |
+
return "Ask me a real question, ending with a '?'"
|
| 25 |
+
|
| 26 |
+
responses = {
|
| 27 |
+
1: ["Yes!", "Absolutely.", "Without a doubt.", "You can count on it.", "Definitely."],
|
| 28 |
+
2: ["Maybe.", "Hard to say.", "Could go either way.", "Ask again later.", "Unclear for now."],
|
| 29 |
+
3: ["No.", "Absolutely not.", "Don't count on it.", "Very unlikely.", "No way."]
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
if mood not in responses:
|
| 33 |
+
return "Invalid mood. Use 1 for positive, 2 for neutral, or 3 for negative."
|
| 34 |
+
|
| 35 |
+
return random.choice(responses[mood])
|
| 36 |
|
| 37 |
@tool
|
| 38 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 51 |
|
| 52 |
|
| 53 |
final_answer = FinalAnswerTool()
|
| 54 |
+
duckduck = DuckDuckGoSearchTool()
|
| 55 |
|
| 56 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
| 57 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|