palitrajarshi commited on
Commit
f3ce637
β€’
1 Parent(s): 0644c3a

Upload Job_Hunting_Bot.py

Browse files
Files changed (1) hide show
  1. pages/Job_Hunting_Bot.py +85 -0
pages/Job_Hunting_Bot.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils import *
3
+ import constants
4
+
5
+ # Creating Session State Variable
6
+ if 'HuggingFace_API_Key' not in st.session_state:
7
+ st.session_state['HuggingFace_API_Key'] =''
8
+ if 'Pinecone_API_Key' not in st.session_state:
9
+ st.session_state['Pinecone_API_Key'] =''
10
+
11
+
12
+ #
13
+ st.title('πŸ€– AI Assistance For Website')
14
+
15
+ #********SIDE BAR Funtionality started*******
16
+
17
+ # Sidebar to capture the API keys
18
+ st.sidebar.title("πŸ˜ŽπŸ—οΈ")
19
+ st.session_state['HuggingFace_API_Key']= st.sidebar.text_input("What's your HuggingFace API key?",type="password")
20
+ st.session_state['Pinecone_API_Key']= st.sidebar.text_input("What's your Pinecone API key?",type="password")
21
+
22
+ load_button = st.sidebar.button("Load data to Pinecone", key="load_button")
23
+
24
+ #If the bove button is clicked, pushing the data to Pinecone...
25
+ if load_button:
26
+ #Proceed only if API keys are provided
27
+ if st.session_state['HuggingFace_API_Key'] !="" and st.session_state['Pinecone_API_Key']!="" :
28
+
29
+ #Fetch data from site
30
+ site_data=get_website_data(constants.WEBSITE_URL)
31
+ st.write("Data pull done...")
32
+
33
+ #Split data into chunks
34
+ chunks_data=split_data(site_data)
35
+ st.write("Spliting data done...")
36
+
37
+ #Creating embeddings instance
38
+ embeddings=create_embeddings()
39
+ st.write("Embeddings instance creation done...")
40
+
41
+ #Push data to Pinecone
42
+ push_to_pinecone(st.session_state['Pinecone_API_Key'],constants.PINECONE_ENVIRONMENT,constants.PINECONE_INDEX,embeddings,chunks_data)
43
+ st.write("Pushing data to Pinecone done...")
44
+
45
+ st.sidebar.success("Data pushed to Pinecone successfully!")
46
+ else:
47
+ st.sidebar.error("Ooopssss!!! Please provide API keys.....")
48
+
49
+ #********SIDE BAR Funtionality ended*******
50
+
51
+ #Captures User Inputs
52
+ prompt = st.text_input('How can I help you my friend ❓',key="prompt") # The box for the text prompt
53
+ document_count = st.slider('No.Of links to return πŸ”— - (0 LOW || 5 HIGH)', 0, 5, 2,step=1)
54
+
55
+ submit = st.button("Search")
56
+
57
+
58
+ if submit:
59
+ #Proceed only if API keys are provided
60
+ if st.session_state['HuggingFace_API_Key'] !="" and st.session_state['Pinecone_API_Key']!="" :
61
+
62
+ #Creating embeddings instance
63
+ embeddings=create_embeddings()
64
+ st.write("Embeddings instance creation done...")
65
+
66
+ #Pull index data from Pinecone
67
+ index=pull_from_pinecone(st.session_state['Pinecone_API_Key'],constants.PINECONE_ENVIRONMENT,constants.PINECONE_INDEX,embeddings)
68
+ st.write("Pinecone index retrieval done...")
69
+
70
+ #Fetch relavant documents from Pinecone index
71
+ relavant_docs=get_similar_docs(index,prompt,document_count)
72
+ #st.write(relavant_docs)
73
+
74
+ #Displaying search results
75
+ st.success("Please find the search results :")
76
+ #Displaying search results
77
+ st.write("search results list....")
78
+ for document in relavant_docs:
79
+
80
+ st.write("πŸ‘‰**Result : "+ str(relavant_docs.index(document)+1)+"**")
81
+ st.write("**Info**: "+document.page_content)
82
+ st.write("**Link**: "+ document.metadata['source'])
83
+
84
+ else:
85
+ st.sidebar.error("Ooopssss!!! Please provide API keys.....")