Model3 / app.py
priyam169's picture
Update app.py
14601d2 verified
import streamlit as st
import os
# This is an open source developed by Facebook , helps us perform similariy search
from langchain_community.vectorstores import FAISS
from dotenv import load_dotenv
from sentence_transformers import SentenceTransformer #for embedding
load_dotenv()
key = os.getenv("GOOGLE_API_KEY")
os.environ["GOOGLE_API_KEY"]=key
# st.set_page_config(page_title="Educate Kids", page_icon=":robot:")
# st.header("Hey, Ask me something & I will give out similar things")
model = SentenceTransformer('sentence-transformers/average_word_embeddings_glove.6B.300d')
from langchain.document_loaders.csv_loader import CSVLoader
loader = CSVLoader(file_path='myData.csv', csv_args={
'delimiter': ',',
'quotechar': '"',
'fieldnames': ['Words']
})
data = loader.load()
db = FAISS.from_documents(data, model)
def get_text():
input_text = st.text_input("You: ", key= input)
return input_text
db = FAISS.from_documents(data, embeddings)
#Function to receive input from user
def get_text():
input_text = st.text_input("You: ", key= input)
return input_text
user_input=get_text()
submit = st.button('Find similar Things')
if submit:
#fetch the similar text
docs = db.similarity_search(user_input)
# print(docs)
st.subheader("Top Matches:")
st.text(docs[0].page_content)
st.text(docs[1].page_content)
# print(data)