diff --git a/components/__pycache__/__init__.cpython-313.pyc b/components/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000..b5eb29b Binary files /dev/null and b/components/__pycache__/__init__.cpython-313.pyc differ diff --git a/components/__pycache__/chat_interface.cpython-313.pyc b/components/__pycache__/chat_interface.cpython-313.pyc new file mode 100644 index 0000000..c6cb3be Binary files /dev/null and b/components/__pycache__/chat_interface.cpython-313.pyc differ diff --git a/components/__pycache__/header.cpython-313.pyc b/components/__pycache__/header.cpython-313.pyc new file mode 100644 index 0000000..3599f89 Binary files /dev/null and b/components/__pycache__/header.cpython-313.pyc differ diff --git a/components/__pycache__/sidebar.cpython-313.pyc b/components/__pycache__/sidebar.cpython-313.pyc new file mode 100644 index 0000000..6b26cef Binary files /dev/null and b/components/__pycache__/sidebar.cpython-313.pyc differ diff --git a/components/chat_interface.py b/components/chat_interface.py index 991ef1b..c7b52e7 100644 --- a/components/chat_interface.py +++ b/components/chat_interface.py @@ -1,6 +1,44 @@ import streamlit as st from core.utils import get_current_time, get_ai_response +import streamlit.components.v1 as components +import streamlit as st +from datetime import datetime, timedelta +import json + +def set_user_time_in_session(): + if "user_time_offset" not in st.session_state: + # Embed JS to send local timezone offset in minutes + components.html(""" + + """, height=0) + + st.markdown(""" + + """, unsafe_allow_html=True) + + else: + # Already set, do nothing + pass + +set_user_time_in_session() + def render_chat_interface(): if st.session_state.active_conversation >= 0: active_convo = st.session_state.conversations[st.session_state.active_conversation] diff --git a/core/__pycache__/__init__.cpython-313.pyc b/core/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000..0c7aeb7 Binary files /dev/null and b/core/__pycache__/__init__.cpython-313.pyc differ diff --git a/core/__pycache__/config.cpython-313.pyc b/core/__pycache__/config.cpython-313.pyc new file mode 100644 index 0000000..aab7895 Binary files /dev/null and b/core/__pycache__/config.cpython-313.pyc differ diff --git a/core/__pycache__/utils.cpython-313.pyc b/core/__pycache__/utils.cpython-313.pyc new file mode 100644 index 0000000..84cbc69 Binary files /dev/null and b/core/__pycache__/utils.cpython-313.pyc differ diff --git a/core/config.py b/core/config.py index 0b557dc..50a452f 100644 --- a/core/config.py +++ b/core/config.py @@ -15,7 +15,7 @@ def configure_gemini(): try: api_key = st.secrets["GEMINI_API_KEY"] - genai.configure(api_key=api_key) + genai.configure(api_key="GEMINI_API_KEY") model = genai.GenerativeModel('gemini-2.0-flash') return model except KeyError: diff --git a/core/utils.py b/core/utils.py index 16ae530..b442f81 100644 --- a/core/utils.py +++ b/core/utils.py @@ -1,11 +1,21 @@ -from datetime import datetime +from datetime import datetime, timedelta, timezone import streamlit as st import re def get_current_time(): - """Returns the current time formatted as HH:MM AM/PM.""" - now = datetime.now() - return now.strftime("%-I:%M %p") if hasattr(now, 'strftime') else now.strftime("%I:%M %p").lstrip('0') + """Returns the user's local time formatted as HH:MM AM/PM.""" + tz_offset = st.context.timezone_offset + + if tz_offset is None: + # Default to UTC if timezone is not available (e.g., on Streamlit Cloud) + now = datetime.now() + else: + now_utc = datetime.now(timezone.utc) + now = now_utc + timedelta(minutes=-tz_offset) + + return now.strftime("%I:%M %p").lstrip("0") + + def create_new_conversation(initial_message=None): """ diff --git a/css/__pycache__/styles.cpython-313.pyc b/css/__pycache__/styles.cpython-313.pyc new file mode 100644 index 0000000..5fe2de4 Binary files /dev/null and b/css/__pycache__/styles.cpython-313.pyc differ