Spaces:
Runtime error
Runtime error
Upload main_app.py
Browse files- main_app.py +7 -4
main_app.py
CHANGED
|
@@ -10,8 +10,6 @@ import sys
|
|
| 10 |
import time
|
| 11 |
import streamlit.components.v1 as components
|
| 12 |
import requests
|
| 13 |
-
from huggingface_hub import HfApi, whoami
|
| 14 |
-
from datetime import datetime
|
| 15 |
from dotenv import load_dotenv
|
| 16 |
from contextlib import contextmanager
|
| 17 |
|
|
@@ -53,7 +51,7 @@ st.write(f"ユーザー ID: {user_id} (HF ログイン: {is_hf_user})")
|
|
| 53 |
|
| 54 |
if not is_hf_user:
|
| 55 |
import streamlit.components.v1 as components
|
| 56 |
-
login_url = "https://sirochild-mari-chat-3.hf.space
|
| 57 |
components.html(f"""
|
| 58 |
<a href="{login_url}" target="_blank">
|
| 59 |
<button>HuggingFaceでログイン</button>
|
|
@@ -91,7 +89,7 @@ def start_session_server():
|
|
| 91 |
セッション管理サーバーを自動起動する
|
| 92 |
Hugging Face Spacesでの実行時に必要
|
| 93 |
"""
|
| 94 |
-
|
| 95 |
import threading
|
| 96 |
import requests
|
| 97 |
import time
|
|
@@ -319,18 +317,23 @@ def initialize_session_state(managers, force_reset_override=False):
|
|
| 319 |
|
| 320 |
# 基本的なセッション状態を最初に初期化(Cookie処理より前)
|
| 321 |
logger.info("🚀 基本セッション状態の早期初期化開始")
|
|
|
|
| 322 |
if 'chat_initialized' not in st.session_state:
|
| 323 |
st.session_state.chat_initialized = False
|
| 324 |
logger.info("✅ chat_initialized フラグを初期化(Cookie処理前)")
|
|
|
|
| 325 |
if 'memory_notifications' not in st.session_state:
|
| 326 |
st.session_state.memory_notifications = []
|
| 327 |
logger.info("✅ memory_notifications を初期化")
|
|
|
|
| 328 |
if 'affection_notifications' not in st.session_state:
|
| 329 |
st.session_state.affection_notifications = []
|
| 330 |
logger.info("✅ affection_notifications を初期化")
|
|
|
|
| 331 |
if 'debug_mode' not in st.session_state:
|
| 332 |
st.session_state.debug_mode = os.getenv("DEBUG_MODE", "false").lower() == "true"
|
| 333 |
logger.info(f"✅ debug_mode を初期化: {st.session_state.debug_mode}")
|
|
|
|
| 334 |
logger.info("✅ 基本セッション状態の早期初期化完了")
|
| 335 |
|
| 336 |
# 強制リセットフラグ(開発時用または明示的な指定)
|
|
|
|
| 10 |
import time
|
| 11 |
import streamlit.components.v1 as components
|
| 12 |
import requests
|
|
|
|
|
|
|
| 13 |
from dotenv import load_dotenv
|
| 14 |
from contextlib import contextmanager
|
| 15 |
|
|
|
|
| 51 |
|
| 52 |
if not is_hf_user:
|
| 53 |
import streamlit.components.v1 as components
|
| 54 |
+
login_url = "https://sirochild-mari-chat-3.hf.space/login"
|
| 55 |
components.html(f"""
|
| 56 |
<a href="{login_url}" target="_blank">
|
| 57 |
<button>HuggingFaceでログイン</button>
|
|
|
|
| 89 |
セッション管理サーバーを自動起動する
|
| 90 |
Hugging Face Spacesでの実行時に必要
|
| 91 |
"""
|
| 92 |
+
|
| 93 |
import threading
|
| 94 |
import requests
|
| 95 |
import time
|
|
|
|
| 317 |
|
| 318 |
# 基本的なセッション状態を最初に初期化(Cookie処理より前)
|
| 319 |
logger.info("🚀 基本セッション状態の早期初期化開始")
|
| 320 |
+
|
| 321 |
if 'chat_initialized' not in st.session_state:
|
| 322 |
st.session_state.chat_initialized = False
|
| 323 |
logger.info("✅ chat_initialized フラグを初期化(Cookie処理前)")
|
| 324 |
+
|
| 325 |
if 'memory_notifications' not in st.session_state:
|
| 326 |
st.session_state.memory_notifications = []
|
| 327 |
logger.info("✅ memory_notifications を初期化")
|
| 328 |
+
|
| 329 |
if 'affection_notifications' not in st.session_state:
|
| 330 |
st.session_state.affection_notifications = []
|
| 331 |
logger.info("✅ affection_notifications を初期化")
|
| 332 |
+
|
| 333 |
if 'debug_mode' not in st.session_state:
|
| 334 |
st.session_state.debug_mode = os.getenv("DEBUG_MODE", "false").lower() == "true"
|
| 335 |
logger.info(f"✅ debug_mode を初期化: {st.session_state.debug_mode}")
|
| 336 |
+
|
| 337 |
logger.info("✅ 基本セッション状態の早期初期化完了")
|
| 338 |
|
| 339 |
# 強制リセットフラグ(開発時用または明示的な指定)
|