Bhaskar2611 commited on
Commit
65dafe3
·
verified ·
1 Parent(s): 24cdbfb

Update planner.py

Browse files
Files changed (1) hide show
  1. planner.py +38 -28
planner.py CHANGED
@@ -9,44 +9,54 @@ client = InferenceClient(
9
  )
10
 
11
  def generate_task_plan(goal: str) -> str:
12
- """
13
- Generate a realistic task plan that respects the timeline in the goal.
14
- Example: "Launch a product in 4 weeks" use up to Day 28.
15
- """
16
- # Simple, clear prompt — no over-engineering
17
- prompt = f"""
18
- You are an experienced product manager. Break down the following goal into a clear, practical list of tasks.
19
 
20
- Goal: "{goal}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- Important:
23
- - If the goal mentions a timeframe (e.g., "in 4 weeks"), convert it to days (4 weeks = 28 days).
24
- - All tasks must be completed within that total number of days.
25
- - Distribute work realistically across the full timeline — don’t cram everything early.
26
- - Include key phases: planning, design, development, testing, marketing, launch, and post-launch.
27
- - For each task, specify:
28
- • A short name
29
- • A due date as "Due: Day N" (N must be ≤ total days)
30
- • Dependencies (e.g., "Depends on: Task 3" or "None")
31
- • A one-sentence description
32
 
33
- Output only a numbered list like this:
 
 
 
 
 
 
34
 
35
- 1. Define product requirements - Due: Day 2 - Depends on: None
36
- Description: Finalize core features and target users.
37
- 2. Design user interface - Due: Day 6 - Depends on: Task 1
38
- Description: Create wireframes and high-fidelity mockups.
39
- ...
40
 
41
- Now generate the plan for the goal above. Use the full available time wisely.
42
- """
43
 
44
  try:
45
  response = client.chat.completions.create(
46
  model="Qwen/Qwen2.5-Coder-7B-Instruct",
47
  messages=[{"role": "user", "content": prompt}],
48
- max_tokens=800,
49
- temperature=0.4, # Balanced: clear but not robotic
50
  stream=False
51
  )
52
  return response.choices[0].message.content.strip()
 
9
  )
10
 
11
  def generate_task_plan(goal: str) -> str:
12
+ # Simple: tell the model the exact number of days
13
+ # We'll assume user includes "X weeks" or "X days"
14
+ # For reliability, we hard-code the logic for common cases
15
+ goal_lower = goal.lower()
16
+ total_days = 14 # default
 
 
17
 
18
+ if "1 week" in goal_lower:
19
+ total_days = 7
20
+ elif "2 weeks" in goal_lower:
21
+ total_days = 14
22
+ elif "3 weeks" in goal_lower:
23
+ total_days = 21
24
+ elif "4 weeks" in goal_lower:
25
+ total_days = 28
26
+ elif "5 weeks" in goal_lower:
27
+ total_days = 35
28
+ else:
29
+ # Try to extract number + "days"
30
+ import re
31
+ if match := re.search(r'(\d+)\s*days?', goal_lower):
32
+ total_days = int(match.group(1))
33
+
34
+ prompt = f"""You are a senior product manager. Break down this goal into a realistic task plan.
35
 
36
+ Goal: "{goal}"
37
+ You have exactly {total_days} days to complete everything. The final task must be done by Day {total_days}.
 
 
 
 
 
 
 
 
38
 
39
+ Instructions:
40
+ - Create 8 to 15 actionable tasks.
41
+ - Spread work across all {total_days} days — don’t finish early.
42
+ - Include: planning, design, development, testing, marketing, launch, and feedback.
43
+ - For each task, write:
44
+ [Number]. [Task name] - Due: Day [N] - Depends on: [Task numbers or "None"]
45
+ Description: [One clear sentence]
46
 
47
+ Important:
48
+ - NEVER use a day greater than {total_days}.
49
+ - Do NOT add introductions, summaries, or extra text.
50
+ - Output ONLY the numbered list.
 
51
 
52
+ Now generate the plan:"""
 
53
 
54
  try:
55
  response = client.chat.completions.create(
56
  model="Qwen/Qwen2.5-Coder-7B-Instruct",
57
  messages=[{"role": "user", "content": prompt}],
58
+ max_tokens=2048,
59
+ temperature=0.3,
60
  stream=False
61
  )
62
  return response.choices[0].message.content.strip()