Skip to content

Commit c5250e0

Browse files
Merge branch 'macae-v3-dev' into rai-check - resolved conflicts in router.py
2 parents d4e1d81 + 4923664 commit c5250e0

File tree

3 files changed

+74
-46
lines changed

3 files changed

+74
-46
lines changed

src/backend/app_kernel.py

Lines changed: 51 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import asyncio
33
import logging
44
import os
5+
56
# Azure monitoring
67
import re
78
import uuid
@@ -12,26 +13,37 @@
1213
from azure.monitor.opentelemetry import configure_azure_monitor
1314
from common.config.app_config import config
1415
from common.database.database_factory import DatabaseFactory
15-
from common.models.messages_kernel import (AgentMessage, AgentType,
16-
HumanClarification, HumanFeedback,
17-
InputTask, Plan, PlanStatus,
18-
PlanWithSteps, Step, UserLanguage)
16+
from common.models.messages_kernel import (
17+
AgentMessage,
18+
AgentType,
19+
HumanClarification,
20+
HumanFeedback,
21+
InputTask,
22+
Plan,
23+
PlanStatus,
24+
PlanWithSteps,
25+
Step,
26+
UserLanguage,
27+
)
1928
from common.utils.event_utils import track_event_if_configured
2029
from common.utils.utils_date import format_dates_in_messages
30+
2131
# Updated import for KernelArguments
2232
from common.utils.utils_kernel import rai_success
33+
2334
# FastAPI imports
2435
from fastapi import FastAPI, HTTPException, Query, Request, WebSocket
2536
from fastapi.middleware.cors import CORSMiddleware
2637
from kernel_agents.agent_factory import AgentFactory
38+
2739
# Local imports
2840
from middleware.health_check import HealthCheckMiddleware
2941
from v3.api.router import app_v3
3042
from common.utils.websocket_streaming import websocket_streaming_endpoint, ws_manager
43+
3144
# Semantic Kernel imports
32-
from v3.config.settings import orchestration_config
33-
from v3.magentic_agents.magentic_agent_factory import (cleanup_all_agents,
34-
get_agents)
45+
# from v3.config.settings import orchestration_config
46+
# from v3.magentic_agents.magentic_agent_factory import cleanup_all_agents, get_agents
3547

3648
# Check if the Application Insights Instrumentation Key is set in the environment variables
3749
connection_string = config.APPLICATIONINSIGHTS_CONNECTION_STRING
@@ -91,6 +103,7 @@
91103
app.include_router(app_v3)
92104
logging.info("Added health check middleware")
93105

