Spaces:
Sleeping
Sleeping
Add TaskEngine strategic planning layer
Browse files- engine/tasks/task_engine.py +40 -0
engine/tasks/task_engine.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from engine.model import EngineModel
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class TaskEngine:
|
| 5 |
+
"""
|
| 6 |
+
TaskEngine v1
|
| 7 |
+
-------------
|
| 8 |
+
- Strategic goal decomposition
|
| 9 |
+
- Structured execution planning
|
| 10 |
+
- Clean separation from API layer
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
@staticmethod
|
| 14 |
+
async def execute_goal(goal: str) -> dict:
|
| 15 |
+
"""
|
| 16 |
+
Takes a high-level goal and returns a structured execution plan.
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
planning_prompt = f"""
|
| 20 |
+
You are an advanced AI strategic planner.
|
| 21 |
+
|
| 22 |
+
Break down the following goal into:
|
| 23 |
+
|
| 24 |
+
1. Strategic Objective
|
| 25 |
+
2. Step-by-step Action Plan
|
| 26 |
+
3. Potential Risks
|
| 27 |
+
4. Success Criteria
|
| 28 |
+
|
| 29 |
+
Goal:
|
| 30 |
+
{goal}
|
| 31 |
+
|
| 32 |
+
Return clean, well-structured output.
|
| 33 |
+
"""
|
| 34 |
+
|
| 35 |
+
response = await EngineModel.generate(planning_prompt)
|
| 36 |
+
|
| 37 |
+
return {
|
| 38 |
+
"goal": goal,
|
| 39 |
+
"plan": response
|
| 40 |
+
}
|