Tesneem commited on
Commit
8c30127
1 Parent(s): 75adc2b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -37,6 +37,8 @@ def generate_input(input_type, image=None, text=None, response_amount=3):
37
  # If no input, fallback
38
  if not combined_input:
39
  combined_input = "No input provided."
 
 
40
 
41
  return vector_search(combined_input,response_amount)
42
 
@@ -48,6 +50,8 @@ metadata = pd.read_csv("netflix_metadata.csv") #created using sentence_transform
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=""
@@ -90,6 +94,8 @@ with gr.Blocks() as demo:
90
 
91
  submit_button = gr.Button("Submit")
92
  output = gr.Textbox(label="Recommendations")
 
 
93
 
94
  submit_button.click(fn=generate_input, inputs=[input_type,image_input, text_input,selected_response_amount], outputs=output)
95
  demo.launch()
 
37
  # If no input, fallback
38
  if not combined_input:
39
  combined_input = "No input provided."
40
+ if response_amount is None:
41
+ response_amount=3
42
 
43
  return vector_search(combined_input,response_amount)
44
 
 
50
  def vector_search(query,top_n=3):
51
  query_embedding = sentence_model.encode(query)
52
  similarities = cosine_similarity([query_embedding], embeddings)[0]
53
+ if top_n is None:
54
+ top_n=3
55
  top_indices = similarities.argsort()[-top_n:][::-1]
56
  results = metadata.iloc[top_indices]
57
  result_text=""
 
94
 
95
  submit_button = gr.Button("Submit")
96
  output = gr.Textbox(label="Recommendations")
97
+ if selected_response_amount is None:
98
+ selected_response_amount=3
99
 
100
  submit_button.click(fn=generate_input, inputs=[input_type,image_input, text_input,selected_response_amount], outputs=output)
101
  demo.launch()