Nicole Hye Won Hwang commited on
Commit
6010b14
1 Parent(s): 07845b7

first commit

Browse files
.DS_Store ADDED
Binary file (6.15 kB). View file
 
Documents/HR Policy Manual.docx ADDED
Binary file (16.7 kB). View file
 
Documents/HR Policy Manual.pdf ADDED
Binary file (114 kB). View file
 
Documents/IT Department Policy Manual.docx ADDED
Binary file (17.7 kB). View file
 
Documents/IT Department Policy Manual.pdf ADDED
Binary file (122 kB). View file
 
Documents/Tickets.csv ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "The bus arrived late again, causing me to miss an important meeting.",Transportation
2
+ "The taxi driver took a longer route, resulting in an inflated fare.",Transportation
3
+ "There's no proper signage at the train station, making it confusing for passengers.",Transportation
4
+ The flight was delayed for hours without any proper explanation.,Transportation
5
+ The bus driver was rude and unprofessional during the entire journey.,Transportation
6
+ "The train compartments were overcrowded, and there were no seats available.",Transportation
7
+ "I booked a cab, but it never arrived at the designated pick-up location.",Transportation
8
+ "The airline lost my luggage, and I haven't received any updates on its whereabouts.",Transportation
9
+ "The taxi had a broken seatbelt, posing a safety risk during the ride.",Transportation
10
+ "The bus broke down in the middle of the journey, causing a significant delay.",Transportation
11
+ "The train schedule is inconsistent, with frequent cancellations and delays.",Transportation
12
+ The airline customer service was unresponsive and provided no assistance.,Transportation
13
+ "The taxi smelled strongly of smoke, making the ride uncomfortable and unpleasant.",Transportation
14
+ There's a lack of wheelchair accessibility on public transportation vehicles.,Transportation
15
+ The flight attendant was rude and disrespectful towards passengers.,Transportation
16
+ "The bus station lacks proper facilities, including restrooms and waiting areas.",Transportation
17
+ "The taxi driver was speeding and driving recklessly, compromising passenger safety.",Transportation
18
+ The train ticketing system charged me twice for the same journey.,Transportation
19
+ "The airline overbooked the flight, causing me to be denied boarding.",Transportation
20
+ "The taxi driver refused to take me to my destination, citing a short trip.",Transportation
21
+ The bus seats were uncomfortable and in poor condition.,Transportation
22
+ "The train announcements were unclear, making it difficult to understand the next stop.",Transportation
23
+ "I purchased an online ticket, but the QR code was not recognized by the ticket scanner.",Transportation
24
+ "The airline misplaced my pet during the flight, causing distress and anxiety.",Transportation
25
+ "The taxi meter was tampered with, resulting in an inflated fare.",Transportation
26
+ "The bus driver skipped my designated stop, forcing me to walk a long distance.",Transportation
27
+ "The train platform was overcrowded, and there were no proper crowd management measures.",Transportation
28
+ The airline canceled my flight without any prior notification or alternative arrangements.,Transportation
29
+ "The taxi driver took a longer route to increase the fare, even though I provided directions.",Transportation
30
+ "The bus was dirty and poorly maintained, with broken seats and windows.",Transportation
31
+ "The train was extremely overcrowded, with passengers struggling to find space.",Transportation
32
+ I had difficulty finding a parking space at the airport due to insufficient availability.,Transportation
33
+ The taxi driver was playing loud music and refused to lower the volume upon request.,Transportation
34
+ "The bus driver was not following the designated route, causing confusion among passengers.",Transportation
35
+ "The train ticket vending machine was out of order, causing inconvenience to passengers.",Transportation
36
+ I experienced motion sickness due to poor driving skills of the taxi driver.,Transportation
37
+ The airline changed my flight schedule without notifying me in advance.,Transportation
38
+ "The bus was not wheelchair accessible, making it challenging for passengers with disabilities.",Transportation
39
+ "The train doors were malfunctioning, posing a safety hazard during boarding and disembarking.",Transportation
40
+ "The taxi driver was using a mobile phone while driving, endangering passengers' safety.",Transportation
41
+ "The bus driver was constantly honking unnecessarily, causing disturbance and discomfort.",Transportation
42
+ "The train was overcrowded, and there were no functioning air conditioning units.",Transportation
43
+ I received no assistance with my heavy luggage from the airline staff.,Transportation
44
+ "The taxi driver dropped me off at the wrong location, despite providing the correct address.",Transportation
45
+ "The bus schedule was inaccurate, with buses arriving either too early or too late.",Transportation
46
+ "The train station lacks proper lighting, posing safety concerns during evening hours.",Transportation
47
+ "I was wrongly charged for excess baggage on the airline, even though I was within the allowed limit.",Transportation
48
+ The taxi driver was driving aggressively and abruptly changing lanes without warning.,Transportation
49
+ The software crashes frequently during data entry. It's affecting my productivity.,IT
50
+ I haven't received my salary for the past two months. Can someone from HR please look into this?,HR
51
+ "The network is slow, and I'm unable to access important files. Could the IT team check it?",IT
52
+ I'm facing issues with my medical insurance coverage. Can HR assist me in resolving this matter?,HR
53
+ "The printer in our department is constantly jamming, causing delays in our work. IT, please fix it urgently.",IT
54
+ "I've been experiencing harassment from a colleague. HR, I need your help to address this problem.",HR
55
+ "The system keeps logging me out repeatedly. IT, please investigate and resolve this issue.",IT
56
+ "I have a concern regarding my vacation leave balance. HR, can you provide clarification?",HR
57
+ "There's a problem with the email server. I can't send or receive emails. IT, please resolve it quickly.",IT
58
+ "I believe there's an error in my tax deductions. HR, could you please review my payroll details?",HR
59
+ "The new software update is causing compatibility issues with my computer. IT, can you assist in fixing it?",IT
60
+ "HR, I haven't received any response to my promotion request. Can you please update me on the status?",HR
61
+ "The internet connection in our office is unreliable. IT, please look into this matter as soon as possible.",IT
62
+ "I need assistance with setting up my company email on my mobile device. IT, can you guide me through it?",IT
63
+ "I'm facing difficulties accessing my employee benefits portal. HR, can you help me resolve this issue?",HR
64
+ "IT, I accidentally deleted an important file. Is there any way to recover it?",IT
65
+ "I have concerns about the working hours. HR, can we discuss possible adjustments?",HR
66
+ "The video conferencing software is not functioning properly. IT, please fix it before our meeting.",IT
67
+ "I have questions about the company's policy on parental leave. HR, can you provide me with the details?",HR
68
+ "IT, the projector in the meeting room is not working. We need it for the presentation.",IT
69
+ "I'm having trouble accessing my employee account. HR, can you assist me in resetting my password?",HR
70
+ "The software is giving me error messages whenever I try to save my work. IT, please resolve this issue.",IT
71
+ "HR, there's an error in my employment contract. Can you review it and make the necessary corrections?",HR
72
+ "IT, I need a software license key to install a program on my computer. Can you provide it?",IT
73
+ "I'm experiencing issues with my company-issued laptop. HR, can you arrange for a replacement?",HR
74
+ "The server is down, and we are unable to access our files. IT, please fix it immediately.",IT
75
+ "I have concerns about the work environment. HR, can we schedule a meeting to discuss it?",HR
76
+ "IT, the wireless network is not available in certain areas of the office. Can you investigate the issue?",IT
77
+ "I need help with updating my personal information in the HR system. HR, can you guide me through the process?",HR
78
+ "The software is not compatible with my operating system. IT, can you recommend a solution?",IT
79
+ "The HR department did not process my vacation request on time, causing inconvenience.",HR
80
+ "IT, the email attachments are not opening correctly. Please resolve this issue promptly.",IT
81
+ "There's a discrepancy in my performance evaluation. HR, can we schedule a meeting to discuss it?",HR
82
+ I'm unable to access the HR portal to update my personal information. Can someone assist me with this?,HR
83
+ The IT helpdesk has not responded to my support ticket for three days. Please prioritize it.,IT
84
+ "I have concerns about the onboarding process. HR, can we improve the orientation program?",HR
85
+ "IT, the software license on my computer has expired. Can you renew it?",IT
86
+ "I'm facing difficulties with the time tracking system. HR, can you provide guidance on how to use it?",HR
87
+ "The Wi-Fi network in our office is not secure. IT, please ensure that appropriate measures are taken.",IT
88
+ I'm experiencing issues with the HR benefits enrollment process. Can someone assist me with this?,HR
89
+ "IT, I need assistance in setting up a virtual private network (VPN) for secure remote access.",IT
90
+ "There's a conflict within our team. HR, can you mediate and help resolve the issue?",HR
91
+ "I'm receiving spam emails repeatedly. IT, please enhance the email filtering system.",IT
92
+ The HR department has not provided me with the required training materials. Can this be addressed?,HR
93
+ "IT, I accidentally deleted an important file from the shared drive. Can you recover it?",IT
94
+ "I have concerns about the employee recognition program. HR, can we implement improvements?",HR
95
+ "The IT system crashed during an important presentation, causing embarrassment. Please fix this issue.",IT
96
+ I'm experiencing difficulties with the HR self-service portal. Can someone provide technical support?,HR
97
+ "IT, the video conferencing software is not compatible with my device. Please suggest an alternative.",IT
98
+ "There's an error in my salary calculation. HR, can you review it and rectify the mistake?",HR
99
+ "I'm unable to print documents from my computer. IT, can you investigate and resolve the issue?",IT
100
+ The HR department needs to streamline the employee appraisal process. Can improvements be made?,HR
101
+ "IT, my computer is running slow, affecting my productivity. Can you optimize its performance?",IT
102
+ "I have concerns about the diversity and inclusion initiatives. HR, can we discuss this further?",HR
103
+ The IT team needs to provide more comprehensive cybersecurity training to employees.,IT
104
+ I'm experiencing delays in receiving responses from the HR department. Can this be addressed?,HR
105
+ "IT, the website is not loading properly. Please investigate and fix the issue.",IT
106
+ "There's a lack of communication regarding policy updates. HR, can we improve internal notifications?",HR
107
+ "I need assistance with data recovery from a damaged hard drive. IT, can you help me retrieve the files?",IT
108
+ The HR department needs to address the employee morale issue. Can we conduct a survey?,HR
109
+ The IT department has not resolved my software installation issue despite multiple requests.,IT
110
+ "HR, there is a discrepancy in my employee benefits coverage. Can you please investigate and rectify it?",HR
111
+ "I'm experiencing network connectivity problems in the conference room. IT, can you check and fix it?",IT
112
+ "There's a conflict between me and my supervisor. HR, I need assistance in resolving this matter.",HR
113
+ "IT, the server is experiencing frequent outages, disrupting our work. Please address the issue urgently.",IT
114
+ "I have concerns about the transparency of the promotion process. HR, can we discuss this and provide clarity?",HR
115
+ "IT, my computer is infected with a virus. Please perform a thorough scan and remove any malware.",IT
116
+ "I'm having difficulties accessing my training materials on the learning management system. HR, can you help?",HR
117
+ The IT helpdesk provided incorrect instructions for resolving my technical issue. Can someone correct it?,IT
118
+ "I believe my performance review was biased and unfair. HR, can you conduct a thorough investigation?",HR
119
+ "IT, I need assistance in recovering a deleted email from my inbox. Is it possible to retrieve it?",IT
120
+ "There's a lack of communication regarding company policies. HR, can we improve the dissemination process?",HR
121
+ "I'm experiencing frequent system crashes while using a specific software. IT, can you investigate and fix it?",IT
122
+ The HR department has not responded to my leave application. Can you please expedite the approval process?,HR
123
+ "IT, I accidentally formatted my external hard drive. Is there any way to recover the lost data?",IT
124
+ "I have concerns about the effectiveness of our performance appraisal system. HR, can we explore improvements?",HR
125
+ "The IT network in our office is not secure, leaving us vulnerable to cyber threats. Please address the issue.",IT
126
+ I'm facing difficulties accessing the HR policy manual. Can you provide an updated version or alternative access?,HR
127
+ "IT, the software update has caused compatibility issues with other applications. Can you find a solution?",IT
128
+ "There's an error in my timesheet records. HR, can you rectify it to ensure accurate payroll processing?",HR
129
+ "I'm unable to connect to the VPN for remote access. IT, can you troubleshoot and help me establish a connection?",IT
130
+ The HR department needs to enhance communication channels for employee feedback. Can improvements be made?,HR
131
+ "IT, the conference room audio system is malfunctioning, affecting our meetings. Please fix it as soon as possible.",IT
132
+ "I have concerns about the accuracy of my expense reimbursements. HR, can we review and reconcile the records?",HR
133
+ The IT team needs to improve response time for resolving technical issues. Urgent matters are being delayed.,IT
134
+ "I'm experiencing delays in receiving my performance bonus. HR, can you check the status and provide an update?",HR
135
+ "IT, the software license on my computer is about to expire. Can you renew it before it causes any disruptions?",IT
136
+ "There's a lack of diversity in the company's hiring process. HR, can we implement more inclusive practices?",HR
137
+ "I need assistance with data backup and recovery procedures. IT, can you provide guidance on best practices?",IT
138
+ The HR department needs to address concerns related to work-life balance. Can we implement flexible policies?,HR
139
+ "IT, the software application is crashing whenever I try to export data. Can you investigate and fix the issue?",IT
140
+ "I have concerns about the transparency of the salary structure. HR, can we discuss and provide more clarity?",HR
141
+ "The network printer in our department is constantly offline. IT, please resolve this issue as it hampers productivity.",IT
142
+ I'm facing difficulties accessing my performance metrics on the HR portal. Can you provide assistance?,HR
143
+ "IT, there's a persistent issue with the video conferencing system. It frequently disconnects during meetings.",IT
144
+ "I've been subjected to workplace bullying by a colleague. HR, I need your immediate intervention to address this.",HR
145
+ "The software license on my computer has expired. IT, can you provide a renewed license key?",IT
146
+ I'm experiencing challenges with the HR onboarding process. Can you streamline and improve it?,HR
147
+ "IT, my computer is infected with malware. Can you perform a thorough scan and remove the malicious files?",IT
148
+ "I have concerns about the accuracy of my attendance records. HR, can we review and rectify any discrepancies?",HR
149
+ The IT helpdesk is not responsive to my technical support requests. It's causing delays in my work.,IT
150
+ "HR, I need clarification regarding the company's bereavement leave policy. Can you provide detailed information?",HR
151
+ "The software is not compatible with my operating system. IT, can you recommend an alternative solution?",IT
152
+ "I'm facing difficulties accessing my employee benefits portal. HR, can you provide guidance on resolving this?",HR
153
+ "IT, there's a problem with the server configuration, leading to intermittent downtime. Please address it urgently.",IT
154
+ "I believe there's an error in my performance appraisal rating. HR, can you review and amend it accordingly?",HR
155
+ "The IT network in our office is not reliable. It frequently disconnects, disrupting our work.",IT
156
+ "I'm unable to access the HR policy manual. HR, can you provide an updated copy or alternative access?",HR
157
+ "IT, my laptop is overheating, which is affecting its performance. Can you provide a solution to prevent this?",IT
158
+ The HR department needs to improve communication regarding employee development opportunities.,HR
159
+ I'm experiencing delays in receiving responses to my HR inquiries. Can this be addressed promptly?,HR
160
+ "IT, the software update has caused a loss of data on my computer. Is there any way to recover the lost files?",IT
161
+ "There's a lack of clarity in the company's remote work policy. HR, can we discuss and provide clear guidelines?",HR
162
+ "I'm unable to access my email account. IT, can you assist in resolving this issue?",IT
163
+ The HR department needs to address concerns related to employee recognition and rewards programs.,HR
164
+ "IT, the server response time is significantly slow, affecting our productivity. Please optimize its performance.",IT
165
+ "I have concerns about the fairness of the promotion process. HR, can we ensure equal opportunities for all employees?",HR
166
+ "The software interface is not user-friendly. IT, can you provide training or alternative software options?",IT
167
+ I'm experiencing challenges with the HR grievance handling process. Can you provide guidance and support?,HR
168
+ "IT, there's an issue with the backup system. It's not capturing the latest data. Please investigate and fix it.",IT
169
+ The HR department needs to improve communication regarding policy updates and changes.,HR
170
+ I'm facing difficulties with the IT asset management system. Can you provide assistance in tracking and managing assets?,IT
171
+ "IT, the website is not loading properly in certain browsers. Can you investigate and resolve the compatibility issue?",IT
172
+ "There's a lack of diversity in the company's leadership positions. HR, can we implement strategies for promoting diversity?",HR
173
+ "I'm experiencing difficulties with the remote access VPN. IT, can you troubleshoot and help me establish a secure connection?",IT
174
+ The HR department needs to address concerns related to employee morale and job satisfaction.,HR
175
+ "IT, the software is not saving my preferences and settings. Can you investigate and fix the issue?",IT
176
+ "I have concerns about the accuracy of my expense reimbursements. HR, can we review and rectify any discrepancies?",HR
177
+ The IT network in our office is not secure. Can you implement additional security measures to protect sensitive data?,IT
Documents/Tranportation Policy Manual.docx ADDED
Binary file (16.5 kB). View file
 
