Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,31 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
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 |
self.base_url = "https://agkd0n-fa.myshopify.com/products/"
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
def process_query(self, query):
|
14 |
intent, confidence = self.intent_classifier.classify(query)
|
15 |
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
3 |
+
import subprocess
|
4 |
+
import spacy
|
5 |
from sql_generator import SQLGenerator
|
6 |
from intent_classifier import IntentClassifier
|
7 |
from rag_system import RAGSystem
|
8 |
|
9 |
class UnifiedSystem:
|
10 |
def __init__(self):
|
11 |
+
# Download the spaCy model if not present
|
12 |
+
self.download_spacy_model()
|
13 |
+
self.nlp = spacy.load("en_core_web_sm") # Load the spaCy model
|
14 |
+
|
15 |
self.sql_generator = SQLGenerator()
|
16 |
self.intent_classifier = IntentClassifier()
|
17 |
self.rag_system = RAGSystem()
|
18 |
self.base_url = "https://agkd0n-fa.myshopify.com/products/"
|
19 |
|
20 |
+
def download_spacy_model(self):
|
21 |
+
"""Download the spaCy model if it's not already installed."""
|
22 |
+
try:
|
23 |
+
# Check if the model is already downloaded
|
24 |
+
import en_core_web_sm
|
25 |
+
except ImportError:
|
26 |
+
# If not, download the model
|
27 |
+
subprocess.run(["python", "-m", "spacy", "download", "en_core_web_sm"])
|
28 |
+
|
29 |
def process_query(self, query):
|
30 |
intent, confidence = self.intent_classifier.classify(query)
|
31 |
|