chainyo commited on
Commit
c7ced1a
·
1 Parent(s): 43478d2
Files changed (1) hide show
  1. main.py +19 -19
main.py CHANGED
@@ -46,26 +46,26 @@ st.title("PubMed Embeddings")
46
  st.subheader("Search for a PubMed article and get its id.")
47
 
48
 
49
- with st.text_input("Password", type="password") as password:
50
- if password == config.password:
51
- st.write("Password correct!")
52
- text = st.text_input("Search for a PubMed article", "Epidemiology of COVID-19")
53
 
54
- with st.spinner("Loading Embedding Model..."):
55
- pinecone.init(api_key=config.pinecone_api_key, env=config.pinecone_env)
56
- if "index" not in st.session_state:
57
- st.session_state.index = pinecone.Index(config.pinecone_index)
58
- if "tokenizer" not in st.session_state:
59
- st.session_state.tokenizer = AutoTokenizer.from_pretrained(config.model_name)
60
- if "model" not in st.session_state:
61
- st.session_state.model = AutoModel.from_pretrained(config.model_name)
62
 
63
- if st.button("Search"):
64
- with st.spinner("Searching..."):
65
- results = search(text)
66
 
67
- for res in results["matches"]:
68
- st.write(f"{res['id']} - confidence: {res['score']:.2f}")
69
- else:
70
- st.write("Password incorrect!")
71
 
 
46
  st.subheader("Search for a PubMed article and get its id.")
47
 
48
 
49
+ password = st.text_input("Password", type="password")
50
+ if password == config.password:
51
+ st.write("Password correct!")
52
+ text = st.text_input("Search for a PubMed article", "Epidemiology of COVID-19")
53
 
54
+ with st.spinner("Loading Embedding Model..."):
55
+ pinecone.init(api_key=config.pinecone_api_key, env=config.pinecone_env)
56
+ if "index" not in st.session_state:
57
+ st.session_state.index = pinecone.Index(config.pinecone_index)
58
+ if "tokenizer" not in st.session_state:
59
+ st.session_state.tokenizer = AutoTokenizer.from_pretrained(config.model_name)
60
+ if "model" not in st.session_state:
61
+ st.session_state.model = AutoModel.from_pretrained(config.model_name)
62
 
63
+ if st.button("Search"):
64
+ with st.spinner("Searching..."):
65
+ results = search(text)
66
 
67
+ for res in results["matches"]:
68
+ st.write(f"{res['id']} - confidence: {res['score']:.2f}")
69
+ else:
70
+ st.write("Password incorrect!")
71