Documents/Tranportation Policy Manual.pdf ADDED
Binary file (108 kB). View file
 
__pycache__/admin_utils.cpython-311.pyc ADDED
Binary file (2.11 kB). View file
 
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import utils.user_utils as uu
3
+
4
+ if 'HR_tickets' not in st.session_state:
5
+ st.session_state['HR_tickets'] =[]
6
+ if 'IT_tickets' not in st.session_state:
7
+ st.session_state['IT_tickets'] =[]
8
+ if 'Transport_tickets' not in st.session_state:
9
+ st.session_state['Transport_tickets'] =[]
10
+ if 'PINECONE_API_KEY' not in st.session_state:
11
+ st.session_state['PINECONE_API_KEY'] = ''
12
+
13
+ def main():
14
+ st.header("Automatic Ticket Classification Tool")
15
+ st.write("We are here to help you. Please ask a question")
16
+ user_input = st.text_input("🔎")
17
+
18
+ st.sidebar.title("😎🗝️")
19
+ st.session_state['PINECONE_API_KEY' ]= st.sidebar.text_input("What's your Pinecone API key?",type="password")
20
+
21
+ if user_input:
22
+ embedder = uu.initiate_embedder()
23
+
24
+ index = uu.pull_from_pinecone(st.session_state['PINECONE_API_KEY'], 'tickets', embedder)
25
+
26
+ similar_docs = uu.get_similar_docs(index, user_input)
27
+
28
+ response = uu.get_answer(similar_docs, user_input)
29
+ st.write(response)
30
+
31
+ button = st.button("Submit Ticket?")
32
+
33
+ if button:
34
+ embedded_query = embedder.embed_query(user_input)
35
+ department = uu.predict(embedded_query)
36
+ st.write("your ticket has been sumbitted to : " + department)
37
+
38
+ if department == 'HR':
39
+ st.session_state['HR_tickets'].append(user_input)
40
+ elif department == 'IT':
41
+ st.session_state['IT_tickets'].append(user_input)
42
+ else:
43
+ st.session_state['Transport_tickets'].append(user_input)
44
+
45
+
46
+ if __name__ == '__main__':
47
+ main()
modelsvm.pk1 ADDED
Binary file (381 kB). View file
 
