def identify_agent()

in AI_Agent_Service/AgentHandler.py [0:0]


    def identify_agent(self, message: str) -> Optional[CustomAIServiceAgent]:
        
        handler_agent = CustomAIServiceAgent("AgentHandler", self._agent_handler_instructions, None, model="gpt-4o")
        handler_agent._thread_id = self._thread_id
        next_agent_name = handler_agent.post_message(message)
        parsed_json = json.loads(next_agent_name)
        agent_response = CustomAIAgentResponse(**parsed_json)
        #print(f"Next Agent is : {agent_response.agent_name}")
        for agent_name, agent_instance in self._agents.items():
            #print(f"Agent Name in list: {agent_name}")
            if agent_name.lower() == agent_response.agent_name.lower():
                return agent_instance
        return None