Skip to content

Commit 40993f8

Browse files
committed
Refactor plan models and update team selection logic
Replaces MPlan and MStep definitions in messages_kernel.py with a generic dictionary for m_plan, and moves their definitions to models.py. Updates plan_service.py to store m_plan as a dictionary using model_dump. Uncomments and enables in-memory team selection in router.py for current user.
1 parent 1848ebc commit 40993f8

File tree

4 files changed

+14
-25
lines changed

4 files changed

+14
-25
lines changed

src/backend/common/models/messages_kernel.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from datetime import datetime, timezone
33
from enum import Enum
44
from typing import Any, Dict, List, Literal, Optional
5-
from pydantic import BaseModel
5+
66
from semantic_kernel.kernel_pydantic import Field, KernelBaseModel
77

88
class DataType(str, Enum):
@@ -111,21 +111,7 @@ class UserCurrentTeam(BaseDataModel):
111111
user_id: str
112112
team_id: str
113113

114-
class MStep(BaseModel):
115-
"""model of a step in a plan"""
116-
agent: str = ""
117-
action: str = ""
118-
class MPlan(BaseModel):
119-
"""model of a plan"""
120-
id: str = Field(default_factory=lambda: str(uuid.uuid4()))
121-
user_id: str = ""
122-
team_id: str = ""
123-
plan_id: str = ""
124-
overall_status: PlanStatus = PlanStatus.created
125-
user_request: str = ""
126-
team: List[str] = []
127-
facts: str = ""
128-
steps: List[MStep] = []
114+
129115
class Plan(BaseDataModel):
130116
"""Represents a plan containing multiple steps."""
131117

@@ -136,7 +122,7 @@ class Plan(BaseDataModel):
136122
overall_status: PlanStatus = PlanStatus.in_progress
137123
approved: bool = False
138124
source: str = AgentType.PLANNER.value
139-
m_plan: Optional[MPlan] = None
125+
m_plan: Optional[Dict[str, Any]] = None
140126
summary: Optional[str] = None
141127
team_id: Optional[str] = None
142128
human_clarification_request: Optional[str] = None

src/backend/v3/api/router.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,9 +1127,9 @@ async def select_team(selection: TeamSelectionRequest, request: Request):
11271127
)
11281128

11291129
# save to in-memory config for current user
1130-
# team_config.set_current_team(
1131-
# user_id=user_id, team_configuration=team_configuration
1132-
# )
1130+
team_config.set_current_team(
1131+
user_id=user_id, team_configuration=team_configuration
1132+
)
11331133

11341134
# Track the team selection event
11351135
track_event_if_configured(

src/backend/v3/common/services/plan_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ async def handle_plan_approval(
158158
orchestration_config.plans[human_feedback.m_plan_id] = mplan
159159
if plan:
160160
plan.overall_status = PlanStatus.approved
161-
plan.m_plan = mplan
161+
plan.m_plan = mplan.model_dump()
162162
await memory_store.update_plan(plan)
163163
track_event_if_configured(
164164
"PlanApproved",

src/backend/v3/models/models.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import uuid
22
from datetime import datetime, timezone
33
from enum import Enum
4-
from typing import List, Literal, Optional
4+
from typing import Any, Dict, List, Literal, Optional
55

6-
from pydantic import BaseModel, Field
6+
from dataclasses import asdict, dataclass, field
77

8-
from common.models.messages_kernel import DataType
8+
from pydantic import BaseModel, Field
99

1010

1111
class PlanStatus(str, Enum):
@@ -16,11 +16,13 @@ class PlanStatus(str, Enum):
1616
FAILED = "failed"
1717
CANCELLED = "cancelled"
1818

19+
1920
class MStep(BaseModel):
2021
"""model of a step in a plan"""
2122
agent: str = ""
2223
action: str = ""
2324

25+
2426
class MPlan(BaseModel):
2527
"""model of a plan"""
2628
id: str = Field(default_factory=lambda: str(uuid.uuid4()))
@@ -31,4 +33,5 @@ class MPlan(BaseModel):
3133
user_request: str = ""
3234
team: List[str] = []
3335
facts: str = ""
34-
steps: List[MStep] = []
36+
steps: List[MStep] = []
37+

0 commit comments

Comments
 (0)