pages/Pending_tickets.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.title("Department")
4
+
5
+ tab_titles = ['HR Support', 'IT Support', 'Transportation Support']
6
+ tabs = st.tabs(tab_titles)
7
+
8
+ # Add content to each tab...
9
+ with tabs[0]:
10
+ st.header('HR Support tickets')
11
+ for ticket in st.session_state['HR_tickets']:
12
+ st.write(str(st.session_state['HR_tickets'].index(ticket)+1)+" : "+ticket)
13
+
14
+
15
+ with tabs[1]:
16
+ st.header('IT Support tickets')
17
+ for ticket in st.session_state['IT_tickets']:
18
+ st.write(str(st.session_state['IT_tickets'].index(ticket)+1)+" : "+ticket)
19
+
20
+ with tabs[2]:
21
+ st.header('Transportation Support tickets')
22
+ for ticket in st.session_state['Transport_tickets']:
23
+ st.write(str(st.session_state['Transport_tickets'].index(ticket)+1)+" : "+ticket)
24
+
25
+
pages/create_ML_model.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from sklearn.svm import SVC
3
+ from sklearn.pipeline import make_pipeline
4
+ from sklearn.preprocessing import StandardScaler
5
+ import joblib
6
+
7
+ import utils.admin_utils as au
8
+
9
+ if 'cleaned_data' not in st.session_state:
10
+ st.session_state['cleaned_data'] =''
11
+ if 'sentences_train' not in st.session_state:
12
+ st.session_state['sentences_train'] =''
13
+ if 'sentences_test' not in st.session_state:
14
+ st.session_state['sentences_test'] =''
15
+ if 'labels_train' not in st.session_state:
16
+ st.session_state['labels_train'] =''
17
+ if 'labels_test' not in st.session_state:
18
+ st.session_state['labels_test'] =''
19
+ if 'svm_classifier' not in st.session_state:
20
+ st.session_state['svm_classifier'] =''
21
+
22
+
23
+ st.title("Let's build our Model...")
24
+
25
+ # Create tabs
26
+ tab_titles = ['Data Preprocessing', 'Model Training', 'Model Evaluation',"Save Model"]
27
+ tabs = st.tabs(tab_titles)
28
+
29
+ with tabs[0]:
30
+ st.header('Data Preprocessing')
31
+ st.write('Here we preprocess the data...')
32
+
33
+ data = st.file_uploader("Upload CSV file", type='csv')
34
+ button = st.button("Load data", key='data')
35
+
36
+ if button:
37
+ with st.spinner("uploading data..."):
38
+ df = au.read_data(data)
39
+ embedder = au.initiate_embedder()
40
+ st.session_state['cleaned_data'] = au.create_embedding(df, embedder)
41
+ st.success("Finished uploading and embedding csv")
42
+
43
+ with tabs[1]:
44
+ st.header("Model Training")
45
+ st.write("Here we train the model...")
46
+ button = st.button("Train Model", key='model')
47
+ if button:
48
+ with st.spinner("Training model..."):
49
+ st.session_state['sentences_train'], st.session_state['sentences_test'], st.session_state['labels_train'], st.session_state['labels_test'] = au.split_train_test_data(st.session_state['cleaned_data'])
50
+ st.session_state['svm_classifier'] = make_pipeline(StandardScaler(), SVC(class_weight='balanced'))
51
+ st.session_state['svm_classifier'].fit(st.session_state['sentences_train'], st.session_state['labels_train'])
52
+ st.success('Finished Training model!')
53
+
54
+ with tabs[2]:
55
+ st.header('Model Evaluation')
56
+ st.write('Here we evaluate the model...')
57
+ button = st.button("Evaluate model",key="Evaluation")
58
+
59
+ if button:
60
+ with st.spinner("Evaluating model..."):
61
+ acc_score = au.get_score(st.session_state['svm_classifier'], st.session_state['sentences_test'], st.session_state['labels_test'])
62
+ st.success(f"Validation accuracy: {100 * acc_score}%")
63
+ st.write("A sample run:")
64
+ text = "Rude driver with scary driving"
65
+ st.write("*** Our Issue ***: " + text)
66
+
67
+ embedder = au.initiate_embedder()
68
+ query_result = embedder.embed_query(text)
69
+
70
+ result = st.session_state['svm_classifier'].predict([query_result])
71
+ st.write("*** Department it belongs to ***: " + result[0])
72
+
73
+ st.success("Finished")
74
+
75
+ with tabs[3]:
76
+ st.header('Save model')
77
+ st.write('Here we save the model...')
78
+
79
+ button = st.button("Save model",key="save")
80
+ if button:
81
+ with st.spinner('Saving model...'):
82
+ joblib.dump(st.session_state['svm_classifier'], 'modelsvm.pk1')
83
+ st.success('Done!')
pages/load_data_store.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import utils.admin_utils as au
3
+
4
+ def main():
5
+
6
+ if 'PINECONE_API_KEY' not in st.session_state:
7
+ st.session_state['PINECONE_API_KEY'] = ''
8
+
9
+ st.set_page_config("Dump PDF to Pinecone - Vector Store")
10
+ st.title("Please upload your files...📁")
11
+
12
+ st.sidebar.title("😎🗝️")
13
+ st.session_state['PINECONE_API_KEY' ]= st.sidebar.text_input("What's your Pinecone API key?",type="password")
14
+
15
+ pdf = st.file_uploader("Only PDF files allowed...", type=['pdf'])
16
+
17
+ if pdf and st.session_state['PINECONE_API_KEY']:
18
+ with st.spinner("Wait...."):
19
+
20
+ text = au.read_pdf(pdf)
21
+ st.write("👉Reading PDF done")
22
+ chunks = au.split_data(text)
23
+ st.write("👉Splitting data into chunks done")
24
+ embedder = au.initiate_embedder()
25
+ st.write("👉Creating embeddings instance done")
26
+
27
+ au.push_to_pinecone(st.session_state['PINECONE_API_KEY'], 'tickets', embedder, chunks)
28
+ st.success("Successfully pushed the embeddings to Pinecone")
29
+ else:
30
+ if not st.session_state['PINECONE_API_KEY']:
31
+ st.error("Please provide pinecone API key")
32
+ else:
33
+ st.error("Please provide a PDF file")
34
+
35
+
36
+
37
+ if __name__ == '__main__':
38
+ main()
requirements.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ langchain==0.1.4
2
+ streamlit==1.29.0
3
+ openai==1.10.0
4
+ tiktoken==0.5.2
5
+ python-dotenv==1.0.1
6
+ pinecone-client==3.0.1
7
+ pypdf==4.0.1
8
+ joblib==1.3.2
9
+ pandas==2.2.0
10
+ scikit-learn==1.4.0
11
+ sentence-transformers==2.3.0
12
+ langchain-openai==0.0.5
utils/__pycache__/admin_utils.cpython-311.pyc ADDED
Binary file (3.55 kB). View file
 
