Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ class UnifiedSystem:
|
|
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)
|
@@ -18,7 +19,8 @@ class UnifiedSystem:
|
|
18 |
|
19 |
if products and 'products' in products:
|
20 |
results = "\n".join([
|
21 |
-
f"Title: {p['title']}, Vendor: {p['vendor']}"
|
|
|
22 |
for p in products['products']
|
23 |
])
|
24 |
return f"Intent: Database Query (Confidence: {confidence:.2f})\n\n" \
|
@@ -28,8 +30,16 @@ class UnifiedSystem:
|
|
28 |
|
29 |
elif intent == "product_description":
|
30 |
rag_response = self.rag_system.process_query(query)
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
return "Intent not recognized."
|
35 |
|
@@ -39,7 +49,8 @@ def create_interface():
|
|
39 |
examples = [
|
40 |
"Show me shirt less than 5 USD",
|
41 |
"Show me shirt with red color",
|
42 |
-
"Show me T-shirt with M size"
|
|
|
43 |
]
|
44 |
|
45 |
iface = gr.Interface(
|
|
|
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/" # Shopify base URL for product links
|
12 |
|
13 |
def process_query(self, query):
|
14 |
intent, confidence = self.intent_classifier.classify(query)
|
|
|
19 |
|
20 |
if products and 'products' in products:
|
21 |
results = "\n".join([
|
22 |
+
f"Title: {p['title']}, Vendor: {p['vendor']}, "
|
23 |
+
f"Link: {self.base_url}{p['handle']}"
|
24 |
for p in products['products']
|
25 |
])
|
26 |
return f"Intent: Database Query (Confidence: {confidence:.2f})\n\n" \
|
|
|
30 |
|
31 |
elif intent == "product_description":
|
32 |
rag_response = self.rag_system.process_query(query)
|
33 |
+
|
34 |
+
# Assuming rag_response includes product descriptions and handles
|
35 |
+
if rag_response and 'products' in rag_response:
|
36 |
+
results = "\n".join([
|
37 |
+
f"Description: {p['description']}, Link: {self.base_url}{p['handle']}"
|
38 |
+
for p in rag_response['products']
|
39 |
+
])
|
40 |
+
return f"Intent: Product Description (Confidence: {confidence:.2f})\n\nResults:\n{results}"
|
41 |
+
else:
|
42 |
+
return "No matching products found for the description query."
|
43 |
|
44 |
return "Intent not recognized."
|
45 |
|
|
|
49 |
examples = [
|
50 |
"Show me shirt less than 5 USD",
|
51 |
"Show me shirt with red color",
|
52 |
+
"Show me T-shirt with M size",
|
53 |
+
"Describe the features of the blue jeans"
|
54 |
]
|
55 |
|
56 |
iface = gr.Interface(
|