Spaces:
Sleeping
Sleeping
DeepSoft-Tech
commited on
Commit
•
50474fb
1
Parent(s):
e3b290a
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
from pinecone import Pinecone
|
4 |
-
# Set up the Streamlit app
|
5 |
-
st.set_page_config(page_title="Search Engine", layout="wide")
|
6 |
-
|
7 |
-
# Set up the Streamlit app title and search bar
|
8 |
-
st.title("Search Engine")
|
9 |
-
index_name = st.text_input("Enter a database name:", "")
|
10 |
-
key = st.text_input("Enter a key:", "")
|
11 |
-
namespace = st.text_input("Enter a table name:", "")
|
12 |
-
# initialize connection to pinecone (get API key at app.pinecone.io)
|
13 |
-
api_key = os.environ.get('PINECONE_API_KEY') or key
|
14 |
-
|
15 |
-
# configure client
|
16 |
-
pc = Pinecone(api_key=api_key)
|
17 |
-
|
18 |
-
from pinecone import ServerlessSpec
|
19 |
-
|
20 |
-
cloud = os.environ.get('PINECONE_CLOUD') or 'aws'
|
21 |
-
region = os.environ.get('PINECONE_REGION') or 'us-east-1'
|
22 |
-
|
23 |
-
spec = ServerlessSpec(cloud=cloud, region=region)
|
24 |
-
|
25 |
-
|
26 |
-
# connect to index
|
27 |
-
index = pc.Index(index_name)
|
28 |
-
|
29 |
-
|
30 |
from sentence_transformers import SentenceTransformer
|
31 |
# import torch
|
32 |
|
@@ -34,7 +8,37 @@ from sentence_transformers import SentenceTransformer
|
|
34 |
|
35 |
model = SentenceTransformer('intfloat/e5-small')
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
|
|
38 |
query = st.text_input("Enter a search query:", "")
|
39 |
|
40 |
# If the user has entered a search query, search the Pinecone index with the query
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
from pinecone import Pinecone
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
from sentence_transformers import SentenceTransformer
|
5 |
# import torch
|
6 |
|
|
|
8 |
|
9 |
model = SentenceTransformer('intfloat/e5-small')
|
10 |
|
11 |
+
# Set up the Streamlit app
|
12 |
+
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 |
+
st.button("Connect to Search Engine Database", type="primary")
|
17 |
+
if st.button():
|
18 |
+
index_name = st.text_input("Enter a database name:", "")
|
19 |
+
key = st.text_input("Enter a key:", "")
|
20 |
+
namespace = st.text_input("Enter a table name:", "")
|
21 |
+
# initialize connection to pinecone (get API key at app.pinecone.io)
|
22 |
+
api_key = os.environ.get('PINECONE_API_KEY') or key
|
23 |
+
|
24 |
+
# configure client
|
25 |
+
pc = Pinecone(api_key=api_key)
|
26 |
+
|
27 |
+
from pinecone import ServerlessSpec
|
28 |
+
|
29 |
+
cloud = os.environ.get('PINECONE_CLOUD') or 'aws'
|
30 |
+
region = os.environ.get('PINECONE_REGION') or 'us-east-1'
|
31 |
+
|
32 |
+
spec = ServerlessSpec(cloud=cloud, region=region)
|
33 |
+
|
34 |
+
|
35 |
+
# connect to index
|
36 |
+
index = pc.Index(index_name)
|
37 |
+
st.write('Successfully connected to your Search Engine DB!')
|
38 |
+
else:
|
39 |
+
st.write("Goodbye")
|
40 |
|
41 |
+
|
42 |
query = st.text_input("Enter a search query:", "")
|
43 |
|
44 |
# If the user has entered a search query, search the Pinecone index with the query
|