18
18
from autogen_agentchat .base import Response
19
19
import json
20
20
import os
21
- import asyncio
22
21
from datetime import datetime
23
22
23
+
24
24
class EmptyResponseUserProxyAgent (UserProxyAgent ):
25
25
"""UserProxyAgent that automatically responds with empty messages."""
26
+
26
27
def __init__ (self , name ):
27
28
super ().__init__ (name = name )
28
29
self ._has_responded = False
@@ -35,6 +36,7 @@ async def on_messages_stream(self, messages, sender=None, config=None):
35
36
yield message
36
37
yield Response (chat_message = message )
37
38
39
+
38
40
class AutoGenText2Sql :
39
41
def __init__ (self , engine_specific_rules : str , ** kwargs : dict ):
40
42
self .use_query_cache = False
@@ -65,32 +67,31 @@ def get_all_agents(self):
65
67
"""Get all agents for the complete flow."""
66
68
# Get current datetime for the Query Rewrite Agent
67
69
current_datetime = datetime .now ()
68
-
70
+
69
71
QUERY_REWRITE_AGENT = LLMAgentCreator .create (
70
- "query_rewrite_agent" ,
71
- current_datetime = current_datetime
72
+ "query_rewrite_agent" , current_datetime = current_datetime
72
73
)
73
-
74
+
74
75
SQL_QUERY_GENERATION_AGENT = LLMAgentCreator .create (
75
76
"sql_query_generation_agent" ,
76
77
target_engine = self .target_engine ,
77
78
engine_specific_rules = self .engine_specific_rules ,
78
79
** self .kwargs ,
79
80
)
80
-
81
+
81
82
SQL_SCHEMA_SELECTION_AGENT = SqlSchemaSelectionAgent (
82
83
target_engine = self .target_engine ,
83
84
engine_specific_rules = self .engine_specific_rules ,
84
85
** self .kwargs ,
85
86
)
86
-
87
+
87
88
SQL_QUERY_CORRECTION_AGENT = LLMAgentCreator .create (
88
89
"sql_query_correction_agent" ,
89
90
target_engine = self .target_engine ,
90
91
engine_specific_rules = self .engine_specific_rules ,
91
92
** self .kwargs ,
92
93
)
93
-
94
+
94
95
SQL_DISAMBIGUATION_AGENT = LLMAgentCreator .create (
95
96
"sql_disambiguation_agent" ,
96
97
target_engine = self .target_engine ,
@@ -101,11 +102,9 @@ def get_all_agents(self):
101
102
QUESTION_DECOMPOSITION_AGENT = LLMAgentCreator .create (
102
103
"question_decomposition_agent"
103
104
)
104
-
105
+
105
106
# Auto-responding UserProxyAgent
106
- USER_PROXY = EmptyResponseUserProxyAgent (
107
- name = "user_proxy"
108
- )
107
+ USER_PROXY = EmptyResponseUserProxyAgent (name = "user_proxy" )
109
108
110
109
agents = [
111
110
USER_PROXY ,
@@ -114,7 +113,7 @@ def get_all_agents(self):
114
113
SQL_SCHEMA_SELECTION_AGENT ,
115
114
SQL_QUERY_CORRECTION_AGENT ,
116
115
QUESTION_DECOMPOSITION_AGENT ,
117
- SQL_DISAMBIGUATION_AGENT
116
+ SQL_DISAMBIGUATION_AGENT ,
118
117
]
119
118
120
119
if self .use_query_cache :
@@ -192,7 +191,6 @@ def agentic_flow(self):
192
191
allow_repeated_speaker = False ,
193
192
model_client = LLMModelCreator .get_model ("4o-mini" ),
194
193
termination_condition = self .termination_condition ,
195
- selector_func = self .selector ,
196
194
selector_func = self .unified_selector ,
197
195
)
198
196
return flow
0 commit comments