|
import streamlit as st |
|
import os |
|
|
|
from langchain_community.vectorstores import FAISS |
|
|
|
from dotenv import load_dotenv |
|
from sentence_transformers import SentenceTransformer |
|
load_dotenv() |
|
|
|
key = os.getenv("GOOGLE_API_KEY") |
|
os.environ["GOOGLE_API_KEY"]=key |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
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: |
|
|
|
|
|
docs = db.similarity_search(user_input) |
|
|
|
st.subheader("Top Matches:") |
|
st.text(docs[0].page_content) |
|
st.text(docs[1].page_content) |
|
|
|
|
|
|
|
|
|
|