ll7098ll commited on
Commit
57336d1
·
verified ·
1 Parent(s): b5598ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -56,8 +56,11 @@ if "history" not in st.session_state:
56
  if "chat_session" not in st.session_state:
57
  st.session_state.chat_session = chat_session
58
 
 
 
 
59
  # 사용자 입력 받기
60
- user_input = st.text_input("입력", key="user_input")
61
 
62
  def respond(user_input):
63
  st.session_state.history.append({"user": user_input, "ai": ""})
@@ -90,11 +93,12 @@ if user_input:
90
  respond(user_input)
91
 
92
  # 채팅 메시지 출력
93
- for chat in st.session_state.history:
94
- if "user" in chat:
95
- message(chat["user"], is_user=True, key=f"user_{chat['user']}")
96
- if "ai" in chat:
97
- message(chat["ai"], is_user=False, key=f"ai_{chat['ai']}")
 
98
 
99
  # 초기화 버튼 클릭 시
100
  if st.button("초기화"):
 
56
  if "chat_session" not in st.session_state:
57
  st.session_state.chat_session = chat_session
58
 
59
+ # 채팅 메시지 출력 섹션
60
+ chat_container = st.container()
61
+
62
  # 사용자 입력 받기
63
+ user_input = st.text_input("입력", key="user_input", placeholder="여기에 질문을 입력하세요...")
64
 
65
  def respond(user_input):
66
  st.session_state.history.append({"user": user_input, "ai": ""})
 
93
  respond(user_input)
94
 
95
  # 채팅 메시지 출력
96
+ with chat_container:
97
+ for chat in st.session_state.history:
98
+ if "user" in chat:
99
+ message(chat["user"], is_user=True, key=f"user_{chat['user']}")
100
+ if "ai" in chat:
101
+ message(chat["ai"], is_user=False, key=f"ai_{chat['ai']}")
102
 
103
  # 초기화 버튼 클릭 시
104
  if st.button("초기화"):