Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -256,23 +256,29 @@ def render_llm_followup(chat_container, inline=False):
|
|
| 256 |
_ensure_llm_state()
|
| 257 |
MAX_TURNS = 6
|
| 258 |
|
| 259 |
-
#
|
| 260 |
-
if st.session_state.get("llm_intro_needed"):
|
| 261 |
-
log_and_render(
|
| 262 |
-
"๐ง ์ด์ ๋ถํฐ๋ ์์ ์ง๋ฌธ ๋ชจ๋์์. ์ฌํ ์ธ์๋ ๋ญ๋ ํ๊ตญ์ด๋ก ๋ฌผ์ด๋ณด์ธ์!",
|
| 263 |
-
sender="bot",
|
| 264 |
-
chat_container=chat_container,
|
| 265 |
-
key=f"llm_intro_{random.randint(1,999999)}"
|
| 266 |
-
)
|
| 267 |
-
st.session_state["llm_intro_needed"] = False
|
| 268 |
-
|
| 269 |
-
# ์ธ๋ผ์ธ ํจ๋ ๊ตฌ์ญ
|
| 270 |
if inline:
|
| 271 |
st.divider()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
st.markdown("#### ๐ค LLM ์ง๋ฌธ")
|
| 273 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
st.markdown("### ๐ค LLM ์ง๋ฌธ")
|
| 275 |
|
|
|
|
| 276 |
q = st.text_input(
|
| 277 |
"LLM ์ง๋ฌธ",
|
| 278 |
placeholder="๋ฌด์์ด๋ ๋ฌผ์ด๋ณด์ธ์ (์ข
๋ฃํ๋ ค๋ฉด '์ข
๋ฃ' ์
๋ ฅ)",
|
|
@@ -280,18 +286,19 @@ def render_llm_followup(chat_container, inline=False):
|
|
| 280 |
)
|
| 281 |
|
| 282 |
if q:
|
| 283 |
-
# ์ข
๋ฃ ํค์๋
|
| 284 |
if q.strip() in ("์ข
๋ฃ", "quit", "exit"):
|
| 285 |
if inline:
|
| 286 |
-
|
|
|
|
| 287 |
st.session_state["llm_input"] = ""
|
| 288 |
log_and_render(
|
| 289 |
-
"LLM
|
| 290 |
sender="bot", chat_container=chat_container,
|
| 291 |
key=f"llm_end_inline_{random.randint(1,999999)}"
|
| 292 |
)
|
| 293 |
return
|
| 294 |
else:
|
|
|
|
| 295 |
st.session_state["llm_mode"] = False
|
| 296 |
st.session_state["llm_input"] = ""
|
| 297 |
log_and_render(
|
|
@@ -299,10 +306,10 @@ def render_llm_followup(chat_container, inline=False):
|
|
| 299 |
sender="bot", chat_container=chat_container,
|
| 300 |
key=f"llm_end_full_{random.randint(1,999999)}"
|
| 301 |
)
|
| 302 |
-
# ํ์คํฌ๋ฆฐ ๋ชจ๋๋ง rerun
|
| 303 |
st.rerun()
|
| 304 |
return
|
| 305 |
|
|
|
|
| 306 |
log_and_render(q, sender="user", chat_container=chat_container,
|
| 307 |
key=f"llm_user_{random.randint(1,999999)}")
|
| 308 |
st.session_state.llm_history.append({"role": "user", "content": q})
|
|
@@ -323,9 +330,9 @@ def render_llm_followup(chat_container, inline=False):
|
|
| 323 |
st.session_state.llm_history.append({"role": "assistant", "content": a})
|
| 324 |
st.session_state["llm_input"] = ""
|
| 325 |
|
| 326 |
-
#
|
| 327 |
if inline:
|
| 328 |
-
if st.button("
|
| 329 |
st.session_state["llm_inline"] = False
|
| 330 |
else:
|
| 331 |
if st.button("๐ LLM ๋ชจ๋ ์ข
๋ฃ", key="llm_close_full"):
|
|
|
|
| 256 |
_ensure_llm_state()
|
| 257 |
MAX_TURNS = 6
|
| 258 |
|
| 259 |
+
# โโ ์ธ๋ผ์ธ: ๊ตฌ๋ถ์ ๋จผ์ , ๊ทธ ๋ค์ ์๋ด ๋ฒ๋ธ, ๊ทธ ๋ค์ ์
๋ ฅ์ฐฝ โโ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
if inline:
|
| 261 |
st.divider()
|
| 262 |
+
if st.session_state.pop("llm_intro_needed", False):
|
| 263 |
+
log_and_render(
|
| 264 |
+
"๐ง ์ด์ ๋ถํฐ๋ ์์ ์ง๋ฌธ ๋ชจ๋์์. ์ฌํ ์ธ์๋ ๋ญ๋ ํ๊ตญ์ด๋ก ๋ฌผ์ด๋ณด์ธ์!",
|
| 265 |
+
sender="bot",
|
| 266 |
+
chat_container=chat_container,
|
| 267 |
+
key=f"llm_intro_{random.randint(1,999999)}"
|
| 268 |
+
)
|
| 269 |
st.markdown("#### ๐ค LLM ์ง๋ฌธ")
|
| 270 |
else:
|
| 271 |
+
# ํ์คํฌ๋ฆฐ ๋ชจ๋์์๋ ์๋ด ๋ฒ๋ธ ๋จผ์
|
| 272 |
+
if st.session_state.pop("llm_intro_needed", False):
|
| 273 |
+
log_and_render(
|
| 274 |
+
"๐ง ์ด์ ๋ถํฐ๋ ์์ ์ง๋ฌธ ๋ชจ๋์์. ์ฌํ ์ธ์๋ ๋ญ๋ ํ๊ตญ์ด๋ก ๋ฌผ์ด๋ณด์ธ์!",
|
| 275 |
+
sender="bot",
|
| 276 |
+
chat_container=chat_container,
|
| 277 |
+
key=f"llm_intro_{random.randint(1,999999)}"
|
| 278 |
+
)
|
| 279 |
st.markdown("### ๐ค LLM ์ง๋ฌธ")
|
| 280 |
|
| 281 |
+
# ์
๋ ฅ์ฐฝ (ํญ์ ์ฌ๊ธฐ์๋ง ๋
ธ์ถ)
|
| 282 |
q = st.text_input(
|
| 283 |
"LLM ์ง๋ฌธ",
|
| 284 |
placeholder="๋ฌด์์ด๋ ๋ฌผ์ด๋ณด์ธ์ (์ข
๋ฃํ๋ ค๋ฉด '์ข
๋ฃ' ์
๋ ฅ)",
|
|
|
|
| 286 |
)
|
| 287 |
|
| 288 |
if q:
|
|
|
|
| 289 |
if q.strip() in ("์ข
๋ฃ", "quit", "exit"):
|
| 290 |
if inline:
|
| 291 |
+
# โ
์ธ๋ผ์ธ ์ข
๋ฃ(๋ฒ๋ธ์ ์ ์ง, ์๋ก๊ณ ์นจ ์์)
|
| 292 |
+
st.session_state["llm_inline"] = False
|
| 293 |
st.session_state["llm_input"] = ""
|
| 294 |
log_and_render(
|
| 295 |
+
"LLM ๋ชจ๋๋ฅผ ์ข
๋ฃํ ๊ฒ์. ํ์ํ์ค ๋ ๋ค์ ์ง๋ฌธํด ์ฃผ์ธ์! โจ",
|
| 296 |
sender="bot", chat_container=chat_container,
|
| 297 |
key=f"llm_end_inline_{random.randint(1,999999)}"
|
| 298 |
)
|
| 299 |
return
|
| 300 |
else:
|
| 301 |
+
# ํ์คํฌ๋ฆฐ ์ข
๋ฃ
|
| 302 |
st.session_state["llm_mode"] = False
|
| 303 |
st.session_state["llm_input"] = ""
|
| 304 |
log_and_render(
|
|
|
|
| 306 |
sender="bot", chat_container=chat_container,
|
| 307 |
key=f"llm_end_full_{random.randint(1,999999)}"
|
| 308 |
)
|
|
|
|
| 309 |
st.rerun()
|
| 310 |
return
|
| 311 |
|
| 312 |
+
# ์ผ๋ฐ ์ง์ ์ฒ๋ฆฌ
|
| 313 |
log_and_render(q, sender="user", chat_container=chat_container,
|
| 314 |
key=f"llm_user_{random.randint(1,999999)}")
|
| 315 |
st.session_state.llm_history.append({"role": "user", "content": q})
|
|
|
|
| 330 |
st.session_state.llm_history.append({"role": "assistant", "content": a})
|
| 331 |
st.session_state["llm_input"] = ""
|
| 332 |
|
| 333 |
+
# ํ๋จ ๋ฒํผ: ์ธ๋ผ์ธ์ 'LLM ํจ๋ ์ข
๋ฃ'๋ง, ํ์คํฌ๋ฆฐ์ 'LLM ๋ชจ๋ ์ข
๋ฃ'๋ง
|
| 334 |
if inline:
|
| 335 |
+
if st.button("๐ LLM ๋ชจ๋ ์ข
๋ฃ", key="llm_close_inline"):
|
| 336 |
st.session_state["llm_inline"] = False
|
| 337 |
else:
|
| 338 |
if st.button("๐ LLM ๋ชจ๋ ์ข
๋ฃ", key="llm_close_full"):
|