in orchestration/strategies/chat_with_fabric_strategy.py [0:0]
def custom_selector_func(messages):
"""
Selects the next agent based on the last message.
"""
last_msg = messages[-1]
if last_msg.source == "user":
return "triage_agent"
if isinstance(last_msg, TextMessage) and re.search(r"QUESTION_ANSWERED\.?$", last_msg.content.strip()):
return "chat_closure"
def is_datasource_selected(source, keyword):
return last_msg.source == "triage_agent" and \
"DATASOURCE_SELECTED" in last_msg.content.strip() and \
keyword in last_msg.content.strip()
agent_mapping = {
"sql_query_agent": "sql_endpoint",
"dax_query_agent": "semantic_model"
}
for agent, keyword in agent_mapping.items():
if last_msg.source == agent or is_datasource_selected(last_msg.source, keyword):
return agent
return "triage_agent"