Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ st.set_page_config(page_title="Search Engine", layout="wide")
|
|
13 |
|
14 |
# Set up the Streamlit app title and search bar
|
15 |
st.title("Search Engine")
|
16 |
-
if st.button("Connect to Search Engine Database", type="primary")
|
17 |
index_name = st.text_input("Enter a database name:", "")
|
18 |
key = st.text_input("Enter a key:", "")
|
19 |
namespace = st.text_input("Enter a table name:", "")
|
@@ -34,20 +34,19 @@ if st.button("Connect to Search Engine Database", type="primary")
|
|
34 |
# connect to index
|
35 |
index = pc.Index(index_name)
|
36 |
st.write('Successfully connected to your Search Engine DB!')
|
37 |
-
|
38 |
-
st.write("Goodbye")
|
39 |
|
40 |
|
41 |
-
query = st.text_input("Enter a search query:", "")
|
42 |
-
|
43 |
-
# If the user has entered a search query, search the Pinecone index with the query
|
44 |
-
if query:
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
13 |
|
14 |
# Set up the Streamlit app title and search bar
|
15 |
st.title("Search Engine")
|
16 |
+
if st.button("Connect to Search Engine Database", type="primary"):
|
17 |
index_name = st.text_input("Enter a database name:", "")
|
18 |
key = st.text_input("Enter a key:", "")
|
19 |
namespace = st.text_input("Enter a table name:", "")
|
|
|
34 |
# connect to index
|
35 |
index = pc.Index(index_name)
|
36 |
st.write('Successfully connected to your Search Engine DB!')
|
37 |
+
st.write('Start searching...')
|
|
|
38 |
|
39 |
|
40 |
+
query = st.text_input("Enter a search query:", "")
|
41 |
+
|
42 |
+
# If the user has entered a search query, search the Pinecone index with the query
|
43 |
+
if query:
|
44 |
+
# Upsert the embeddings for the query into the Pinecone index
|
45 |
+
query_embeddings = model.encode(query).tolist()
|
46 |
+
# now query
|
47 |
+
xc = index.query(vector=query_embeddings, top_k=10, namespace=namespace, include_metadata=True)
|
48 |
+
|
49 |
+
# Display the search results
|
50 |
+
st.write(f"Search results for '{query}':")
|
51 |
+
for result in xc['matches']:
|
52 |
+
st.write(f"{round(result['score'], 2)}: {result['metadata']['meta_text']}")
|