thisisdev commited on
Commit
9bc4ac7
1 Parent(s): b0728fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -16
app.py CHANGED
@@ -40,25 +40,25 @@ llm = ChatGoogleGenerativeAI(
40
 
41
 
42
  # Response function
43
- # def load_answer(question):
44
- # st.session_state.sessionMessages.append(HumanMessage(content=question))
45
- # assistant_response = llm.invoke(st.session_state.sessionMessages)
46
 
47
- # # Assuming assistant_response is an object with a 'content' attribute
48
- # if hasattr(assistant_response, 'content') and isinstance(assistant_response.content, str):
49
- # processed_content = assistant_response.content
50
- # st.session_state.sessionMessages.append(AIMessage(content=processed_content))
51
- # else:
52
- # st.error("Invalid response received from AI.")
53
- # processed_content = "Sorry, I couldn't process your request."
54
 
55
- # return processed_content
56
 
57
- def load_answer(question):
58
- st.session_state.sessionMessages.append(HumanMessage(content = question))
59
- assistant_answer = llm.invoke(st.session_state.sessionMessages)
60
- st.session_state.sessionMessages.append(AIMessage(content = assistant_answer))
61
- return assistant_answer.content
62
 
63
  # User message
64
  def get_text():
 
40
 
41
 
42
  # Response function
43
+ def load_answer(question):
44
+ st.session_state.sessionMessages.append(HumanMessage(content=question))
45
+ assistant_response = llm.invoke(st.session_state.sessionMessages)
46
 
47
+ # Assuming assistant_response is an object with a 'content' attribute
48
+ if hasattr(assistant_response, 'content') and isinstance(assistant_response.content, str):
49
+ processed_content = assistant_response.content
50
+ st.session_state.sessionMessages.append(AIMessage(content=processed_content))
51
+ else:
52
+ st.error("Invalid response received from AI.")
53
+ processed_content = "Sorry, I couldn't process your request."
54
 
55
+ return processed_content
56
 
57
+ # def load_answer(question):
58
+ # st.session_state.sessionMessages.append(HumanMessage(content = question))
59
+ # assistant_answer = llm.invoke(st.session_state.sessionMessages)
60
+ # st.session_state.sessionMessages.append(AIMessage(content = assistant_answer))
61
+ # return assistant_answer.content
62
 
63
  # User message
64
  def get_text():