atrytone commited on
Commit
46247a1
·
1 Parent(s): 16e869e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -1,11 +1,14 @@
1
  import gradio as gr
2
  import csv
3
  import random
 
4
  import uuid
5
  from langchain.vectorstores import FAISS
6
  from langchain.embeddings import HuggingFaceEmbeddings
7
 
8
  USER_ID = uuid.uuid4()
 
 
9
  INDEXES = ["miread_large", "miread_contrastive", "scibert_contrastive"]
10
  MODELS = [
11
  "biodatlab/MIReAD-Neuro-Large",
@@ -33,9 +36,8 @@ def get_comp(prompt):
33
  right_output = inference(prompt,right)
34
  return left_output, right_output
35
 
36
- def get_article(db_name="miread_contrastive"):
37
- db = vecdbs[INDEXES.index(db_name)]
38
- return db.docstore._dict[db.index_to_docstore_id[0]]
39
 
40
 
41
  def send_result(l_output, r_output, prompt, pick):
@@ -136,7 +138,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
136
  l_btn.click(fn=lambda x,y,z: send_result(x,y,z,'left'),
137
  inputs=[l_output,r_output,prompt],
138
  api_name="feedleft")
139
- l_btn.click(fn=lambda x,y,z: send_result(x,y,z,'right'),
140
  inputs=[l_output,r_output,prompt],
141
  api_name="feedright")
142
 
 
1
  import gradio as gr
2
  import csv
3
  import random
4
+ import pickle
5
  import uuid
6
  from langchain.vectorstores import FAISS
7
  from langchain.embeddings import HuggingFaceEmbeddings
8
 
9
  USER_ID = uuid.uuid4()
10
+ with open("article_list.pkl","rb") as articles:
11
+ article_list = pickle.load(articles)
12
  INDEXES = ["miread_large", "miread_contrastive", "scibert_contrastive"]
13
  MODELS = [
14
  "biodatlab/MIReAD-Neuro-Large",
 
36
  right_output = inference(prompt,right)
37
  return left_output, right_output
38
 
39
+ def get_article():
40
+ return random.choice(article_list)
 
41
 
42
 
43
  def send_result(l_output, r_output, prompt, pick):
 
138
  l_btn.click(fn=lambda x,y,z: send_result(x,y,z,'left'),
139
  inputs=[l_output,r_output,prompt],
140
  api_name="feedleft")
141
+ r_btn.click(fn=lambda x,y,z: send_result(x,y,z,'right'),
142
  inputs=[l_output,r_output,prompt],
143
  api_name="feedright")
144