Spaces:
Runtime error
Runtime error
AnanyaPathak
commited on
Commit
•
5489720
1
Parent(s):
e349a16
update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import pinecone
|
2 |
-
import streamlit
|
|
|
3 |
|
4 |
index_id = "youtube-search"
|
5 |
|
@@ -9,8 +10,18 @@ pinecone.init(
|
|
9 |
)
|
10 |
index = pinecone.Index(index_id)
|
11 |
|
12 |
-
query =
|
|
|
|
|
|
|
13 |
|
14 |
xq = model.encode(query).tolist()
|
15 |
|
16 |
-
index.query(xq, top_k=5, include_metadata=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import pinecone
|
2 |
+
import streamlit as st
|
3 |
+
from sentence_transformers import SentenceTransformer
|
4 |
|
5 |
index_id = "youtube-search"
|
6 |
|
|
|
10 |
)
|
11 |
index = pinecone.Index(index_id)
|
12 |
|
13 |
+
query = st.text_iput("Query (exmaple: when to raise funds?)")
|
14 |
+
model_id = "multi-qa-mpnet-base-dot-v1"
|
15 |
+
|
16 |
+
model = SentenceTransformer(model_id)
|
17 |
|
18 |
xq = model.encode(query).tolist()
|
19 |
|
20 |
+
output = index.query(xq, top_k=5, include_metadata=True)
|
21 |
+
for o in output["matches"]:
|
22 |
+
url = o["id"].split("-")[0]
|
23 |
+
start = o["metadata"]["start"]
|
24 |
+
url_time = "https://youtu.be/" + url+ f"?t={start}"
|
25 |
+
text = o["metadata"]["text"]
|
26 |
+
st.write(url_time)
|
27 |
+
st.write(text)
|