File size: 1,392 Bytes
fb58d38
 
14601d2
fb58d38
 
 
14601d2
fb58d38
 
14601d2
 
 
 
 
 
 
fb58d38
 
 
 
 
 
 
 
 
 
 
14601d2
 
 
 
 
fb58d38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fa7521b
fb58d38
 
 
14601d2
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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)