|
8 | 8 | import v3.models.messages as messages |
9 | 9 | from auth.auth_utils import get_authenticated_user_details |
10 | 10 | from common.database.database_factory import DatabaseFactory |
11 | | -from common.models.messages_kernel import (GeneratePlanRequest, InputTask, |
12 | | - TeamSelectionRequest) |
| 11 | +from common.models.messages_kernel import (GeneratePlanRequest, InputTask, PlanStatus, |
| 12 | + TeamSelectionRequest, Plan) |
13 | 13 | from common.utils.event_utils import track_event_if_configured |
14 | 14 | from common.utils.utils_kernel import rai_success, rai_validate_team_config |
15 | 15 | from fastapi import (APIRouter, BackgroundTasks, Depends, FastAPI, File, |
@@ -224,16 +224,24 @@ async def process_request(background_tasks: BackgroundTasks, input_task: InputTa |
224 | 224 |
|
225 | 225 | if not input_task.session_id: |
226 | 226 | input_task.session_id = str(uuid.uuid4()) |
227 | | - if not input_task.plan_id: |
228 | | - input_task.plan_id = str(uuid.uuid4()) |
| 227 | + |
| 228 | + plan_id = str(uuid.uuid4()) |
229 | 229 |
|
230 | 230 | try: |
231 | 231 | current_user_id.set(user_id) # Set context |
232 | 232 | current_context = contextvars.copy_context() # Capture context |
233 | 233 | # background_tasks.add_task( |
234 | 234 | # lambda: current_context.run(lambda:OrchestrationManager().run_orchestration, user_id, input_task) |
235 | 235 | # ) |
236 | | - |
| 236 | + memory_store = await DatabaseFactory.get_database(user_id=user_id) |
| 237 | + plan = Plan( |
| 238 | + id=plan_id, |
| 239 | + user_id=user_id, |
| 240 | + team_id="", #TODO add current_team_id |
| 241 | + initial_goal=input_task.description, |
| 242 | + overall_status=PlanStatus.in_progress, |
| 243 | + ) |
| 244 | + await memory_store.add_plan(plan) |
237 | 245 | async def run_with_context(): |
238 | 246 | return await current_context.run(OrchestrationManager().run_orchestration, user_id, input_task) |
239 | 247 |
|
|
0 commit comments