utils/__pycache__/constants.cpython-311.pyc ADDED
Binary file (209 Bytes). View file
 
utils/__pycache__/user_utils.cpython-311.pyc ADDED
Binary file (2.43 kB). View file
 
utils/admin_utils.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pypdf import PdfReader
2
+ from langchain.text_splitter import RecursiveCharacterTextSplitter
3
+ from langchain_openai import OpenAIEmbeddings
4
+ from langchain.embeddings.sentence_transformer import SentenceTransformerEmbeddings
5
+ from langchain_openai import OpenAI
6
+ from pinecone import Pinecone
7
+ from langchain_pinecone import PineconeVectorStore
8
+ import pandas as pd
9
+ from sklearn.model_selection import train_test_split
10
+
11
+ ##################### FUNCTIONS FOR UPLOADING DOCUMENT TO PINECONE #####################
12
+
13
+ def read_pdf(pdf):
14
+ pdf_pages = PdfReader(pdf)
15
+ text = ''
16
+ for page in pdf_pages.pages:
17
+ text += page.extract_text()
18
+ return text
19
+
20
+ def split_data(text):
21
+ text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=50)
22
+ docs = text_splitter.split_text(text)
23
+ docs_chunks = text_splitter.create_documents(docs)
24
+ return docs_chunks
25
+
26
+ def initiate_embedder():
27
+ embedder = SentenceTransformerEmbeddings(model_name='all-MiniLM-L6-v2')
28
+ return embedder
29
+
30
+ def push_to_pinecone(pinecone_apikey,pinecone_index_name,embedder,docs):
31
+ Pinecone(api_key=pinecone_apikey)
32
+ index = PineconeVectorStore.from_documents(docs, embedder,index_name = pinecone_index_name)
33
+ return index
34
+
35
+ ##################### FUNCTIONS FOR MODEL PREPROCESSING/ TRAINING #####################
36
+
37
+ def read_data(data):
38
+ df = pd.read_csv(data, delimiter=',', header=None)
39
+ return df
40
+
41
+ def create_embedding(df, embedder):
42
+ df[2] = df[0].apply(lambda x: embedder.embed_query(x))
43
+ return df
44
+
45
+ def split_train_test_data(df_sample):
46
+ x_train, x_test, y_train, y_test = train_test_split(
47
+ list(df_sample[2]),
48
+ list(df_sample[1]),
49
+ test_size=0.25,
50
+ random_state=42
51
+ )
52
+ print(len(x_train))
53
+ return x_train, x_test, y_train, y_test
54
+
55
+ def get_score(svm_classifier, x_test, y_test):
56
+ score = svm_classifier.score(x_test, y_test)
57
+ return score
58
+
utils/constants.py ADDED
@@ -0,0 +1 @@
 
 
1
+ MODEL = 'modelsvm.pk1'
utils/user_utils.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pinecone import Pinecone
2
+ from langchain_pinecone import PineconeVectorStore
3
+ from langchain.embeddings.sentence_transformer import SentenceTransformerEmbeddings
4
+ from langchain_openai import OpenAI
5
+ from langchain.chains.question_answering import load_qa_chain
6
+ from langchain_community.callbacks import get_openai_callback
7
+ import joblib
8
+ from utils.constants import *
9
+
10
+ def initiate_embedder():
11
+ embedder = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
12
+ return embedder
13
+
14
+ def pull_from_pinecone(pinecone_apikey,pinecone_index_name,embeddings):
15
+ Pinecone(api_key=pinecone_apikey)
16
+
17
+ index = PineconeVectorStore.from_existing_index(pinecone_index_name, embeddings)
18
+ return index
19
+
20
+ def get_similar_docs(index, query, k=2):
21
+ similar_docs = index.similarity_search(query,k)
22
+ return similar_docs
23
+
24
+ def get_answer(docs, query):
25
+ chain = load_qa_chain(OpenAI(), chain_type="stuff")
26
+ with get_openai_callback() as cb:
27
+ response = chain.run(input_documents=docs, question=query)
28
+ return response
29
+
30
+ def predict(query):
31
+ model = joblib.load(MODEL)
32
+ result = model.predict([query])
33
+ return result[0]