|
9 | 9 | from auth.auth_utils import get_authenticated_user_details |
10 | 10 | from common.config.app_config import config |
11 | 11 | from common.database.database_factory import DatabaseFactory |
12 | | -from common.models.messages_kernel import (InputTask, Plan, PlanStatus, |
13 | | - PlanWithSteps, TeamSelectionRequest) |
| 12 | +from common.models.messages_kernel import ( |
| 13 | + InputTask, |
| 14 | + Plan, |
| 15 | + PlanStatus, |
| 16 | + PlanWithSteps, |
| 17 | + TeamSelectionRequest, |
| 18 | +) |
14 | 19 | from common.utils.event_utils import track_event_if_configured |
15 | 20 | from common.utils.utils_date import format_dates_in_messages |
16 | 21 | from common.utils.utils_kernel import rai_success, rai_validate_team_config |
17 | | -from fastapi import (APIRouter, BackgroundTasks, File, HTTPException, Query, |
18 | | - Request, UploadFile, WebSocket, WebSocketDisconnect) |
| 22 | +from fastapi import ( |
| 23 | + APIRouter, |
| 24 | + BackgroundTasks, |
| 25 | + File, |
| 26 | + HTTPException, |
| 27 | + Query, |
| 28 | + Request, |
| 29 | + UploadFile, |
| 30 | + WebSocket, |
| 31 | + WebSocketDisconnect, |
| 32 | +) |
19 | 33 | from semantic_kernel.agents.runtime import InProcessRuntime |
20 | 34 | from v3.common.services.plan_service import PlanService |
21 | 35 | from v3.common.services.team_service import TeamService |
22 | | -from v3.config.settings import (connection_config, current_user_id, |
23 | | - orchestration_config, team_config) |
| 36 | +from v3.config.settings import ( |
| 37 | + connection_config, |
| 38 | + current_user_id, |
| 39 | + orchestration_config, |
| 40 | + team_config, |
| 41 | +) |
24 | 42 | from v3.orchestration.orchestration_manager import OrchestrationManager |
25 | 43 |
|
26 | 44 | router = APIRouter() |
@@ -118,7 +136,7 @@ async def init_team( |
118 | 136 | user_current_team = await memory_store.get_current_team(user_id=user_id) |
119 | 137 | if not user_current_team: |
120 | 138 | print("User has no current team, setting to default:", init_team_id) |
121 | | - user_current_team = await team_service.handle_team_selection( |
| 139 | + user_current_team = await team_service.handle_team_selection( |
122 | 140 | user_id=user_id, team_id=init_team_id |
123 | 141 | ) |
124 | 142 | if user_current_team: |
@@ -445,15 +463,24 @@ async def user_clarification( |
445 | 463 | orchestration_config.clarifications[human_feedback.request_id] = ( |
446 | 464 | human_feedback.answer |
447 | 465 | ) |
| 466 | + |
| 467 | + try: |
| 468 | + result = await PlanService.handle_human_clarification( |
| 469 | + human_feedback, user_id) |
| 470 | + print("Human clarification processed:", result) |
| 471 | + except ValueError as ve: |
| 472 | + print(f"ValueError processing human clarification: {ve}") |
| 473 | + except Exception as e: |
| 474 | + print(f"Error processing human clarification: {e}") |
448 | 475 | track_event_if_configured( |
449 | | - "PlanApprovalReceived", |
| 476 | + "HumanClarificationReceived", |
450 | 477 | { |
451 | 478 | "request_id": human_feedback.request_id, |
452 | 479 | "answer": human_feedback.answer, |
453 | 480 | "user_id": user_id, |
454 | 481 | }, |
455 | 482 | ) |
456 | | - return {"status": "clarification recorded"} |
| 483 | + return {"status": "clarification recorded",} |
457 | 484 | else: |
458 | 485 | logging.warning( |
459 | 486 | f"No orchestration or plan found for request_id: {human_feedback.request_id}" |
@@ -899,7 +926,7 @@ async def select_team(selection: TeamSelectionRequest, request: Request): |
899 | 926 | team_configuration = await team_service.get_team_configuration( |
900 | 927 | selection.team_id, user_id |
901 | 928 | ) |
902 | | - if team_configuration is None: # ensure that id is valid |
| 929 | + if team_configuration is None: # ensure that id is valid |
903 | 930 | raise HTTPException( |
904 | 931 | status_code=404, |
905 | 932 | detail=f"Team configuration '{selection.team_id}' not found or access denied", |
|
0 commit comments