-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
70 lines (44 loc) · 1.83 KB
/
app.py
File metadata and controls
70 lines (44 loc) · 1.83 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
import os
from dotenv import load_dotenv
import streamlit as st
from query_func import *
from upload_func import *
load_dotenv()
pinecone_apikey = os.getenv("PINECONE_APIKEY")
pinecone_environment = os.getenv("PINECONE_ENV")
pinecone_index_name = os.getenv("PINECONE_INDEX")
st.set_page_config(page_title="Your personal local LLM")
st.title("LLM at your fingertips")
tab_titles = ['Queries', 'Upload Data']
tabs = st.tabs(tab_titles)
#Query LLM
with tabs[0]:
def main():
st.header("Query Your Own Data")
st.write("Enter question here:")
user_input = st.text_input("🔍")
if user_input:
embeddings=create_embeddings()
index = pull_from_pinecone(pinecone_apikey, pinecone_environment, pinecone_index_name, embeddings)
relavant_docs=get_similar_docs(index,user_input)
response=get_answer(relavant_docs,user_input)
st.write(response)
if __name__ == '__main__':
main()
#Uploading Data
with tabs[1]:
def main():
st.header("Upload your files...📁 ")
pdf = st.file_uploader("Only PDF files allowed", type=["pdf"])
if pdf is not None:
with st.spinner('Wait for it...'):
text = read_pdf_data(pdf)
st.write("👉Reading PDF done")
docs_chunks = split_data(text)
st.write("👉Splitting data into chunks done")
embeddings = create_embeddings_load_data()
st.write("👉Creating embeddings instance done")
push_to_pinecone(pinecone_apikey, pinecone_environment, pinecone_index_name, embeddings, docs_chunks)
st.success("Successfully pushed the embeddings to Pinecone")
if __name__ == '__main__':
main()