@@ -18,164 +18,168 @@ def demo_conversation():
1818 """Demo conversation functionality."""
1919 print ("🗣️ CONVERSATION DEMO" )
2020 print ("=" * 40 )
21-
21+
2222 routing_service = IntelligentRoutingService ()
23-
23+
2424 # Test different conversation types
2525 conversations = [
2626 "Hello" ,
2727 "How are you?" ,
2828 "What can you do?" ,
2929 "Thanks for your help" ,
30- "Goodbye"
30+ "Goodbye" ,
3131 ]
32-
32+
3333 for query in conversations :
3434 print (f"\n User: { query } " )
3535 response = routing_service .handle_conversation_query (query )
3636 print (f"Assistant: { response } " )
37-
37+
3838 print ("\n " + "=" * 40 )
3939
4040
4141def demo_sql_generation ():
4242 """Demo SQL generation functionality."""
4343 print ("🗃️ SQL GENERATION DEMO" )
4444 print ("=" * 40 )
45-
45+
4646 routing_service = IntelligentRoutingService ()
47-
47+
4848 # Test different SQL queries
4949 sql_queries = [
5050 "Show me all users" ,
5151 "Find customers who made purchases in the last 30 days" ,
5252 "Get the total sales by month" ,
53- "SELECT * FROM users WHERE status = 'active'"
53+ "SELECT * FROM users WHERE status = 'active'" ,
5454 ]
55-
55+
5656 for query in sql_queries :
5757 print (f"\n User: { query } " )
5858 response = routing_service .handle_sql_query (query , [])
5959 print (f"Assistant: { response [:200 ]} ..." )
60-
60+
6161 print ("\n " + "=" * 40 )
6262
6363
6464def demo_csv_analysis ():
6565 """Demo CSV analysis functionality."""
6666 print ("📊 CSV ANALYSIS DEMO" )
6767 print ("=" * 40 )
68-
68+
6969 # Sample CSV data
7070 sample_csv = """name,age,salary,department
7171Alice,25,50000,IT
7272Bob,30,60000,HR
7373Charlie,35,70000,IT
7474Diana,28,55000,Finance
7575Eve,32,65000,HR"""
76-
76+
7777 print (f"Sample CSV Data:\n { sample_csv } " )
78-
78+
7979 routing_service = IntelligentRoutingService ()
80-
80+
8181 # Test different CSV analysis queries
8282 csv_queries = [
8383 "Show me the basic statistics of the data" ,
8484 "Create a bar chart of department distribution" ,
8585 "What is the average salary by department?" ,
86- "Show me the top 3 highest paid employees"
86+ "Show me the top 3 highest paid employees" ,
8787 ]
88-
88+
8989 for query in csv_queries :
9090 print (f"\n User: { query } " )
9191 response = routing_service .handle_csv_query (query , sample_csv )
9292 print (f"Assistant: { response [:300 ]} ..." )
93-
93+
9494 print ("\n " + "=" * 40 )
9595
9696
9797def demo_intelligent_routing ():
9898 """Demo intelligent routing functionality."""
9999 print ("🧠 INTELLIGENT ROUTING DEMO" )
100100 print ("=" * 40 )
101-
101+
102102 routing_service = IntelligentRoutingService ()
103-
103+
104104 # Test different types of queries
105105 test_queries = [
106106 ("Hello" , "CONVERSATION_AGENT" ),
107107 ("Show me all users" , "SQL_AGENT" ),
108108 ("Analyze this CSV data" , "CSV_AGENT" ),
109109 ("How are you?" , "CONVERSATION_AGENT" ),
110110 ("SELECT * FROM users" , "SQL_AGENT" ),
111- ("Create a chart from the data" , "CSV_AGENT" )
111+ ("Create a chart from the data" , "CSV_AGENT" ),
112112 ]
113-
113+
114114 for query , expected_agent in test_queries :
115115 print (f"\n Query: '{ query } '" )
116116 decision = routing_service .determine_agent (query , [], csv_loaded = True )
117117 print (f"Expected: { expected_agent } " )
118118 print (f"Actual: { decision .agent } " )
119119 print (f"Confidence: { decision .confidence } " )
120120 print (f"Reasoning: { decision .reasoning } " )
121-
121+
122122 print ("\n " + "=" * 40 )
123123
124124
125125def demo_orchestrator ():
126126 """Demo the main orchestrator functionality."""
127127 print ("🎼 ORCHESTRATOR DEMO" )
128128 print ("=" * 40 )
129-
129+
130130 orchestrator = BackendOrchestrator ()
131-
131+
132132 # Create a new session
133- session_info = orchestrator .create_new_session (NewChatRequest (session_name = "Demo Session" ))
133+ session_info = orchestrator .create_new_session (
134+ NewChatRequest (session_name = "Demo Session" )
135+ )
134136 session_id = session_info .session_id
135137 print (f"Created session: { session_id } " )
136-
138+
137139 # Test different types of interactions
138140 interactions = [
139141 ("Hello" , "conversation" ),
140142 ("Show me all users" , "sql" ),
141- ("What can you do?" , "conversation" )
143+ ("What can you do?" , "conversation" ),
142144 ]
143-
145+
144146 for query , query_type in interactions :
145147 print (f"\n User ({ query_type } ): { query } " )
146148 response = orchestrator .generate_intelligent_response (session_id , query )
147149 print (f"Assistant: { response .content [:150 ]} ..." )
148-
150+
149151 # Test CSV functionality
150152 sample_csv = "name,age,salary\n Alice,25,50000\n Bob,30,60000\n Charlie,35,70000"
151153 result = orchestrator .load_csv_data (session_id , sample_csv )
152154 print (f"\n CSV Load Result: { result ['status' ]} " )
153-
154- response = orchestrator .generate_intelligent_response (session_id , "Analyze this data" )
155+
156+ response = orchestrator .generate_intelligent_response (
157+ session_id , "Analyze this data"
158+ )
155159 print (f"CSV Analysis: { response .content [:200 ]} ..." )
156-
160+
157161 print ("\n " + "=" * 40 )
158162
159163
160164def main ():
161165 """Run all demos."""
162166 print ("🚀 Querypls Backend Functionality Demo" )
163167 print ("=" * 50 )
164-
168+
165169 demos = [
166170 ("Conversation" , demo_conversation ),
167171 ("SQL Generation" , demo_sql_generation ),
168172 ("CSV Analysis" , demo_csv_analysis ),
169173 ("Intelligent Routing" , demo_intelligent_routing ),
170174 ("Orchestrator" , demo_orchestrator ),
171175 ]
172-
176+
173177 for demo_name , demo_func in demos :
174178 try :
175179 demo_func ()
176180 except Exception as e :
177181 print (f"❌ { demo_name } demo failed: { str (e )} " )
178-
182+
179183 print ("\n 🎉 Demo completed! All backend functionality is working correctly." )
180184 print ("\n 📝 Summary:" )
181185 print ("- Conversation: Natural responses for greetings and help" )
@@ -186,4 +190,4 @@ def main():
186190
187191
188192if __name__ == "__main__" :
189- main ()
193+ main ()
0 commit comments