AdityaTheDev commited on
Commit
5c14988
·
verified ·
1 Parent(s): 2a9fff3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +180 -10
app.py CHANGED
@@ -160,6 +160,131 @@
160
  # </p>
161
  # """, unsafe_allow_html=True)
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  import os
164
  import faiss
165
  import streamlit as st
@@ -183,11 +308,11 @@ st.markdown(
183
  <style>
184
  .main {
185
  background: linear-gradient(135deg, #FFDEE9 0%, #B5FFFC 100%);
186
- color: #ffffff;
187
  font-family: 'Arial', sans-serif;
188
  }
189
  .stButton>button {
190
- background-color: #1f77b4;
191
  color: white;
192
  border-radius: 12px;
193
  padding: 8px 12px;
@@ -197,7 +322,7 @@ st.markdown(
197
  transition: background-color 0.3s;
198
  }
199
  .stButton>button:hover {
200
- background-color: #105a87;
201
  }
202
  .custom-input {
203
  font-size: 18px;
@@ -210,26 +335,62 @@ st.markdown(
210
  .memory-box {
211
  padding: 12px;
212
  margin: 10px 0;
213
- border: 1px solid #ccc;
214
- border-radius: 8px;
215
- background-color: #d9fcea;
216
- box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
 
 
217
  height: 150px;
218
  display: flex;
219
  align-items: center;
220
  justify-content: center;
221
  text-align: center;
222
  overflow: hidden;
 
 
 
 
 
 
 
 
223
  }
224
  </style>
225
  """,
226
  unsafe_allow_html=True
227
  )
228
 
 
 
 
 
 
 
 
 
 
 
 
229
  with st.sidebar:
230
- st.image("sriram.jpg", caption="Say cheese :)", use_container_width=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
- st.title("Sriram’s Q Reflections 🔎📖")
 
 
233
 
234
  # File paths
235
  file_path = "faiss_index.pkl"
@@ -276,7 +437,7 @@ if query:
276
  st.markdown(
277
  f"""
278
  <div class="memory-box">
279
- <p style="margin: 0; font-size: 16px;">{item}</p>
280
  </div>
281
  """,
282
  unsafe_allow_html=True
@@ -285,3 +446,12 @@ if query:
285
  st.error("FAISS index or chunk files are missing. Please check the paths.")
286
 
287
 
 
 
 
 
 
 
 
 
 
 
160
  # </p>
161
  # """, unsafe_allow_html=True)
162
 
163
+ # import os
164
+ # import faiss
165
+ # import streamlit as st
166
+ # import pickle
167
+ # import time
168
+ # import numpy as np
169
+ # from langchain.chains import RetrievalQA
170
+ # from langchain.text_splitter import RecursiveCharacterTextSplitter
171
+ # #from langchain.vectorstores import FAISS
172
+ # from langchain_community.vectorstores import FAISS
173
+ # from langchain_huggingface import HuggingFaceEndpoint
174
+ # from sentence_transformers import SentenceTransformer
175
+ # from langchain.embeddings import HuggingFaceEmbeddings
176
+ # #from langchain import HuggingFaceHub
177
+ # from langchain_community.llms import HuggingFaceHub
178
+ # from dotenv import load_dotenv
179
+
180
+ # # Custom CSS for styling Streamlit app
181
+ # st.markdown(
182
+ # """
183
+ # <style>
184
+ # .main {
185
+ # background: linear-gradient(135deg, #FFDEE9 0%, #B5FFFC 100%);
186
+ # color: #ffffff;
187
+ # font-family: 'Arial', sans-serif;
188
+ # }
189
+ # .stButton>button {
190
+ # background-color: #1f77b4;
191
+ # color: white;
192
+ # border-radius: 12px;
193
+ # padding: 8px 12px;
194
+ # margin-top: 10px;
195
+ # border: none;
196
+ # cursor: pointer;
197
+ # transition: background-color 0.3s;
198
+ # }
199
+ # .stButton>button:hover {
200
+ # background-color: #105a87;
201
+ # }
202
+ # .custom-input {
203
+ # font-size: 18px;
204
+ # padding: 10px;
205
+ # border-radius: 8px;
206
+ # border: 1px solid #ccc;
207
+ # margin-bottom: 8px;
208
+ # width: 100%;
209
+ # }
210
+ # .memory-box {
211
+ # padding: 12px;
212
+ # margin: 10px 0;
213
+ # border: 1px solid #ccc;
214
+ # border-radius: 8px;
215
+ # background-color: #d9fcea;
216
+ # box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
217
+ # height: 150px;
218
+ # display: flex;
219
+ # align-items: center;
220
+ # justify-content: center;
221
+ # text-align: center;
222
+ # overflow: hidden;
223
+ # }
224
+ # </style>
225
+ # """,
226
+ # unsafe_allow_html=True
227
+ # )
228
+
229
+ # with st.sidebar:
230
+ # st.image("sriram.jpg", caption="Say cheese :)", use_container_width=True)
231
+
232
+ # st.title("Sriram’s Q Reflections 🔎📖")
233
+
234
+ # # File paths
235
+ # file_path = "faiss_index.pkl"
236
+ # chunk_path = "chunks.pkl"
237
+
238
+ # # Text input with custom class for styling
239
+ # query = st.text_input("Search for a Memory:", placeholder="Enter a memory or keyword", key="custom_input", help="Type here", label_visibility="visible")
240
+ # submit = st.button("Recall it")
241
+
242
+ # # Create a placeholder for the "Searching for memories..." message
243
+ # searching_placeholder = st.empty()
244
+
245
+ # if query:
246
+ # # Display "Searching for memories..." message
247
+ # searching_placeholder.info("Searching for memories...!")
248
+
249
+ # # Load FAISS index and chunks if the files exist
250
+ # if os.path.exists(file_path) and os.path.exists(chunk_path):
251
+ # with open(file_path, 'rb') as f:
252
+ # index = pickle.load(f)
253
+ # with open(chunk_path, 'rb') as f:
254
+ # chunks = pickle.load(f)
255
+
256
+ # # Load embedding model
257
+ # model = SentenceTransformer("thenlper/gte-large")
258
+ # query_embedding = model.encode(query).astype('float32').reshape(1, -1)
259
+ # distances, indices = index.search(query_embedding, k=6) # Retrieve top 6 matches
260
+ # retrieved_chunks = [chunks[i] for i in indices[0]]
261
+
262
+ # # Clean and format the retrieved memories
263
+ # st.header("Q Memories:")
264
+ # cleaned_text_list = [
265
+ # item.strip().replace(" .", ".").replace("\n", " ").lstrip(". ").strip() + "."
266
+ # for item in retrieved_chunks
267
+ # ]
268
+
269
+ # # Clear the "Searching for memories..." message once results are ready
270
+ # searching_placeholder.empty()
271
+
272
+ # # Display the memories in styled boxes
273
+ # col1, col2 = st.columns(2) # Two-column layout for display
274
+ # for i, item in enumerate(cleaned_text_list):
275
+ # with col1 if i % 2 == 0 else col2:
276
+ # st.markdown(
277
+ # f"""
278
+ # <div class="memory-box">
279
+ # <p style="margin: 0; font-size: 16px;">{item}</p>
280
+ # </div>
281
+ # """,
282
+ # unsafe_allow_html=True
283
+ # )
284
+ # else:
285
+ # st.error("FAISS index or chunk files are missing. Please check the paths.")
286
+
287
+
288
  import os
289
  import faiss
290
  import streamlit as st
 
308
  <style>
309
  .main {
310
  background: linear-gradient(135deg, #FFDEE9 0%, #B5FFFC 100%);
311
+ color: #333;
312
  font-family: 'Arial', sans-serif;
313
  }
314
  .stButton>button {
315
+ background-color: #0e0f5e;
316
  color: white;
317
  border-radius: 12px;
318
  padding: 8px 12px;
 
322
  transition: background-color 0.3s;
323
  }
324
  .stButton>button:hover {
325
+ background-color: red;
326
  }
327
  .custom-input {
328
  font-size: 18px;
 
335
  .memory-box {
336
  padding: 12px;
337
  margin: 10px 0;
338
+ font-weight:bold;
339
+ border: 2px solid #ccc;
340
+ border-radius: 15px;
341
+ background-color: #0e0f5e;
342
+ box-shadow: 4px 4px 12px #bdbffc; /* Softer box-shadow */
343
+
344
  height: 150px;
345
  display: flex;
346
  align-items: center;
347
  justify-content: center;
348
  text-align: center;
349
  overflow: hidden;
350
+ font-size: 16px;
351
+ line-height: 1.5;
352
+ transition: transform 0.3s ease-in-out;
353
+ }
354
+
355
+ .memory-box:hover {
356
+ transform: scale(1.05); /* Hover effect */
357
+ background-color: #f20246; /* Slightly darker pink on hover */
358
  }
359
  </style>
360
  """,
361
  unsafe_allow_html=True
362
  )
363
 
364
+ import base64
365
+
366
+ # Encode the image in base64
367
+ def get_base64_image(image_path):
368
+ with open(image_path, "rb") as img_file:
369
+ return base64.b64encode(img_file.read()).decode()
370
+
371
+ # Path to your image
372
+ image_path = "sriram.jpg"
373
+ image_base64 = get_base64_image(image_path)
374
+
375
  with st.sidebar:
376
+ st.markdown(
377
+ f"""
378
+ <div style="text-align: center; padding: 20px; background-color: #f9f9f9; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);">
379
+ <img src="data:image/jpeg;base64,{image_base64}" style="width: 80%; border-radius: 50%;" alt="Sriram">
380
+ <p style="margin-top: 15px; font-size: 16px; font-weight: bold; color: #333; line-height: 1.5;">
381
+ Sriram, you’ve been an exceptional mentor and a true inspiration. Your jolly personality, unmatched intelligence, and brilliant reasoning skills have always stood out. I’m incredibly thankful that you recognized my potential and gave me the opportunity to start my journey as a Machine Learning Engineer. Your belief in me not only gave me the confidence to pursue my passion but also helped me grow immensely. Thank you for your unwavering guidance and support. As you move forward, I wish you nothing but the best in all your future endeavors. Let’s stay in touch, and I’ll always appreciate everything you’ve done for me!
382
+ </p>
383
+ </div>
384
+ """,
385
+ unsafe_allow_html=True
386
+ )
387
+
388
+
389
+
390
 
391
+
392
+
393
+ st.title("Sriram’s Q Reflections 📖")
394
 
395
  # File paths
396
  file_path = "faiss_index.pkl"
 
437
  st.markdown(
438
  f"""
439
  <div class="memory-box">
440
+ <p style="margin: 0; font-size: 16px; color: white;">{item}</p>
441
  </div>
442
  """,
443
  unsafe_allow_html=True
 
446
  st.error("FAISS index or chunk files are missing. Please check the paths.")
447
 
448
 
449
+
450
+ st.markdown("""
451
+ <hr style="margin-top: 2em;">
452
+ <p style="text-align: center; color: gray; font-size: small;">
453
+ Developed by Aditya Hariharan
454
+ </p>
455
+ """, unsafe_allow_html=True)
456
+
457
+