hienbm commited on
Commit
151abac
·
verified ·
1 Parent(s): 3ba8a22

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -169,13 +169,24 @@ if user_query is not None and find_youtube_links(user_query) != "":
169
  st.session_state.chat_history.append(AIMessage(content=response))
170
 
171
 
 
 
 
 
 
 
 
 
 
 
 
172
  if user_query is not None and user_query != "" and find_youtube_links(user_query) == "":
173
  st.session_state.chat_history.append(HumanMessage(content=user_query))
174
 
175
  with st.chat_message("Human"):
176
  st.markdown(user_query)
177
 
178
- response = get_response(user_query)
179
 
180
  # Remove any unwanted prefixes from the response
181
  response = response.replace("AI response:", "").replace("chat response:", "").replace("bot response:", "").strip()
 
169
  st.session_state.chat_history.append(AIMessage(content=response))
170
 
171
 
172
+
173
+ # Function to get a response from the model
174
+ def get_response_1(user_query, chat_history):
175
+ chain = template | chat_model | StrOutputParser()
176
+ response = chain.invoke({
177
+ "context": chat_history,
178
+ "question": user_query,
179
+ })
180
+
181
+ return response
182
+
183
  if user_query is not None and user_query != "" and find_youtube_links(user_query) == "":
184
  st.session_state.chat_history.append(HumanMessage(content=user_query))
185
 
186
  with st.chat_message("Human"):
187
  st.markdown(user_query)
188
 
189
+ response = get_response_1(user_query)
190
 
191
  # Remove any unwanted prefixes from the response
192
  response = response.replace("AI response:", "").replace("chat response:", "").replace("bot response:", "").strip()