lakxs commited on
Commit
b175159
โ€ข
1 Parent(s): 1e94bd5

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -4
app.py CHANGED
@@ -134,6 +134,12 @@ def handle_userinput(user_question):
134
  else:
135
  st.write(bot_template.replace(
136
  "{{MSG}}", message.content), unsafe_allow_html=True)
 
 
 
 
 
 
137
 
138
 
139
  def main():
@@ -142,14 +148,24 @@ def main():
142
  page_icon=":books:")
143
  st.write(css, unsafe_allow_html=True)
144
 
145
- if "conversation" not in st.session_state:
146
- st.session_state.conversation = None
147
- if "chat_history" not in st.session_state:
148
- st.session_state.chat_history = None
 
 
 
 
149
 
150
  st.header("Chat with multiple Files:")
151
  user_question = st.text_input("Ask a question about your documents:")
 
 
152
  if user_question:
 
 
 
 
153
  handle_userinput(user_question)
154
 
155
  with st.sidebar:
 
134
  else:
135
  st.write(bot_template.replace(
136
  "{{MSG}}", message.content), unsafe_allow_html=True)
137
+ text_chunks = []
138
+ def initialize_conversation_chain():
139
+ # Add the necessary code to initialize the conversation_chain
140
+ # This may include loading the LlamaCpp model and creating the conversation_chain
141
+ vectorstore = get_vectorstore(text_chunks) # Replace this with the appropriate code
142
+ return get_conversation_chain(vectorstore)
143
 
144
 
145
  def main():
 
148
  page_icon=":books:")
149
  st.write(css, unsafe_allow_html=True)
150
 
151
+ # ๋Œ€ํ™” ์ฒด์ธ์ด ์„ธ์…˜ ์ƒํƒœ์— ์—†๊ฑฐ๋‚˜ None์ธ ๊ฒฝ์šฐ ์ดˆ๊ธฐํ™”ํ•ฉ๋‹ˆ๋‹ค.
152
+ if "conversation" not in st.session_state or st.session_state.conversation is None:
153
+ # ์ ์ ˆํ•œ ๋ฐ์ดํ„ฐ๋กœ text_chunks๋ฅผ ์ •์˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
154
+ st.session_state.conversation = initialize_conversation_chain(text_chunks)
155
+ # if "conversation" not in st.session_state:
156
+ # st.session_state.conversation = None
157
+ # if "chat_history" not in st.session_state:
158
+ # st.session_state.chat_history = None
159
 
160
  st.header("Chat with multiple Files:")
161
  user_question = st.text_input("Ask a question about your documents:")
162
+ # if user_question:
163
+ # handle_userinput(user_question)
164
  if user_question:
165
+ # Ensure that conversation_chain is initialized before calling handle_userinput
166
+ if st.session_state.conversation is None:
167
+ st.session_state.conversation = initialize_conversation_chain()
168
+
169
  handle_userinput(user_question)
170
 
171
  with st.sidebar: