Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -45,10 +45,9 @@ embeddings = np.load("netflix_embeddings.npy") #created using sentence_transfor
|
|
45 |
metadata = pd.read_csv("netflix_metadata.csv") #created using sentence_transformers on kaggle
|
46 |
|
47 |
# Vector search function
|
48 |
-
def vector_search(query,
|
49 |
query_embedding = sentence_model.encode(query)
|
50 |
similarities = cosine_similarity([query_embedding], embeddings)[0]
|
51 |
-
top_n=response_amount
|
52 |
top_indices = similarities.argsort()[-top_n:][::-1]
|
53 |
results = metadata.iloc[top_indices]
|
54 |
result_text=""
|
@@ -61,6 +60,8 @@ def vector_search(query,response_amount=3):
|
|
61 |
|
62 |
|
63 |
def set_response_amount(response_amount):
|
|
|
|
|
64 |
return response_amount
|
65 |
|
66 |
# Based on the selected input type, make the appropriate input visible
|
|
|
45 |
metadata = pd.read_csv("netflix_metadata.csv") #created using sentence_transformers on kaggle
|
46 |
|
47 |
# Vector search function
|
48 |
+
def vector_search(query,top_n=3):
|
49 |
query_embedding = sentence_model.encode(query)
|
50 |
similarities = cosine_similarity([query_embedding], embeddings)[0]
|
|
|
51 |
top_indices = similarities.argsort()[-top_n:][::-1]
|
52 |
results = metadata.iloc[top_indices]
|
53 |
result_text=""
|
|
|
60 |
|
61 |
|
62 |
def set_response_amount(response_amount):
|
63 |
+
if response_amount is None:
|
64 |
+
return 3
|
65 |
return response_amount
|
66 |
|
67 |
# Based on the selected input type, make the appropriate input visible
|