redkye2 commited on
Commit
801e595
Β·
1 Parent(s): bebb5c6
Files changed (1) hide show
  1. app.py +12 -16
app.py CHANGED
@@ -102,24 +102,20 @@ def get_conversation_chain(vectorstore):
102
  )
103
  return conversation_chain
104
 
105
-
106
  # μ‚¬μš©μž μž…λ ₯을 μ²˜λ¦¬ν•˜λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
107
  def handle_userinput(user_question):
108
- if st.session_state.conversation is not None:
109
- response = st.session_state.conversation({'question': user_question})
110
-
111
- # Assuming response is a dictionary containing 'chat_history'
112
- st.session_state.chat_history = response.get('chat_history', [])
113
-
114
- for i, message in enumerate(st.session_state.chat_history):
115
- if i % 2 == 0:
116
- st.write(user_template.replace(
117
- "{{MSG}}", message.content), unsafe_allow_html=True)
118
- else:
119
- st.write(bot_template.replace(
120
- "{{MSG}}", message.content), unsafe_allow_html=True)
121
- else:
122
- st.warning("Conversation function is not defined.")
123
 
124
 
125
  def main():
 
102
  )
103
  return conversation_chain
104
 
 
105
  # μ‚¬μš©μž μž…λ ₯을 μ²˜λ¦¬ν•˜λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
106
  def handle_userinput(user_question):
107
+ # λŒ€ν™” 체인을 μ‚¬μš©ν•˜μ—¬ μ‚¬μš©μž μ§ˆλ¬Έμ— λŒ€ν•œ 응닡을 μƒμ„±ν•©λ‹ˆλ‹€.
108
+ response = st.session_state.conversation({'question': user_question})
109
+ # λŒ€ν™” 기둝을 μ €μž₯ν•©λ‹ˆλ‹€.
110
+ st.session_state.chat_history = response['chat_history']
111
+
112
+ for i, message in enumerate(st.session_state.chat_history):
113
+ if i % 2 == 0:
114
+ st.write(user_template.replace(
115
+ "{{MSG}}", message.content), unsafe_allow_html=True)
116
+ else:
117
+ st.write(bot_template.replace(
118
+ "{{MSG}}", message.content), unsafe_allow_html=True)
 
 
 
119
 
120
 
121
  def main():