1818from autogen_agentchat .base import Response
1919import json
2020import os
21- import asyncio
2221from datetime import datetime
2322
23+
2424class EmptyResponseUserProxyAgent (UserProxyAgent ):
2525 """UserProxyAgent that automatically responds with empty messages."""
26+
2627 def __init__ (self , name ):
2728 super ().__init__ (name = name )
2829 self ._has_responded = False
@@ -35,6 +36,7 @@ async def on_messages_stream(self, messages, sender=None, config=None):
3536 yield message
3637 yield Response (chat_message = message )
3738
39+
3840class AutoGenText2Sql :
3941 def __init__ (self , engine_specific_rules : str , ** kwargs : dict ):
4042 self .use_query_cache = False
@@ -65,32 +67,31 @@ def get_all_agents(self):
6567 """Get all agents for the complete flow."""
6668 # Get current datetime for the Query Rewrite Agent
6769 current_datetime = datetime .now ()
68-
70+
6971 QUERY_REWRITE_AGENT = LLMAgentCreator .create (
70- "query_rewrite_agent" ,
71- current_datetime = current_datetime
72+ "query_rewrite_agent" , current_datetime = current_datetime
7273 )
73-
74+
7475 SQL_QUERY_GENERATION_AGENT = LLMAgentCreator .create (
7576 "sql_query_generation_agent" ,
7677 target_engine = self .target_engine ,
7778 engine_specific_rules = self .engine_specific_rules ,
7879 ** self .kwargs ,
7980 )
80-
81+
8182 SQL_SCHEMA_SELECTION_AGENT = SqlSchemaSelectionAgent (
8283 target_engine = self .target_engine ,
8384 engine_specific_rules = self .engine_specific_rules ,
8485 ** self .kwargs ,
8586 )
86-
87+
8788 SQL_QUERY_CORRECTION_AGENT = LLMAgentCreator .create (
8889 "sql_query_correction_agent" ,
8990 target_engine = self .target_engine ,
9091 engine_specific_rules = self .engine_specific_rules ,
9192 ** self .kwargs ,
9293 )
93-
94+
9495 SQL_DISAMBIGUATION_AGENT = LLMAgentCreator .create (
9596 "sql_disambiguation_agent" ,
9697 target_engine = self .target_engine ,
@@ -101,11 +102,9 @@ def get_all_agents(self):
101102 QUESTION_DECOMPOSITION_AGENT = LLMAgentCreator .create (
102103 "question_decomposition_agent"
103104 )
104-
105+
105106 # Auto-responding UserProxyAgent
106- USER_PROXY = EmptyResponseUserProxyAgent (
107- name = "user_proxy"
108- )
107+ USER_PROXY = EmptyResponseUserProxyAgent (name = "user_proxy" )
109108
110109 agents = [
111110 USER_PROXY ,
@@ -114,7 +113,7 @@ def get_all_agents(self):
114113 SQL_SCHEMA_SELECTION_AGENT ,
115114 SQL_QUERY_CORRECTION_AGENT ,
116115 QUESTION_DECOMPOSITION_AGENT ,
117- SQL_DISAMBIGUATION_AGENT
116+ SQL_DISAMBIGUATION_AGENT ,
118117 ]
119118
120119 if self .use_query_cache :
@@ -192,7 +191,6 @@ def agentic_flow(self):
192191 allow_repeated_speaker = False ,
193192 model_client = LLMModelCreator .get_model ("4o-mini" ),
194193 termination_condition = self .termination_condition ,
195- selector_func = self .selector ,
196194 selector_func = self .unified_selector ,
197195 )
198196 return flow
0 commit comments