Spaces:
Running
Running
add if condition res.score > 0.83
Browse files
app.py
CHANGED
@@ -90,7 +90,6 @@ def correct_query_merge_phrases(query: str, whitelist, threshold=80, max_ngram=3
|
|
90 |
cleaned = [word for word in corrected if len(word) > 1 or word in whitelist]
|
91 |
return "".join(cleaned)
|
92 |
|
93 |
-
|
94 |
# 🌟 Main search function
|
95 |
def search_product(query, model_name):
|
96 |
start_time = time.time()
|
@@ -109,7 +108,7 @@ def search_product(query, model_name):
|
|
109 |
query=query_embed.tolist(),
|
110 |
with_payload=True,
|
111 |
query_filter=Filter(must=[FieldCondition(key="type", match=MatchValue(value="product"))]),
|
112 |
-
limit=
|
113 |
).points
|
114 |
except Exception as e:
|
115 |
return f"<p>❌ Qdrant error: {str(e)}</p>"
|
@@ -125,6 +124,7 @@ def search_product(query, model_name):
|
|
125 |
|
126 |
result_summary = ""
|
127 |
for res in result:
|
|
|
128 |
name = res.payload.get("name", "ไม่ทราบชื่อสินค้า")
|
129 |
score = f"{res.score:.4f}"
|
130 |
img_url = res.payload.get("imageUrl", "")
|
|
|
90 |
cleaned = [word for word in corrected if len(word) > 1 or word in whitelist]
|
91 |
return "".join(cleaned)
|
92 |
|
|
|
93 |
# 🌟 Main search function
|
94 |
def search_product(query, model_name):
|
95 |
start_time = time.time()
|
|
|
108 |
query=query_embed.tolist(),
|
109 |
with_payload=True,
|
110 |
query_filter=Filter(must=[FieldCondition(key="type", match=MatchValue(value="product"))]),
|
111 |
+
limit=50
|
112 |
).points
|
113 |
except Exception as e:
|
114 |
return f"<p>❌ Qdrant error: {str(e)}</p>"
|
|
|
124 |
|
125 |
result_summary = ""
|
126 |
for res in result:
|
127 |
+
if res.score > 0.83:
|
128 |
name = res.payload.get("name", "ไม่ทราบชื่อสินค้า")
|
129 |
score = f"{res.score:.4f}"
|
130 |
img_url = res.payload.get("imageUrl", "")
|