1
1
import os
2
2
import kustoQuery
3
- import utils
3
+ import apis
4
4
from azure .kusto .data import KustoClient
5
5
from azure .kusto .data .exceptions import KustoServiceError
6
6
from azure .kusto .data .helpers import dataframe_from_result_table
@@ -21,35 +21,37 @@ def favicon():
21
21
return send_from_directory (os .path .join (app .root_path , 'static' ),
22
22
'favicon.ico' , mimetype = 'image/vnd.microsoft.icon' )
23
23
24
- @app .route ('/hello ' , methods = ['POST' ])
25
- def hello ():
26
- name = request .form .get ('name ' )
24
+ @app .route ('/execute_prompt ' , methods = ['POST' ])
25
+ def execute_prompt ():
26
+ user_input = request .form .get ('prompt ' )
27
27
28
- if name :
29
- print ('Request for hello page received with name=%s' % name )
30
-
31
- print ("Kusto Query App is starting..." )
28
+ if user_input :
29
+ print ('Prompt=%s' % user_input )
30
+ response = apis .call_openai (apis .system_prompt , user_input )
31
+ # Printing the result
32
+ print (response )
33
+ # print("Kusto Query App is starting...")
32
34
33
35
app = kustoQuery .KustoQueryApp ()
34
36
app .load_configs (app .CONFIG_FILE_NAME )
35
37
36
- if app .config .authentication_mode == "UserPrompt" :
37
- app .wait_for_user_to_proceed ("You will be prompted for credentials during this script. Please return to the console after authenticating." )
38
+ # if app.config.authentication_mode == "UserPrompt":
39
+ # app.wait_for_user_to_proceed("You will be prompted for credentials during this script. Please return to the console after authenticating.")
38
40
39
- kusto_connection_string = utils .Utils .Authentication .generate_connection_string (app .config .kusto_uri , app .config .authentication_mode )
41
+ kusto_connection_string = apis .Utils .Authentication .generate_connection_string (app .config .kusto_uri , app .config .authentication_mode )
40
42
print (f"Using cluster URI: { app .config .kusto_uri } " )
41
43
42
44
if not kusto_connection_string :
43
- utils .Utils .error_handler ("Connection String error. Please validate your configuration file." )
45
+ apis .Utils .error_handler ("Connection String error. Please validate your configuration file." )
44
46
else :
45
47
with KustoClient (kusto_connection_string ) as kusto_client :
46
- app .query_table (kusto_client , app .config .database_name , app .config .table_name )
48
+ df = app .query_table (kusto_client , app .config .database_name , app .config .table_name , response )
47
49
48
50
print ("\n Kusto Query App done" )
49
51
50
- return render_template ('hello .html' , name = name )
52
+ return render_template ('response .html' , output = df . to_string ( index = False ) )
51
53
else :
52
- print ('Request for hello page received with no name or blank name -- redirecting' )
54
+ print ('Request received without any prompt from the user or blank prompt -- redirecting' )
53
55
return redirect (url_for ('index' ))
54
56
55
57
if __name__ == '__main__' :
0 commit comments