SakibAhmed commited on
Commit
7fa58d2
·
verified ·
1 Parent(s): 2007618

Upload 36 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,27 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ faiss_storage/faiss_index/index.faiss filter=lfs diff=lfs merge=lfs -text
37
+ sources/Endodontics[[:space:]]appendix[[:space:]]4.pdf filter=lfs diff=lfs merge=lfs -text
38
+ sources/Endodontics[[:space:]]cap[[:space:]]1.pdf filter=lfs diff=lfs merge=lfs -text
39
+ sources/Endodontics[[:space:]]cap[[:space:]]10.pdf filter=lfs diff=lfs merge=lfs -text
40
+ sources/Endodontics[[:space:]]cap[[:space:]]11.pdf filter=lfs diff=lfs merge=lfs -text
41
+ sources/Endodontics[[:space:]]cap[[:space:]]12.pdf filter=lfs diff=lfs merge=lfs -text
42
+ sources/Endodontics[[:space:]]cap[[:space:]]13.pdf filter=lfs diff=lfs merge=lfs -text
43
+ sources/Endodontics[[:space:]]cap[[:space:]]14.pdf filter=lfs diff=lfs merge=lfs -text
44
+ sources/Endodontics[[:space:]]cap[[:space:]]15.pdf filter=lfs diff=lfs merge=lfs -text
45
+ sources/Endodontics[[:space:]]cap[[:space:]]16.pdf filter=lfs diff=lfs merge=lfs -text
46
+ sources/Endodontics[[:space:]]cap[[:space:]]17.pdf filter=lfs diff=lfs merge=lfs -text
47
+ sources/Endodontics[[:space:]]cap[[:space:]]18.pdf filter=lfs diff=lfs merge=lfs -text
48
+ sources/Endodontics[[:space:]]cap[[:space:]]19.pdf filter=lfs diff=lfs merge=lfs -text
49
+ sources/Endodontics[[:space:]]cap[[:space:]]2.pdf filter=lfs diff=lfs merge=lfs -text
50
+ sources/Endodontics[[:space:]]cap[[:space:]]20.pdf filter=lfs diff=lfs merge=lfs -text
51
+ sources/Endodontics[[:space:]]cap[[:space:]]21.pdf filter=lfs diff=lfs merge=lfs -text
52
+ sources/Endodontics[[:space:]]cap[[:space:]]22.pdf filter=lfs diff=lfs merge=lfs -text
53
+ sources/Endodontics[[:space:]]cap[[:space:]]3.pdf filter=lfs diff=lfs merge=lfs -text
54
+ sources/Endodontics[[:space:]]cap[[:space:]]4.pdf filter=lfs diff=lfs merge=lfs -text
55
+ sources/Endodontics[[:space:]]cap[[:space:]]5.pdf filter=lfs diff=lfs merge=lfs -text
56
+ sources/Endodontics[[:space:]]cap[[:space:]]6.pdf filter=lfs diff=lfs merge=lfs -text
57
+ sources/Endodontics[[:space:]]cap[[:space:]]7.pdf filter=lfs diff=lfs merge=lfs -text
58
+ sources/Endodontics[[:space:]]cap[[:space:]]8.pdf filter=lfs diff=lfs merge=lfs -text
59
+ sources/Endodontics[[:space:]]cap[[:space:]]9.pdf filter=lfs diff=lfs merge=lfs -text
faiss_storage/faiss_index/index.faiss ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8c627f912c7eead10f1ed14a68211eaad41b98e8920deb999f79f8671dc01979
3
+ size 3640365
faiss_storage/faiss_index/index.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e7f4e06d1c5d0de27cae7d9a9328c94073faa58705ceea28242166dca11c581e
3
+ size 2569631
sources/Endodontics appendix 1.pdf ADDED
Binary file (90.7 kB). View file
 
sources/Endodontics appendix 2.pdf ADDED
Binary file (66.3 kB). View file
 
sources/Endodontics appendix 3.pdf ADDED
Binary file (92 kB). View file
 
