Spaces:
Runtime error
Runtime error
Upload main_app.py
Browse files- main_app.py +27 -25
main_app.py
CHANGED
|
@@ -2185,31 +2185,7 @@ Streamlit情報:
|
|
| 2185 |
if "affection_notifications" not in st.session_state:
|
| 2186 |
st.session_state.affection_notifications = []
|
| 2187 |
|
| 2188 |
-
#
|
| 2189 |
-
col1, col2 = st.columns([4, 1])
|
| 2190 |
-
|
| 2191 |
-
# フォームを使用してウィジェットの状態管理を改善
|
| 2192 |
-
with st.form(key="chat_form", clear_on_submit=True):
|
| 2193 |
-
col1, col2 = st.columns([4, 1])
|
| 2194 |
-
|
| 2195 |
-
with col1:
|
| 2196 |
-
prompt = st.text_input(
|
| 2197 |
-
"麻理にメッセージを送信...",
|
| 2198 |
-
placeholder="ここにメッセージを入力してください",
|
| 2199 |
-
label_visibility="collapsed"
|
| 2200 |
-
)
|
| 2201 |
-
|
| 2202 |
-
with col2:
|
| 2203 |
-
# 送信ボタン
|
| 2204 |
-
submitted = st.form_submit_button("送信", use_container_width=True, type="primary")
|
| 2205 |
-
|
| 2206 |
-
if submitted and prompt: # フォームが送信され、何か入力されている場合のみ処理
|
| 2207 |
-
# 応答処理のロジックをトリガーする
|
| 2208 |
-
st.session_state.awaiting_response = True
|
| 2209 |
-
st.session_state.latest_prompt = prompt
|
| 2210 |
-
|
| 2211 |
-
# フォームのclear_on_submit=Trueにより自動的に入力欄がクリアされる
|
| 2212 |
-
# rerunは不要 - フォーム送信により自動的に再描画される
|
| 2213 |
|
| 2214 |
|
| 2215 |
# 応答処理(rerun 後にこのブロックが実行される)
|
|
@@ -2305,6 +2281,32 @@ Streamlit情報:
|
|
| 2305 |
st.session_state.response_completed = False # フラグをクリア
|
| 2306 |
logger.info("応答完了後の処理完了")
|
| 2307 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2308 |
# DogAssistantの固定配置コンポーネントを描画(右下のみ)
|
| 2309 |
# 犬のボタン表示前にチャットセッション状態を確認
|
| 2310 |
if 'chat' not in st.session_state:
|
|
|
|
| 2185 |
if "affection_notifications" not in st.session_state:
|
| 2186 |
st.session_state.affection_notifications = []
|
| 2187 |
|
| 2188 |
+
# チャット入力フォームは履歴表示の後に移動
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2189 |
|
| 2190 |
|
| 2191 |
# 応答処理(rerun 後にこのブロックが実行される)
|
|
|
|
| 2281 |
st.session_state.response_completed = False # フラグをクリア
|
| 2282 |
logger.info("応答完了後の処理完了")
|
| 2283 |
|
| 2284 |
+
# チャット入力フォーム(履歴の下に配置)
|
| 2285 |
+
st.markdown("---") # 区切り線
|
| 2286 |
+
|
| 2287 |
+
# フォームを使用してウィジェットの状態管理を改善
|
| 2288 |
+
with st.form(key="chat_form", clear_on_submit=True):
|
| 2289 |
+
col1, col2 = st.columns([4, 1])
|
| 2290 |
+
|
| 2291 |
+
with col1:
|
| 2292 |
+
prompt = st.text_input(
|
| 2293 |
+
"麻理にメッセージを送信...",
|
| 2294 |
+
placeholder="ここにメッセージを入力してください",
|
| 2295 |
+
label_visibility="collapsed"
|
| 2296 |
+
)
|
| 2297 |
+
|
| 2298 |
+
with col2:
|
| 2299 |
+
# 送信ボタン
|
| 2300 |
+
submitted = st.form_submit_button("送信", use_container_width=True, type="primary")
|
| 2301 |
+
|
| 2302 |
+
if submitted and prompt: # フォームが送信され、何か入力されている場合のみ処理
|
| 2303 |
+
# 応答処理のロジックをトリガーする
|
| 2304 |
+
st.session_state.awaiting_response = True
|
| 2305 |
+
st.session_state.latest_prompt = prompt
|
| 2306 |
+
|
| 2307 |
+
# フォームのclear_on_submit=Trueにより自動的に入力欄がクリアされる
|
| 2308 |
+
# rerunは不要 - フォーム送信により自動的に再描画される
|
| 2309 |
+
|
| 2310 |
# DogAssistantの固定配置コンポーネントを描画(右下のみ)
|
| 2311 |
# 犬のボタン表示前にチャットセッション状態を確認
|
| 2312 |
if 'chat' not in st.session_state:
|