euracle commited on
Commit
02793df
·
verified ·
1 Parent(s): b0f4cd8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -28
app.py CHANGED
@@ -2,6 +2,7 @@ import base64
2
  from itertools import cycle
3
  import time
4
  import streamlit as st
 
5
  import os
6
  from dotenv import load_dotenv
7
  import time
@@ -22,6 +23,36 @@ HEADER_IMAGE = "i1.jpg" # Organic farming landscape
22
  SIDE_IMAGE = "i2.JPG" # Medicinal plants/herbs
23
  FOOTER_IMAGE = "i3.JPG" # Sustainable farming practices
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  def initialize_vector_db():
26
  if os.path.exists(PERSISTENT_DIR) and os.listdir(PERSISTENT_DIR):
27
  embeddings = HuggingFaceEmbeddings()
@@ -223,6 +254,21 @@ fallback_chain = LLMChain(llm=llm, prompt=fallback_prompt)
223
 
224
  chat_container = st.container()
225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  with st.form(key='query_form'):
227
  query = st.text_input("Ask your question:", value="")
228
  submit_button = st.form_submit_button(label='Submit')
@@ -278,35 +324,35 @@ st.markdown("""
278
  </style>
279
  """, unsafe_allow_html=True)
280
 
281
- def create_auto_rotating_carousel(image_paths, interval=3):
282
- if 'carousel_time' not in st.session_state:
283
- st.session_state.carousel_time = time.time()
284
- st.session_state.carousel_idx = 0
285
 
286
- # Check if interval has passed
287
- current_time = time.time()
288
- if current_time - st.session_state.carousel_time > interval:
289
- st.session_state.carousel_idx = (st.session_state.carousel_idx + 1) % len(image_paths)
290
- st.session_state.carousel_time = current_time
291
 
292
- # Create three columns
293
- cols = st.columns(3)
294
 
295
- # Calculate indices for three images
296
- num_images = len(image_paths)
297
- indices = [
298
- (st.session_state.carousel_idx + i) % num_images
299
- for i in range(3)
300
- ]
301
 
302
- # Display images
303
- for idx, col in enumerate(cols):
304
- with col:
305
- st.image(
306
- image_paths[indices[idx]],
307
- use_container_width=True,
308
- caption=f"Image {indices[idx]+1}"
309
- )
310
-
311
- # Replace the previous carousel call with:
312
- create_auto_rotating_carousel(carousel_images, interval=3)
 
2
  from itertools import cycle
3
  import time
4
  import streamlit as st
5
+ from streamlit_carousel import carousel
6
  import os
7
  from dotenv import load_dotenv
8
  import time
 
23
  SIDE_IMAGE = "i2.JPG" # Medicinal plants/herbs
24
  FOOTER_IMAGE = "i3.JPG" # Sustainable farming practices
25
 
26
+ images = [
27
+ dict(
28
+ title="Image 1",
29
+ text="",
30
+ img="i1.jpg"
31
+ ),
32
+ dict(
33
+ title="Image 2",
34
+ text="",
35
+ img="i2.JPG"
36
+ ),
37
+ dict(
38
+ title="Image 3",
39
+ text="",
40
+ img="i3.JPG"
41
+ ),
42
+ dict(
43
+ title="Image 4",
44
+ text="",
45
+ img="i4.jpg"
46
+ ),
47
+ dict(
48
+ title="Image 5",
49
+ text="",
50
+ img="i5.JPG"
51
+ )
52
+ ]
53
+
54
+ carousel(items=images)
55
+
56
  def initialize_vector_db():
57
  if os.path.exists(PERSISTENT_DIR) and os.listdir(PERSISTENT_DIR):
58
  embeddings = HuggingFaceEmbeddings()
 
254
 
255
  chat_container = st.container()
256
 
257
+ st.markdown("""
258
+ <style>
259
+ .stButton > button {
260
+ color: red;
261
+ }
262
+ /* Maintain color on hover and focus */
263
+ .stButton > button:hover {
264
+ color: red;
265
+ }
266
+ .stButton > button:focus {
267
+ color: red;
268
+ }
269
+ </style>
270
+ """, unsafe_allow_html=True)
271
+
272
  with st.form(key='query_form'):
273
  query = st.text_input("Ask your question:", value="")
274
  submit_button = st.form_submit_button(label='Submit')
 
324
  </style>
325
  """, unsafe_allow_html=True)
326
 
327
+ # def create_auto_rotating_carousel(image_paths, interval=3):
328
+ # if 'carousel_time' not in st.session_state:
329
+ # st.session_state.carousel_time = time.time()
330
+ # st.session_state.carousel_idx = 0
331
 
332
+ # # Check if interval has passed
333
+ # current_time = time.time()
334
+ # if current_time - st.session_state.carousel_time > interval:
335
+ # st.session_state.carousel_idx = (st.session_state.carousel_idx + 1) % len(image_paths)
336
+ # st.session_state.carousel_time = current_time
337
 
338
+ # # Create three columns
339
+ # cols = st.columns(3)
340
 
341
+ # # Calculate indices for three images
342
+ # num_images = len(image_paths)
343
+ # indices = [
344
+ # (st.session_state.carousel_idx + i) % num_images
345
+ # for i in range(3)
346
+ # ]
347
 
348
+ # # Display images
349
+ # for idx, col in enumerate(cols):
350
+ # with col:
351
+ # st.image(
352
+ # image_paths[indices[idx]],
353
+ # use_container_width=True,
354
+ # caption=f"Image {indices[idx]+1}"
355
+ # )
356
+
357
+ # # Replace the previous carousel call with:
358
+ # create_auto_rotating_carousel(carousel_images, interval=3)