sources/Endodontics appendix 4.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a8b972d927a7a01f466cfe30e24834e653009926891919df1078f3563b718d1b
3
+ size 188535
sources/Endodontics book.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:045c84eef3be88136f67bea03299a5e54ff121a017b8d6575d2fa7dd1269d460
3
+ size 19170850
sources/Endodontics cap 1.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2956cff53ab6755bd5769d96ea6e021d21992d66898fa7ad19d59a651db08552
3
+ size 1393891
sources/Endodontics cap 10.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d60888b81a8ba43e14a85dee20a485120c6a168e75d8cb44f51f98ea1dc86c6
3
+ size 858903
sources/Endodontics cap 11.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6cdfa6604cc9bdad78c8ffb4ec61e6ae5f12c3b75f0b52d45bab57c43983e676
3
+ size 1132015
sources/Endodontics cap 12.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b42e9dca8977115f11342fd3d264576c5b7224a51b82f3646d3a766669417f91
3
+ size 1539100
sources/Endodontics cap 13.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ed0b9c196e3afe7477709996a261580721c42c391ecab6a0183ef4261b5a86fd
3
+ size 1625649
sources/Endodontics cap 14.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:92e0c462d8eb85d94b08ba84ad2270c86e87a678dea4be0d700f910af89c64e7
3
+ size 1357984
sources/Endodontics cap 15.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:54d2a579eed28d2bb58c8aca669dc6baaad1824a156517212494b0557f4837d7
3
+ size 944072
sources/Endodontics cap 16.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ab55472e1887827d5f55e51993ebb5ab9a031fafb6e81db258b82277c7ce4e5
3
+ size 681335
sources/Endodontics cap 17.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f5c395668f607f37c3f67131bdb0f82bc792b3bdbabb03071abd623d066db27
3
+ size 528079
sources/Endodontics cap 18.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a8cb86f5fa0e481b2d91db3e93dcabe580a447630f7716d0f8309d5a018bbc64
3
+ size 746444
sources/Endodontics cap 19.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a5746dc123bc59f7373699d48e753ad05552acaa18c743dc5026990e603686b2
3
+ size 830885
sources/Endodontics cap 2.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b06e9d058a6f05afb04bfef398b8d0f36c02e4d78aba873dc294652c9fe2517c
3
+ size 612225
sources/Endodontics cap 20.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:127d6f0efcac6fc7d12cbee72f9f0cbf05136be860e5837662037d267e8c621b
3
+ size 609023
sources/Endodontics cap 21.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d3b2e5699b2a92f2bb5187e825aa5f11afc1d2ed54bce56e6ba56fab699f2a4
3
+ size 464443
sources/Endodontics cap 22.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a9dee2fd5d783cdf4f53b8e3d79ab012369e1c55ade79c4e5ee7544c83d690f
3
+ size 561329
sources/Endodontics cap 3.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a79808a3da34f9817136e441254449dc5504f115cae1190505b8ce5f3c3f9b51
3
+ size 786616
sources/Endodontics cap 4.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3223d4b6c6ae9b1b66bd5f0ac750bf8e3a514e7941555632ad98e67202929993
3
+ size 810838
sources/Endodontics cap 5.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fe63ba988c8c88207a7482c677983cd5f1a0b06cb5bc210b650a657b20924ebf
3
+ size 761083
sources/Endodontics cap 6.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1c490f38f73cd72e8bde876bb082964d43d1080abd1593ab7c4e53ca97a4f492
3
+ size 1056526
sources/Endodontics cap 7.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:23b1f2f03a024f0520a798a7e7bd2c128cc5eda3d929a6b56d9a2b9dde184d14
3
+ size 1619923
sources/Endodontics cap 8.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:159d99387578b0d9164e243ae27f7ee77ee998aa8c71dc15310e6ca274d96f7e
3
+ size 751157
sources/Endodontics cap 9.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db47bb570fa521c1e7462e07bd22f9ce38485c2b262b0c774d16ba7795844179
3
+ size 498083
sources/database.csv ADDED
@@ -0,0 +1 @@
 
 
1
+ Question,Answer,Image
sources/general_qa.csv ADDED
@@ -0,0 +1 @@
 
 
1
+ Question,Answer,Image
sources/greetings.csv ADDED
@@ -0,0 +1 @@
 
 
1
+ Question,Answer,Image
sources/personal_qa.csv ADDED
@@ -0,0 +1 @@
 
 
1
+ Question,Answer,Image
sources/preguntas chatbot_01.xlsx ADDED
Binary file (72.6 kB). View file
 
sources/~$preguntas chatbot_01.xlsx ADDED
Binary file (165 Bytes). View file
 
