Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,18 +2,14 @@ import gradio as gr
|
|
2 |
from sql_generator import SQLGenerator
|
3 |
from intent_classifier import IntentClassifier
|
4 |
from rag_system import RAGSystem
|
5 |
-
import threading
|
6 |
|
7 |
class UnifiedSystem:
|
8 |
def __init__(self):
|
9 |
self.sql_generator = SQLGenerator()
|
10 |
self.intent_classifier = IntentClassifier()
|
11 |
self.rag_system = RAGSystem()
|
12 |
-
|
13 |
-
self.stop_event = threading.Event() # Event to stop the current process
|
14 |
-
|
15 |
def process_query(self, query):
|
16 |
-
self.stop_event.clear() # Clear the stop event
|
17 |
intent, confidence = self.intent_classifier.classify(query)
|
18 |
|
19 |
if intent == "database_query":
|
@@ -36,9 +32,6 @@ class UnifiedSystem:
|
|
36 |
f"Response: {rag_response}"
|
37 |
|
38 |
return "Intent not recognized."
|
39 |
-
|
40 |
-
def stop_query(self):
|
41 |
-
self.stop_event.set() # Set the event to stop the current process
|
42 |
|
43 |
def create_interface():
|
44 |
system = UnifiedSystem()
|
@@ -51,17 +44,12 @@ def create_interface():
|
|
51 |
),
|
52 |
outputs=gr.Textbox(label="Response"),
|
53 |
title="Unified Query Processing System",
|
54 |
-
description="Enter a natural language query to search products or get descriptions."
|
55 |
-
live=False # Live updates are not needed for this scenario
|
56 |
-
)
|
57 |
-
|
58 |
-
# Add a button to stop the current query
|
59 |
-
iface.add_button(
|
60 |
-
"Kill Query",
|
61 |
-
lambda: system.stop_query(),
|
62 |
-
elem_id="stop-button"
|
63 |
)
|
64 |
|
|
|
|
|
|
|
65 |
return iface
|
66 |
|
67 |
if __name__ == "__main__":
|
|
|
2 |
from sql_generator import SQLGenerator
|
3 |
from intent_classifier import IntentClassifier
|
4 |
from rag_system import RAGSystem
|
|
|
5 |
|
6 |
class UnifiedSystem:
|
7 |
def __init__(self):
|
8 |
self.sql_generator = SQLGenerator()
|
9 |
self.intent_classifier = IntentClassifier()
|
10 |
self.rag_system = RAGSystem()
|
11 |
+
|
|
|
|
|
12 |
def process_query(self, query):
|
|
|
13 |
intent, confidence = self.intent_classifier.classify(query)
|
14 |
|
15 |
if intent == "database_query":
|
|
|
32 |
f"Response: {rag_response}"
|
33 |
|
34 |
return "Intent not recognized."
|
|
|
|
|
|
|
35 |
|
36 |
def create_interface():
|
37 |
system = UnifiedSystem()
|
|
|
44 |
),
|
45 |
outputs=gr.Textbox(label="Response"),
|
46 |
title="Unified Query Processing System",
|
47 |
+
description="Enter a natural language query to search products or get descriptions."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
)
|
49 |
|
50 |
+
# Optionally, add a button here (though not necessary, as the textbox will have submit functionality)
|
51 |
+
iface.add_component(gr.Button(label="Submit"))
|
52 |
+
|
53 |
return iface
|
54 |
|
55 |
if __name__ == "__main__":
|