Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -52,6 +52,45 @@ def get_weather(location: str) -> str:
|
|
| 52 |
|
| 53 |
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
final_answer = FinalAnswerTool()
|
| 56 |
|
| 57 |
# 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:
|
|
@@ -73,7 +112,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 73 |
|
| 74 |
agent = CodeAgent(
|
| 75 |
model=model,
|
| 76 |
-
tools=[final_answer , get_current_time_in_timezone, get_weather], ## add your tools here (don't remove final answer)
|
| 77 |
max_steps=6,
|
| 78 |
verbosity_level=1,
|
| 79 |
grammar=None,
|
|
|
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
+
from smolagents import tool
|
| 56 |
+
from smolagents.llms import HfApiModel
|
| 57 |
+
|
| 58 |
+
@tool
|
| 59 |
+
def create_personal_schedule(tasks: list, focus_hours: str, restrictions: str, duration_scope: str = "day") -> str:
|
| 60 |
+
"""A tool that generates a personalized daily or weekly schedule using an LLM.
|
| 61 |
+
|
| 62 |
+
Args:
|
| 63 |
+
tasks: A list of tasks (e.g., ["write report", "book flight", "team meeting"])
|
| 64 |
+
focus_hours: User-defined focus hours (e.g., "10:00-13:00, 16:00-18:00")
|
| 65 |
+
restrictions: Any restrictions like "no meetings after 7 PM"
|
| 66 |
+
duration_scope: Either "day" or "week"
|
| 67 |
+
"""
|
| 68 |
+
|
| 69 |
+
prompt = f"""
|
| 70 |
+
You are a smart planning assistant. Based on the following details, generate a personalized schedule:
|
| 71 |
+
|
| 72 |
+
Tasks: {tasks}
|
| 73 |
+
Focus Hours: {focus_hours}
|
| 74 |
+
Restrictions: {restrictions}
|
| 75 |
+
Scope: {duration_scope}
|
| 76 |
+
|
| 77 |
+
Allocate realistic time durations to tasks (e.g., booking a flight = 30 min, working on project = 3 hrs).
|
| 78 |
+
Try to match important tasks with focus hours and respect user restrictions.
|
| 79 |
+
|
| 80 |
+
Format the output as a bullet-point schedule.
|
| 81 |
+
"""
|
| 82 |
+
|
| 83 |
+
# Call the LLM (you can change the model_id if needed)
|
| 84 |
+
model = HfApiModel(
|
| 85 |
+
model_id="mistralai/Mixtral-8x7B-Instruct-v0.1",
|
| 86 |
+
temperature=0.5,
|
| 87 |
+
max_tokens=1024,
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
output = model(prompt)
|
| 91 |
+
return output
|
| 92 |
+
|
| 93 |
+
|
| 94 |
final_answer = FinalAnswerTool()
|
| 95 |
|
| 96 |
# 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:
|
|
|
|
| 112 |
|
| 113 |
agent = CodeAgent(
|
| 114 |
model=model,
|
| 115 |
+
tools=[final_answer , get_current_time_in_timezone, get_weather , create_personal_schedule], ## add your tools here (don't remove final answer)
|
| 116 |
max_steps=6,
|
| 117 |
verbosity_level=1,
|
| 118 |
grammar=None,
|