Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,21 @@
|
|
1 |
-
|
2 |
import streamlit as st
|
3 |
import os
|
4 |
-
|
5 |
-
|
6 |
from langchain_community.vectorstores import FAISS
|
7 |
|
8 |
from dotenv import load_dotenv
|
9 |
-
|
10 |
load_dotenv()
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
#Initialize the OpenAIEmbeddings object
|
17 |
-
embeddings = OpenAIEmbeddings()
|
18 |
|
19 |
-
# import CSV file data
|
20 |
from langchain.document_loaders.csv_loader import CSVLoader
|
21 |
loader = CSVLoader(file_path='myData.csv', csv_args={
|
22 |
'delimiter': ',',
|
@@ -26,8 +25,11 @@ loader = CSVLoader(file_path='myData.csv', csv_args={
|
|
26 |
|
27 |
data = loader.load()
|
28 |
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
31 |
|
32 |
db = FAISS.from_documents(data, embeddings)
|
33 |
|
@@ -48,3 +50,7 @@ if submit:
|
|
48 |
st.subheader("Top Matches:")
|
49 |
st.text(docs[0].page_content)
|
50 |
st.text(docs[1].page_content)
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
+
# This is an open source developed by Facebook , helps us perform similariy search
|
|
|
4 |
from langchain_community.vectorstores import FAISS
|
5 |
|
6 |
from dotenv import load_dotenv
|
7 |
+
from sentence_transformers import SentenceTransformer #for embedding
|
8 |
load_dotenv()
|
9 |
|
10 |
+
key = os.getenv("GOOGLE_API_KEY")
|
11 |
+
os.environ["GOOGLE_API_KEY"]=key
|
12 |
+
|
13 |
+
# st.set_page_config(page_title="Educate Kids", page_icon=":robot:")
|
14 |
+
# st.header("Hey, Ask me something & I will give out similar things")
|
15 |
+
|
16 |
+
model = SentenceTransformer('sentence-transformers/average_word_embeddings_glove.6B.300d')
|
17 |
|
|
|
|
|
18 |
|
|
|
19 |
from langchain.document_loaders.csv_loader import CSVLoader
|
20 |
loader = CSVLoader(file_path='myData.csv', csv_args={
|
21 |
'delimiter': ',',
|
|
|
25 |
|
26 |
data = loader.load()
|
27 |
|
28 |
+
db = FAISS.from_documents(data, model)
|
29 |
+
|
30 |
+
def get_text():
|
31 |
+
input_text = st.text_input("You: ", key= input)
|
32 |
+
return input_text
|
33 |
|
34 |
db = FAISS.from_documents(data, embeddings)
|
35 |
|
|
|
50 |
st.subheader("Top Matches:")
|
51 |
st.text(docs[0].page_content)
|
52 |
st.text(docs[1].page_content)
|
53 |
+
# print(data)
|
54 |
+
|
55 |
+
|
56 |
+
|