eliwill commited on
Commit
ce71abc
·
1 Parent(s): 2fee650

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -48,7 +48,7 @@ def get_similar_quotes(philosopher, question):
48
  question_embedding = model.encode(question)
49
  sims = [util.dot_score(question_embedding, quote_embedding) for quote_embedding in df['Embedding']]
50
  ind = np.argpartition(sims, -5)[-5:]
51
- similar_sentences = [df['Quotes'][i] for i in ind]
52
  top5quotes = pd.DataFrame(data = similar_sentences, columns=["Quotes"], index=range(1,6))
53
  top5quotes['Quotes'] = top5quotes['Quotes'].str[:-1].str[:250] + "..."
54
  return top5quotes
@@ -58,15 +58,15 @@ def main(question, philosopher):
58
 
59
 
60
  ############### BUILDING DEMO ################################
61
- with gr.Blocks() as demo:
62
  gr.Markdown("""
63
  # Ask a Philsopher
64
  """
65
  )
66
  with gr.Row():
67
  with gr.Column():
68
- inp1 = gr.Textbox(placeholder="Place your question here...", label="Ask a question")
69
- inp2 = gr.Dropdown(choices=["stoic", "krishnamurti"], value="stoic", label="Choose a philosopher")
70
 
71
  with gr.Column():
72
  out1 = gr.Textbox(
 
48
  question_embedding = model.encode(question)
49
  sims = [util.dot_score(question_embedding, quote_embedding) for quote_embedding in df['Embedding']]
50
  ind = np.argpartition(sims, -5)[-5:]
51
+ similar_sentences = [df['quote'][i] for i in ind]
52
  top5quotes = pd.DataFrame(data = similar_sentences, columns=["Quotes"], index=range(1,6))
53
  top5quotes['Quotes'] = top5quotes['Quotes'].str[:-1].str[:250] + "..."
54
  return top5quotes
 
58
 
59
 
60
  ############### BUILDING DEMO ################################
61
+ with gr.Blocks() as demo:
62
  gr.Markdown("""
63
  # Ask a Philsopher
64
  """
65
  )
66
  with gr.Row():
67
  with gr.Column():
68
+ inp1 = gr.Textbox(placeholder="Place your question here...", label="Ask a question")
69
+ inp2 = gr.Dropdown(choices=["stoic", "krishnamurti"], value="stoic", label="Choose a philosopher")
70
 
71
  with gr.Column():
72
  out1 = gr.Textbox(