106+
94107
# WebSocket streaming endpoint
95108
@app.websocket("/ws/streaming")
96109
async def websocket_endpoint(websocket: WebSocket):
@@ -604,6 +617,7 @@ async def approve_step_endpoint(
604617

605618
return {"status": "All steps approved"}
606619

620+
607621
# Get plans is called in the initial side rendering of the frontend
608622
@app.get("/api/plans")
609623
async def get_plans(
@@ -677,7 +691,7 @@ async def get_plans(
677691
"UserIdNotFound", {"status_code": 400, "detail": "no user"}
678692
)
679693
raise HTTPException(status_code=400, detail="no user")
680-
694+
681695
# Initialize agent team for this user session
682696
await orchestration_config.get_current_orchestration(user_id=user_id)
683697

@@ -906,66 +920,73 @@ async def test_streaming_updates(plan_id: str):
906920
Test endpoint to simulate streaming updates for a plan.
907921
This is for testing the WebSocket streaming functionality.
908922
"""
909-
from common.utils.websocket_streaming import send_plan_update, send_agent_message, send_step_update
910-
923+
from common.utils.websocket_streaming import (
924+
send_plan_update,
925+
send_agent_message,
926+
send_step_update,
927+
)
928+
911929
try:
912930
# Simulate a series of streaming updates
913931
await send_agent_message(
914932
plan_id=plan_id,
915933
agent_name="Data Analyst",
916934
content="Starting analysis of the data...",
917-
message_type="thinking"
935+
message_type="thinking",
918936
)
919-
937+
920938
await asyncio.sleep(1)
921-
939+
922940
await send_plan_update(
923941
plan_id=plan_id,
924942
step_id="step_1",
925943
agent_name="Data Analyst",
926944
content="Analyzing customer data patterns...",
927945
status="in_progress",
928-
message_type="action"
946+
message_type="action",
929947
)
930-
948+
931949
await asyncio.sleep(2)
932-
950+
933951
await send_agent_message(
934952
plan_id=plan_id,
935-
agent_name="Data Analyst",
953+
agent_name="Data Analyst",
936954
content="Found 3 key insights in the customer data. Processing recommendations...",
937-
message_type="result"
955+
message_type="result",
938956
)
939-
957+
940958
await asyncio.sleep(1)
941-
959+
942960
await send_step_update(
943961
plan_id=plan_id,
944962
step_id="step_1",
945963
status="completed",
946-
content="Data analysis completed successfully!"
964+
content="Data analysis completed successfully!",
947965
)
948-
966+
949967
await send_agent_message(
950968
plan_id=plan_id,
951969
agent_name="Business Advisor",
952970
content="Reviewing the analysis results and preparing strategic recommendations...",
953-
message_type="thinking"
971+
message_type="thinking",
954972
)
955-
973+
956974
await asyncio.sleep(2)
957-
975+
958976
await send_plan_update(
959977
plan_id=plan_id,
960-
step_id="step_2",
978+
step_id="step_2",
961979
agent_name="Business Advisor",
962980
content="Based on the data analysis, I recommend focusing on customer retention strategies for the identified high-value segments.",
963981
status="completed",
964-
message_type="result"
982+
message_type="result",
965983
)
966-
967-
return {"status": "success", "message": f"Test streaming updates sent for plan {plan_id}"}
968-
984+
985+
return {
986+
"status": "success",
987+
"message": f"Test streaming updates sent for plan {plan_id}",
988+
}
989+
969990
except Exception as e:
970991
logging.error(f"Error sending test streaming updates: {e}")
971992
raise HTTPException(status_code=500, detail=str(e))

src/backend/v3/api/router.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
from v3.common.services.team_service import TeamService
1919
from kernel_agents.agent_factory import AgentFactory
2020
from common.database.database_factory import DatabaseFactory
21+
22+
# from v3.config.settings import orchestration_config
23+
from v3.models.models import MPlan, MStep
2124
from v3.models.orchestration_models import AgentType
2225
from common.config.app_config import config
2326

src/backend/v3/config/settings.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
from common.config.app_config import config
99
from semantic_kernel.agents.orchestration.magentic import MagenticOrchestration
1010
from semantic_kernel.connectors.ai.open_ai import (
11-
AzureChatCompletion, OpenAIChatPromptExecutionSettings)
12-
from v3.magentic_agents.magentic_agent_factory import (cleanup_all_agents,
13-
get_agents)
14-
from v3.orchestration.manager import init_orchestration
11+
AzureChatCompletion,
12+
OpenAIChatPromptExecutionSettings,
13+
)
14+
15+
# from v3.magentic_agents.magentic_agent_factory import (cleanup_all_agents,
16+
# get_agents)
17+
# from v3.orchestration.manager import init_orchestration
1518

1619

1720
class AzureConfig:
@@ -58,22 +61,23 @@ def get_headers(self, token):
5861
if token
5962
else {}
6063
)
61-
62-
class OrchestrationConfig:
63-
"""Configuration for orchestration settings."""
6464

65-
def __init__(self):
66-
self._orchestrations = {}
6765

68-
async def get_current_orchestration(self, user_id: str) -> MagenticOrchestration:
69-
"""Initialize or get existing orchestration instance."""
70-
if user_id not in self._orchestrations:
71-
agents = await get_agents()
72-
self._orchestrations[user_id] = await init_orchestration(agents)
73-
return self._orchestrations[user_id]
66+
# class OrchestrationConfig:
67+
# """Configuration for orchestration settings."""
68+
69+
# def __init__(self):
70+
# self._orchestrations = {}
71+
72+
# async def get_current_orchestration(self, user_id: str) -> MagenticOrchestration:
73+
# """Initialize or get existing orchestration instance."""
74+
# if user_id not in self._orchestrations:
75+
# agents = await get_agents()
76+
# self._orchestrations[user_id] = await init_orchestration(agents)
77+
# return self._orchestrations[user_id]
7478

7579

7680
# Global config instances
7781
azure_config = AzureConfig()
7882
mcp_config = MCPConfig()
79-
orchestration_config = OrchestrationConfig()
83+
# orchestration_config = OrchestrationConfig()

0 commit comments

Comments
 (0)