Smart_Task_Planner / planner.py
Bhaskar2611's picture
Update planner.py
91efcfe verified
raw
history blame
1.94 kB
# planner.py
import os
from huggingface_hub import InferenceClient
HF_TOKEN = os.getenv("HF_TOKEN")
client = InferenceClient(
model="Qwen/Qwen2.5-Coder-7B-Instruct",
token=HF_TOKEN
)
def generate_task_plan(goal: str) -> str:
"""
Generate a realistic task plan that respects the timeline in the goal.
Example: "Launch a product in 4 weeks" → use up to Day 28.
"""
# Simple, clear prompt — no over-engineering
prompt = f"""
You are an experienced product manager. Break down the following goal into a clear, practical list of tasks.
Goal: "{goal}"
Important:
- If the goal mentions a timeframe (e.g., "in 4 weeks"), convert it to days (4 weeks = 28 days).
- All tasks must be completed within that total number of days.
- Distribute work realistically across the full timeline — don’t cram everything early.
- Include key phases: planning, design, development, testing, marketing, launch, and post-launch.
- For each task, specify:
• A short name
• A due date as "Due: Day N" (N must be ≤ total days)
• Dependencies (e.g., "Depends on: Task 3" or "None")
• A one-sentence description
Output only a numbered list like this:
1. Define product requirements - Due: Day 2 - Depends on: None
Description: Finalize core features and target users.
2. Design user interface - Due: Day 6 - Depends on: Task 1
Description: Create wireframes and high-fidelity mockups.
...
Now generate the plan for the goal above. Use the full available time wisely.
"""
try:
response = client.chat.completions.create(
model="Qwen/Qwen2.5-Coder-7B-Instruct",
messages=[{"role": "user", "content": prompt}],
max_tokens=800,
temperature=0.4, # Balanced: clear but not robotic
stream=False
)
return response.choices[0].message.content.strip()
except Exception as e:
return f"Error: {str(e)}"