@@ -47,6 +47,27 @@ def __init__(self):
4747from event_utils import track_event_if_configured
4848
4949
50+ class GroupChatManagerClass :
51+ """A class for service compatibility with Semantic Kernel."""
52+ # Defining properties needed by Semantic Kernel
53+ service_id = ""
54+
55+ def __init__ (self , manager ):
56+ self .manager = manager
57+ self .service_id = f"group_chat_manager_{ manager ._session_id } "
58+
59+ async def execute_next_step (self , kernel_arguments : KernelArguments ) -> str :
60+ """Execute the next step in the plan.
61+
62+ Args:
63+ kernel_arguments: KernelArguments that should contain session_id and plan_id
64+
65+ Returns:
66+ Status message
67+ """
68+ return await self .manager .execute_next_step (kernel_arguments )
69+
70+
5071class GroupChatManager :
5172 """Group Chat Manager implementation using Semantic Kernel's AgentGroupChat.
5273
@@ -83,6 +104,27 @@ def __init__(
83104 # Initialize the AgentGroupChat later when all agents are registered
84105 self ._agent_group_chat = None
85106 self ._initialized = False
107+
108+ # Create a wrapper class for service registration
109+ service_wrapper = GroupChatManagerClass (self )
110+
111+ try :
112+ # Register with kernel using the service_wrapper
113+ if hasattr (kernel , "register_services" ):
114+ kernel .register_services ({service_wrapper .service_id : service_wrapper })
115+ logging .info (f"Registered GroupChatManager as kernel service with ID: { service_wrapper .service_id } " )
116+ elif hasattr (kernel , "services" ) and hasattr (kernel .services , "register_service" ):
117+ kernel .services .register_service (service_wrapper .service_id , service_wrapper )
118+ logging .info (f"Registered GroupChatManager as kernel service with ID: { service_wrapper .service_id } " )
119+ elif hasattr (kernel , "services" ) and isinstance (kernel .services , dict ):
120+ # Last resort: directly add to services dictionary
121+ kernel .services [service_wrapper .service_id ] = service_wrapper
122+ logging .info (f"Added GroupChatManager to kernel services dictionary with ID: { service_wrapper .service_id } " )
123+ else :
124+ logging .warning ("Could not register GroupChatManager service. Semantic Kernel version might be incompatible." )
125+ except Exception as e :
126+ logging .error (f"Error registering GroupChatManager service: { e } " )
127+ # Continue without crashing
86128
87129 async def initialize_group_chat (self ) -> None :
88130 """Initialize the AgentGroupChat with registered agents and strategies."""
@@ -566,16 +608,22 @@ async def run_group_chat(self, user_input: str, plan_id: str = "", step_id: str
566608 logging .exception (f"Error running group chat: { e } " )
567609 return f"Error running group chat: { str (e )} "
568610
569- async def execute_next_step (self , session_id : str , plan_id : str ) -> str :
611+ async def execute_next_step (self , kernel_arguments : KernelArguments ) -> str :
570612 """Execute the next step in the plan.
571613
572614 Args:
573- session_id: The session identifier
574- plan_id: The plan identifier
615+ kernel_arguments: KernelArguments that should contain session_id and plan_id
575616
576617 Returns:
577618 Status message
578619 """
620+ # Extract arguments
621+ session_id = kernel_arguments .get ("session_id" , "" )
622+ plan_id = kernel_arguments .get ("plan_id" , "" )
623+
624+ if not session_id or not plan_id :
625+ return "Missing session_id or plan_id in arguments"
626+
579627 # Get all steps for the plan
580628 steps = await self ._memory_store .get_steps_for_plan (plan_id , session_id )
581629
0 commit comments