templates/chat-bot.html ADDED
@@ -0,0 +1,686 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en" data-theme="light">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Personal Assistant</title>
7
+ <link href="https://fonts.googleapis.com/css?family=Roboto:400,500,700" rel="stylesheet">
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ :root {
11
+ /* Light Theme (Default) */
12
+ --bg-primary: #f4f7f9;
13
+ --bg-secondary: #ffffff;
14
+ --text-primary: #2c3e50;
15
+ --text-secondary: #6c757d;
16
+ --header-bg: #2c3e50;
17
+ --bot-message-bg: #e9ecef;
18
+ --user-message-bg: #d1e7fd;
19
+ --accent-color: #3498db;
20
+ --border-color: #dee2e6;
21
+ --shadow-color: rgba(0, 0, 0, 0.05);
22
+ --success-color: #28a745;
23
+ --error-color: #dc3545;
24
+ --info-color: #17a2b8;
25
+ }
26
+
27
+ [data-theme="dark"] {
28
+ /* Dark Theme */
29
+ --bg-primary: #1a1a1a;
30
+ --bg-secondary: #2c2c2c;
31
+ --text-primary: #e0e0e0;
32
+ --text-secondary: #a0a0a0;
33
+ --header-bg: #1f1f1f;
34
+ --bot-message-bg: #3a3f44;
35
+ --user-message-bg: #004a7c;
36
+ --accent-color: #87CEEB;
37
+ --border-color: #444;
38
+ --shadow-color: rgba(0, 0, 0, 0.2);
39
+ --success-color: #20c997;
40
+ --error-color: #ff6b6b;
41
+ --info-color: #63e6be;
42
+ }
43
+
44
+ * {
45
+ box-sizing: border-box;
46
+ }
47
+
48
+ body {
49
+ background-color: var(--bg-primary);
50
+ font-family: 'Roboto', sans-serif;
51
+ margin: 0;
52
+ padding: 0;
53
+ color: var(--text-primary);
54
+ transition: background-color 0.3s, color 0.3s;
55
+ }
56
+
57
+ .chat-container {
58
+ width: 100vw;
59
+ height: 100vh;
60
+ display: flex;
61
+ flex-direction: column;
62
+ overflow: hidden;
63
+ }
64
+
65
+ .chat-header {
66
+ background: var(--header-bg);
67
+ color: #fff;
68
+ padding: 15px 20px;
69
+ display: flex;
70
+ justify-content: space-between;
71
+ align-items: center;
72
+ flex-shrink: 0;
73
+ box-shadow: 0 2px 5px var(--shadow-color);
74
+ z-index: 10;
75
+ }
76
+
77
+ .chat-header h2 {
78
+ margin: 0;
79
+ font-size: 22px;
80
+ }
81
+
82
+ .header-buttons {
83
+ display: flex;
84
+ gap: 10px;
85
+ }
86
+
87
+ .header-buttons .icon-button {
88
+ background: transparent;
89
+ border: 1px solid rgba(255, 255, 255, 0.5);
90
+ color: #fff;
91
+ width: 38px;
92
+ height: 38px;
93
+ border-radius: 50%;
94
+ cursor: pointer;
95
+ font-size: 16px;
96
+ transition: background 0.3s, transform 0.3s;
97
+ display: flex;
98
+ justify-content: center;
99
+ align-items: center;
100
+ }
101
+
102
+ .header-buttons .icon-button:hover {
103
+ background: rgba(255, 255, 255, 0.15);
104
+ transform: scale(1.1);
105
+ }
106
+
107
+ .chat-messages {
108
+ flex: 1;
109
+ padding: 20px;
110
+ overflow-y: auto;
111
+ background-color: var(--bg-secondary);
112
+ }
113
+
114
+ .message {
115
+ margin-bottom: 20px;
116
+ display: flex;
117
+ align-items: flex-start;
118
+ max-width: 85%;
119
+ }
120
+
121
+ .message.user {
122
+ justify-content: flex-end;
123
+ margin-left: auto;
124
+ }
125
+
126
+ .message.bot {
127
+ margin-right: auto;
128
+ }
129
+
130
+ .message-content {
131
+ padding: 12px 18px;
132
+ border-radius: 18px;
133
+ box-shadow: 0 2px 4px var(--shadow-color);
134
+ word-wrap: break-word;
135
+ line-height: 1.6;
136
+ }
137
+
138
+ .message.user .message-content {
139
+ background-color: var(--user-message-bg);
140
+ color: var(--text-primary);
141
+ border-bottom-right-radius: 4px;
142
+ }
143
+
144
+ .message.bot .message-content {
145
+ background-color: var(--bot-message-bg);
146
+ border-bottom-left-radius: 4px;
147
+ }
148
+
149
+ .message.bot .typing-indicator {
150
+ display: flex;
151
+ align-items: center;
152
+ gap: 5px;
153
+ padding: 5px 0;
154
+ }
155
+
156
+ .message.bot .typing-indicator span {
157
+ height: 8px;
158
+ width: 8px;
159
+ background: var(--accent-color);
160
+ border-radius: 50%;
161
+ animation: bounce 1.3s linear infinite;
162
+ }
163
+
164
+ @keyframes bounce {
165
+ 0%, 60%, 100% { transform: translateY(0); }
166
+ 30% { transform: translateY(-8px); }
167
+ }
168
+
169
+ .chat-input {
170
+ display: flex;
171
+ padding: 15px;
172
+ background: var(--bg-secondary);
173
+ border-top: 1px solid var(--border-color);
174
+ flex-shrink: 0;
175
+ }
176
+
177
+ .chat-input textarea {
178
+ flex: 1;
179
+ padding: 12px 15px;
180
+ border: 1px solid var(--border-color);
181
+ border-radius: 22px;
182
+ resize: none;
183
+ font-size: 16px;
184
+ margin-right: 10px;
185
+ background-color: var(--bg-primary);
186
+ color: var(--text-primary);
187
+ transition: border-color 0.3s;
188
+ }
189
+
190
+ .chat-input textarea:focus {
191
+ border-color: var(--accent-color);
192
+ outline: none;
193
+ }
194
+
195
+ .chat-input button {
196
+ background-color: var(--accent-color);
197
+ color: #fff;
198
+ border: none;
199
+ width: 44px;
200
+ height: 44px;
201
+ border-radius: 50%;
202
+ cursor: pointer;
203
+ transition: background-color 0.3s;
204
+ font-size: 18px;
205
+ }
206
+
207
+ /* Modal Styles */
208
+ .modal-overlay {
209
+ position: fixed;
210
+ top: 0;
211
+ left: 0;
212
+ width: 100%;
213
+ height: 100%;
214
+ background: rgba(0, 0, 0, 0.6);
215
+ display: flex;
216
+ justify-content: center;
217
+ align-items: center;
218
+ z-index: 1000;
219
+ opacity: 0;
220
+ visibility: hidden;
221
+ transition: opacity 0.3s, visibility 0.3s;
222
+ }
223
+
224
+ .modal-overlay.visible {
225
+ opacity: 1;
226
+ visibility: visible;
227
+ }
228
+
229
+ .modal-content {
230
+ background: var(--bg-secondary);
231
+ padding: 25px;
232
+ border-radius: 12px;
233
+ width: 90%;
234
+ box-shadow: 0 5px 20px rgba(0,0,0,0.2);
235
+ transform: scale(0.95);
236
+ transition: transform 0.3s;
237
+ }
238
+
239
+ .modal-overlay.visible .modal-content {
240
+ transform: scale(1);
241
+ }
242
+
243
+ .modal-content h3 {
244
+ margin-top: 0;
245
+ margin-bottom: 20px;
246
+ border-bottom: 1px solid var(--border-color);
247
+ padding-bottom: 10px;
248
+ color: var(--accent-color);
249
+ }
250
+
251
+ .modal-close-button {
252
+ position: absolute;
253
+ top: 15px;
254
+ right: 15px;
255
+ background: none;
256
+ border: none;
257
+ font-size: 24px;
258
+ color: var(--text-secondary);
259
+ cursor: pointer;
260
+ }
261
+
262
+ /* Admin Panel */
263
+ .admin-panel {
264
+ max-width: 700px;
265
+ max-height: 90vh;
266
+ overflow-y: auto;
267
+ }
268
+
269
+ .admin-section {
270
+ margin-bottom: 25px;
271
+ }
272
+
273
+ .admin-buttons-grid {
274
+ display: grid;
275
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
276
+ gap: 15px;
277
+ }
278
+
279
+ .admin-button {
280
+ background-color: var(--bg-primary);
281
+ border: 1px solid var(--border-color);
282
+ color: var(--text-primary);
283
+ padding: 12px;
284
+ border-radius: 8px;
285
+ cursor: pointer;
286
+ font-size: 15px;
287
+ font-weight: 500;
288
+ text-align: left;
289
+ display: flex;
290
+ align-items: center;
291
+ gap: 10px;
292
+ transition: background-color 0.3s, color 0.3s, transform 0.2s;
293
+ }
294
+
295
+ .admin-button:hover {
296
+ background-color: var(--accent-color);
297
+ color: #fff;
298
+ border-color: var(--accent-color);
299
+ transform: translateY(-2px);
300
+ }
301
+
302
+ .admin-button .fa-fw {
303
+ font-size: 18px;
304
+ }
305
+
306
+ .status-display {
307
+ background: var(--bg-primary);
308
+ padding: 15px;
309
+ border-radius: 8px;
310
+ font-family: monospace;
311
+ font-size: 13px;
312
+ white-space: pre-wrap;
313
+ word-wrap: break-word;
314
+ border: 1px solid var(--border-color);
315
+ }
316
+
317
+ /* Credentials Modal */
318
+ #credentials-modal .modal-content {
319
+ max-width: 400px;
320
+ }
321
+ .form-group {
322
+ margin-bottom: 15px;
323
+ }
324
+ .form-group label {
325
+ display: block;
326
+ margin-bottom: 5px;
327
+ font-weight: 500;
328
+ }
329
+ .form-group input {
330
+ width: 100%;
331
+ padding: 10px;
332
+ border: 1px solid var(--border-color);
333
+ border-radius: 6px;
334
+ background: var(--bg-primary);
335
+ color: var(--text-primary);
336
+ }
337
+ .modal-actions {
338
+ display: flex;
339
+ justify-content: flex-end;
340
+ gap: 10px;
341
+ margin-top: 20px;
342
+ }
343
+ .modal-button {
344
+ padding: 10px 20px;
345
+ border-radius: 6px;
346
+ border: none;
347
+ cursor: pointer;
348
+ }
349
+ .modal-button.primary {
350
+ background: var(--accent-color);
351
+ color: #fff;
352
+ }
353
+ .modal-button.secondary {
354
+ background: var(--border-color);
355
+ color: var(--text-primary);
356
+ }
357
+ </style>
358
+ </head>
359
+ <body>
360
+
361
+ <div class="chat-container">
362
+ <div class="chat-header">
363
+ <h2>Personal Assistant</h2>
364
+ <div class="header-buttons">
365
+ <button id="admin-panel-button" class="icon-button" title="Admin Panel"><i class="fas fa-shield-halved"></i></button>
366
+ <button id="theme-toggle" class="icon-button" title="Toggle Theme"><i class="fas fa-moon"></i></button>
367
+ </div>
368
+ </div>
369
+
370
+ <div class="chat-messages" id="chat-messages"></div>
371
+
372
+ <div class="chat-input">
373
+ <textarea id="user-input" placeholder="Type your message here..." rows="1" disabled></textarea>
374
+ <button id="send-button" disabled><i class="fas fa-paper-plane"></i></button>
375
+ </div>
376
+ </div>
377
+
378
+ <div class="modal-overlay" id="admin-modal-overlay">
379
+ <div class="modal-content admin-panel">
380
+ <button class="modal-close-button" id="modal-close-btn">&times;</button>
381
+ <h3><i class="fas fa-cogs"></i> System Control Panel</h3>
382
+ <div class="admin-section">
383
+ <h4><i class="fas fa-bolt"></i> Actions</h4>
384
+ <div class="admin-buttons-grid">
385
+ <button class="admin-button" id="rebuild-index-button"><i class="fas fa-fw fa-sync-alt"></i> Rebuild Document Index</button>
386
+ <button class="admin-button" id="download-db-button"><i class="fas fa-fw fa-database"></i> Download QA Database</button>
387
+ <button class="admin-button" id="download-log-button"><i class="fas fa-fw fa-file-csv"></i> Download Chat Log</button>
388
+ <button class="admin-button" id="clear-history-button"><i class="fas fa-fw fa-trash"></i> Clear Current Chat</button>
389
+ <button class="admin-button" id="change-credentials-button"><i class="fas fa-fw fa-key"></i> Change Credentials</button>
390
+ </div>
391
+ </div>
392
+ <div class="admin-section">
393
+ <h4><i class="fas fa-chart-line"></i> System Status <button id="refresh-status-button" style="margin-left: 10px; font-size: 12px; padding: 4px 8px; cursor: pointer;">Refresh</button></h4>
394
+ <div id="status-container">
395
+ <div class="status-display" id="rag-status-display">Enter credentials to view status...</div>
396
+ </div>
397
+ </div>
398
+ </div>
399
+ </div>
400
+
401
+ <div class="modal-overlay" id="credentials-modal">
402
+ <div class="modal-content">
403
+ <h3 id="credentials-title">Authentication Required</h3>
404
+ <div class="form-group">
405
+ <label for="username-input">Username</label>
406
+ <input type="text" id="username-input" autocomplete="username">
407
+ </div>
408
+ <div class="form-group">
409
+ <label for="password-input">Password</label>
410
+ <input type="password" id="password-input" autocomplete="current-password">
411
+ </div>
412
+ <div class="modal-actions">
413
+ <button id="credentials-cancel-btn" class="modal-button secondary">Cancel</button>
414
+ <button id="credentials-submit-btn" class="modal-button primary">Submit</button>
415
+ </div>
416
+ </div>
417
+ </div>
418
+
419
+ <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
420
+ <script src="https://unpkg.com/autosize@4.0.2/dist/autosize.min.js"></script>
421
+ <script>
422
+ document.addEventListener('DOMContentLoaded', () => {
423
+ // --- STATE MANAGEMENT ---
424
+ let sessionId = null;
425
+ let sessionAuth = {
426
+ admin: null, // { username, password }
427
+ report: null // { username, password }
428
+ };
429
+
430
+ // --- ELEMENT SELECTORS ---
431
+ const ui = {
432
+ sendButton: document.getElementById('send-button'),
433
+ userInput: document.getElementById('user-input'),
434
+ chatMessages: document.getElementById('chat-messages'),
435
+ themeToggle: document.getElementById('theme-toggle'),
436
+ adminPanelButton: document.getElementById('admin-panel-button'),
437
+ adminModal: {
438
+ overlay: document.getElementById('admin-modal-overlay'),
439
+ closeBtn: document.getElementById('modal-close-btn'),
440
+ rebuildIndexBtn: document.getElementById('rebuild-index-button'),
441
+ clearHistoryBtn: document.getElementById('clear-history-button'),
442
+ downloadDbBtn: document.getElementById('download-db-button'),
443
+ downloadLogBtn: document.getElementById('download-log-button'),
444
+ refreshStatusBtn: document.getElementById('refresh-status-button'),
445
+ changeCredsBtn: document.getElementById('change-credentials-button'),
446
+ statusDisplay: document.getElementById('rag-status-display')
447
+ },
448
+ credsModal: {
449
+ overlay: document.getElementById('credentials-modal'),
450
+ title: document.getElementById('credentials-title'),
451
+ usernameInput: document.getElementById('username-input'),
452
+ passwordInput: document.getElementById('password-input'),
453
+ cancelBtn: document.getElementById('credentials-cancel-btn'),
454
+ submitBtn: document.getElementById('credentials-submit-btn')
455
+ }
456
+ };
457
+
458
+ autosize(ui.userInput);
459
+
460
+ // --- THEME MANAGEMENT ---
461
+ const applyTheme = (theme) => {
462
+ document.documentElement.setAttribute('data-theme', theme);
463
+ localStorage.setItem('chatTheme', theme);
464
+ ui.themeToggle.innerHTML = `<i class="fas ${theme === 'dark' ? 'fa-sun' : 'fa-moon'}"></i>`;
465
+ };
466
+ const toggleTheme = () => applyTheme(document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark');
467
+
468
+ // --- MODAL MANAGEMENT ---
469
+ const toggleModal = (modalOverlay, show) => modalOverlay.classList.toggle('visible', show);
470
+
471
+ // --- CHAT MESSAGING ---
472
+ const initializeChat = async () => {
473
+ applyTheme(localStorage.getItem('chatTheme') || 'light');
474
+ try {
475
+ const response = await axios.post('/create-session');
476
+ sessionId = response.data.session_id;
477
+ ui.userInput.disabled = false;
478
+ ui.sendButton.disabled = false;
479
+ appendMessage({sender: 'bot', text: 'Hello! I am your personal assistant. How can I help you today?'});
480
+ } catch (error) {
481
+ console.error('Error creating session:', error);
482
+ appendMessage({sender: 'bot', text: 'Failed to initialize chat session. Please refresh the page.'});
483
+ }
484
+ };
485
+
486
+ const appendMessage = ({ sender, text, isHtml = false }) => {
487
+ const typingIndicator = ui.chatMessages.querySelector('.typing-indicator-wrapper');
488
+ if (typingIndicator) typingIndicator.remove();
489
+
490
+ const messageElement = document.createElement('div');
491
+ messageElement.className = `message ${sender}`;
492
+ messageElement.innerHTML = `<div class="message-content">${isHtml ? text : `<p>${text.replace(/</g, "&lt;").replace(/>/g, "&gt;")}</p>`}</div>`;
493
+ ui.chatMessages.appendChild(messageElement);
494
+ ui.chatMessages.scrollTop = ui.chatMessages.scrollHeight;
495
+ };
496
+
497
+ const showTypingIndicator = () => {
498
+ if (ui.chatMessages.querySelector('.typing-indicator-wrapper')) return;
499
+ const indicatorWrapper = document.createElement('div');
500
+ indicatorWrapper.className = 'message bot typing-indicator-wrapper';
501
+ indicatorWrapper.innerHTML = `
502
+ <div class="message-content">
503
+ <div class="typing-indicator">
504
+ <span></span><span style="animation-delay: 0.2s"></span><span style="animation-delay: 0.4s"></span>
505
+ </div>
506
+ </div>`;
507
+ ui.chatMessages.appendChild(indicatorWrapper);
508
+ ui.chatMessages.scrollTop = ui.chatMessages.scrollHeight;
509
+ };
510
+
511
+ const sendMessage = async () => {
512
+ if (!sessionId) return;
513
+ const message = ui.userInput.value.trim();
514
+ if (message === '') return;
515
+
516
+ appendMessage({sender: 'user', text: message});
517
+ ui.userInput.value = '';
518
+ autosize.update(ui.userInput);
519
+ showTypingIndicator();
520
+
521
+ try {
522
+ const response = await axios.post('/chat-bot', { query: message, session_id: sessionId });
523
+
524
+ const rawResponse = response.data?.answer || 'Sorry, I could not process that.';
525
+ const cleanResponse = rawResponse.replace(/<think>[\s\S]*?<\/think>/, '').trim();
526
+
527
+ if (cleanResponse) {
528
+ appendMessage({sender: 'bot', text: cleanResponse});
529
+ } else {
530
+ appendMessage({sender: 'bot', text: 'Sorry, I received an empty response.'});
531
+ }
532
+
533
+ } catch (error) {
534
+ console.error('Error sending message:', error);
535
+ appendMessage({sender: 'bot', text: 'A critical error occurred. Please check the server logs.'});
536
+ }
537
+ };
538
+
539
+ // --- CREDENTIALS MANAGEMENT ---
540
+ const getCredentials = (type) => {
541
+ return new Promise((resolve, reject) => {
542
+ if (sessionAuth[type]) {
543
+ return resolve(sessionAuth[type]);
544
+ }
545
+
546
+ ui.credsModal.title.textContent = `${type.charAt(0).toUpperCase() + type.slice(1)} Authentication`;
547
+ ui.credsModal.usernameInput.value = '';
548
+ ui.credsModal.passwordInput.value = '';
549
+ toggleModal(ui.credsModal.overlay, true);
550
+ ui.credsModal.usernameInput.focus();
551
+
552
+ const handleSubmit = () => {
553
+ const username = ui.credsModal.usernameInput.value;
554
+ const password = ui.credsModal.passwordInput.value;
555
+ cleanup();
556
+ if (username && password) {
557
+ resolve({ username, password });
558
+ } else {
559
+ reject(new Error('Credentials not provided.'));
560
+ }
561
+ };
562
+
563
+ const handleCancel = () => {
564
+ cleanup();
565
+ reject(new Error('Authentication cancelled.'));
566
+ };
567
+
568
+ const cleanup = () => {
569
+ ui.credsModal.submitBtn.removeEventListener('click', handleSubmit);
570
+ ui.credsModal.cancelBtn.removeEventListener('click', handleCancel);
571
+ toggleModal(ui.credsModal.overlay, false);
572
+ };
573
+
574
+ ui.credsModal.submitBtn.addEventListener('click', handleSubmit);
575
+ ui.credsModal.cancelBtn.addEventListener('click', handleCancel);
576
+ });
577
+ };
578
+
579
+ // --- ADMIN FUNCTIONS ---
580
+ const handleApiError = (error, type) => {
581
+ if (error.response?.status === 401) {
582
+ sessionAuth[type] = null;
583
+ alert(`${type.charAt(0).toUpperCase() + type.slice(1)} authentication failed. Please try again.`);
584
+ } else {
585
+ alert(`An operation failed. Status: ${error.response?.status}. Check server logs.`);
586
+ }
587
+ };
588
+
589
+ const forceRebuildIndex = async () => {
590
+ if (!confirm('This will trigger a full re-index. This can take several minutes. Continue?')) return;
591
+ try {
592
+ const auth = await getCredentials('admin');
593
+ appendMessage({sender: 'bot', text: 'System re-index process started...'});
594
+ toggleModal(ui.adminModal.overlay, false);
595
+ const response = await axios.post('/admin/rebuild_faiss_index', {}, { auth });
596
+ sessionAuth.admin = auth;
597
+ appendMessage({sender: 'bot', text: `✅ SUCCESS: ${response.data.message}`});
598
+ } catch (error) {
599
+ if (error.message !== 'Authentication cancelled.') {
600
+ appendMessage({ sender: 'bot', text: `❌ ERROR: Re-index process failed.` });
601
+ handleApiError(error, 'admin');
602
+ } else {
603
+ console.log("Admin action cancelled by user.");
604
+ }
605
+ }
606
+ };
607
+
608
+ const downloadFile = async (url, type, defaultFilename) => {
609
+ try {
610
+ const auth = await getCredentials(type);
611
+ const response = await axios.get(url, { auth, responseType: 'blob' });
612
+ sessionAuth[type] = auth;
613
+ const blobUrl = window.URL.createObjectURL(new Blob([response.data]));
614
+ const link = document.createElement('a');
615
+ link.href = blobUrl;
616
+ const disposition = response.headers['content-disposition'];
617
+ link.download = disposition?.match(/filename="(.+)"/)?.[1] || defaultFilename;
618
+ document.body.appendChild(link);
619
+ link.click();
620
+ link.remove();
621
+ window.URL.revokeObjectURL(blobUrl);
622
+ } catch (error) {
623
+ if (error.message !== 'Authentication cancelled.') handleApiError(error, type);
624
+ }
625
+ };
626
+
627
+ const clearHistory = async () => {
628
+ if (!confirm('Clear the current chat on screen and on the server? This cannot be undone.')) return;
629
+ try {
630
+ await axios.post('/clear-history', { session_id: sessionId });
631
+ ui.chatMessages.innerHTML = '';
632
+ appendMessage({sender: 'bot', text: 'Chat history for this session has been cleared.'});
633
+ toggleModal(ui.adminModal.overlay, false);
634
+ } catch (error) {
635
+ alert('Failed to clear history on the server.');
636
+ }
637
+ };
638
+
639
+ const refreshAdminStatus = async () => {
640
+ ui.adminModal.statusDisplay.textContent = 'Authenticating and fetching status...';
641
+ try {
642
+ const auth = await getCredentials('admin');
643
+ const [ragStatusRes, dbStatusRes] = await Promise.all([
644
+ axios.get('/admin/faiss_rag_status', { auth }),
645
+ axios.get('/db/status', { auth })
646
+ ]);
647
+ sessionAuth.admin = auth;
648
+ let statusText = `--- RAG System ---\n${JSON.stringify(ragStatusRes.data, null, 2)}`;
649
+ statusText += `\n\n--- Personal DB Monitor ---\n${JSON.stringify(dbStatusRes.data, null, 2)}`;
650
+ ui.adminModal.statusDisplay.textContent = statusText;
651
+ } catch (error) {
652
+ if (error.message !== 'Authentication cancelled.') {
653
+ handleApiError(error, 'admin');
654
+ ui.adminModal.statusDisplay.textContent = 'Failed to fetch status. Please try again.';
655
+ } else {
656
+ ui.adminModal.statusDisplay.textContent = 'Authentication cancelled. Please provide credentials to see status.';
657
+ }
658
+ }
659
+ };
660
+
661
+ // --- EVENT LISTENERS ---
662
+ ui.sendButton.addEventListener('click', sendMessage);
663
+ ui.userInput.addEventListener('keypress', (e) => e.key === 'Enter' && !e.shiftKey && (e.preventDefault(), sendMessage()));
664
+ ui.themeToggle.addEventListener('click', toggleTheme);
665
+ ui.adminPanelButton.addEventListener('click', () => toggleModal(ui.adminModal.overlay, true));
666
+ ui.adminModal.closeBtn.addEventListener('click', () => toggleModal(ui.adminModal.overlay, false));
667
+ ui.adminModal.overlay.addEventListener('click', (e) => e.target === ui.adminModal.overlay && toggleModal(ui.adminModal.overlay, false));
668
+
669
+ ui.adminModal.rebuildIndexBtn.addEventListener('click', forceRebuildIndex);
670
+ ui.adminModal.downloadDbBtn.addEventListener('click', () => downloadFile('/admin/download_qa_database', 'admin', 'qa_database.xlsx'));
671
+ ui.adminModal.downloadLogBtn.addEventListener('click', () => downloadFile('/report', 'report', 'chat_history.csv'));
672
+ ui.adminModal.clearHistoryBtn.addEventListener('click', clearHistory);
673
+ ui.adminModal.refreshStatusBtn.addEventListener('click', refreshAdminStatus);
674
+ ui.adminModal.changeCredsBtn.addEventListener('click', () => {
675
+ sessionAuth.admin = null;
676
+ sessionAuth.report = null;
677
+ alert('Stored credentials have been cleared.');
678
+ ui.adminModal.statusDisplay.textContent = 'Credentials cleared. Refresh status to re-enter.';
679
+ });
680
+
681
+ // --- STARTUP ---
682
+ initializeChat();
683
+ });
684
+ </script>
685
+ </body>
686
+ </html>