Spaces:
Runtime error
Runtime error
Commit
·
d4a5514
1
Parent(s):
8ca0641
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ embedding_table = cache_data["embeddings"]
|
|
15 |
reviews = cache_data["data"]
|
16 |
reviews['price'] = reviews.price.apply(lambda x: re.findall("\d+", x.replace(",","").replace(".00","").replace("$",""))[0]).astype('int')
|
17 |
|
18 |
-
def user_query_recommend(query,
|
19 |
# Embed user query
|
20 |
embedding = model.encode(query)
|
21 |
|
@@ -27,20 +27,23 @@ def user_query_recommend(query, min_p, max_p):
|
|
27 |
recommendations = reviews.copy()
|
28 |
recommendations['sim'] = sim_scores.T
|
29 |
recommendations = recommendations.sort_values('sim', ascending=False)
|
30 |
-
if
|
31 |
-
min_p = 0
|
|
|
|
|
|
|
|
|
32 |
recommendations = recommendations.loc[(recommendations.price >= min_p) &
|
33 |
(recommendations.price <= max_p),
|
34 |
-
['name', 'price', 'description']].head(
|
35 |
|
36 |
return recommendations.reset_index(drop=True)
|
37 |
|
38 |
interface = gr.Interface(
|
39 |
user_query_recommend,
|
40 |
inputs=[gr.inputs.Textbox(lines=5, label = "enter flavour profile"),
|
41 |
-
gr.inputs.
|
42 |
-
|
43 |
-
outputs=gr.outputs.Dataframe(max_rows=3, overflow_row_behaviour="paginate", type="pandas", label="Scotch recommendations"),
|
44 |
title = "Scotch Recommendation",
|
45 |
description = "Looking for scotch recommendations and have some flavours in mind? \nGet recommendations at a preferred price range using semantic search :) ",
|
46 |
examples=[["very sweet with lemons and oranges and marmalades", 10,40],
|
|
|
15 |
reviews = cache_data["data"]
|
16 |
reviews['price'] = reviews.price.apply(lambda x: re.findall("\d+", x.replace(",","").replace(".00","").replace("$",""))[0]).astype('int')
|
17 |
|
18 |
+
def user_query_recommend(query, price_rng):
|
19 |
# Embed user query
|
20 |
embedding = model.encode(query)
|
21 |
|
|
|
27 |
recommendations = reviews.copy()
|
28 |
recommendations['sim'] = sim_scores.T
|
29 |
recommendations = recommendations.sort_values('sim', ascending=False)
|
30 |
+
if price_rng == "$0-$50":
|
31 |
+
min_p, max_p = 0, 50
|
32 |
+
if price_rng == "$50-$100":
|
33 |
+
min_p, max_p = 50, 100
|
34 |
+
if price_rng == "$100+":
|
35 |
+
min_p, max_p = 100, 10000
|
36 |
recommendations = recommendations.loc[(recommendations.price >= min_p) &
|
37 |
(recommendations.price <= max_p),
|
38 |
+
['name', 'price', 'description']].head(5)
|
39 |
|
40 |
return recommendations.reset_index(drop=True)
|
41 |
|
42 |
interface = gr.Interface(
|
43 |
user_query_recommend,
|
44 |
inputs=[gr.inputs.Textbox(lines=5, label = "enter flavour profile"),
|
45 |
+
gr.inputs.Radio(choices = ["$0-$50", "$50-$100", "$100+"], default="$0-$50", type="value", label='Price range')],
|
46 |
+
outputs=gr.outputs.Dataframe(max_rows=1, overflow_row_behaviour="paginate", type="pandas", label="Scotch recommendations"),
|
|
|
47 |
title = "Scotch Recommendation",
|
48 |
description = "Looking for scotch recommendations and have some flavours in mind? \nGet recommendations at a preferred price range using semantic search :) ",
|
49 |
examples=[["very sweet with lemons and oranges and marmalades", 10,40],
|