Skip to content

Commit 0b9515b

Browse files
committed
Add UserCurrentTeam model and update plan creation
Introduces the UserCurrentTeam model to represent a user's current team. Updates the API router to generate a new plan with a unique ID and store it in the database, removing plan_id and team_id from InputTask. Plan creation now includes initial goal and status.
1 parent 2d17c33 commit 0b9515b

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

src/backend/common/models/messages_kernel.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ class Session(BaseDataModel):
9898
current_status: str
9999
message_to_user: Optional[str] = None
100100

101+
class UserCurrentTeam(BaseDataModel):
102+
"""Represents the current team of a user."""
103+
104+
data_type: Literal["user_current_team"] = Field("user_current_team", Literal=True)
105+
user_id: str
106+
team_id: str
101107

102108
class Plan(BaseDataModel):
103109
"""Represents a plan containing multiple steps."""
@@ -248,9 +254,8 @@ class InputTask(KernelBaseModel):
248254
"""Message representing the initial input task from the user."""
249255

250256
session_id: str
251-
plan_id: str
252257
description: str # Initial goal
253-
team_id: str
258+
# team_id: str
254259

255260

256261
class UserLanguage(KernelBaseModel):

src/backend/v3/api/router.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import v3.models.messages as messages
99
from auth.auth_utils import get_authenticated_user_details
1010
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)
1313
from common.utils.event_utils import track_event_if_configured
1414
from common.utils.utils_kernel import rai_success, rai_validate_team_config
1515
from fastapi import (APIRouter, BackgroundTasks, Depends, FastAPI, File,
@@ -224,16 +224,24 @@ async def process_request(background_tasks: BackgroundTasks, input_task: InputTa
224224

225225
if not input_task.session_id:
226226
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())
229229

230230
try:
231231
current_user_id.set(user_id) # Set context
232232
current_context = contextvars.copy_context() # Capture context
233233
# background_tasks.add_task(
234234
# lambda: current_context.run(lambda:OrchestrationManager().run_orchestration, user_id, input_task)
235235
# )
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)
237245
async def run_with_context():
238246
return await current_context.run(OrchestrationManager().run_orchestration, user_id, input_task)
239247

0 commit comments

Comments
 (0)