ChijoTheDatascientist commited on
Commit
75a7e4b
1 Parent(s): 526fc48

Testing mistralai/Mistral-7B-Instruct-v0.3 to generate insights

Browse files
Files changed (1) hide show
  1. app.py +26 -26
app.py CHANGED
@@ -85,32 +85,32 @@ user_input = st.text_area("Enter customer reviews or a question:")
85
 
86
  if st.button("Submit"):
87
  if user_input:
88
- # Show a loading spinner while processing
89
- with st.spinner("Processing..."):
90
- # Summarize if the query is feedback-related
91
- if "summarize" in user_input.lower():
92
- summary = summarize_review(user_input)
93
- st.markdown(f"**Summary:** \n{summary}")
94
- elif "insight" in user_input.lower() or "feedback" in user_input.lower():
95
- system_message = (
96
- "You are a helpful assistant providing actionable insights "
97
- "from customer feedback to help businesses improve their services."
98
- )
99
- last_summary = st.session_state.get("last_summary", "")
100
- query_input = last_summary if last_summary else user_input
101
- response = generate_response(system_message, query_input, st.session_state.chat_history)
102
-
103
- if response:
104
- st.session_state.chat_history.append({"role": "user", "content": user_input})
105
- st.session_state.chat_history.append({"role": "assistant", "content": response})
106
- st.markdown(f"**Insight:** \n{response}")
107
- else:
108
- st.warning("No response generated. Please try again later.")
109
  else:
110
- st.warning("Please specify if you want to 'summarize' or get 'insights'.")
 
 
111
 
112
-
113
- if "summarize" in user_input.lower():
114
- st.session_state["last_summary"] = summary
115
  else:
116
- st.warning("Please enter customer reviews or ask for insights.")
 
85
 
86
  if st.button("Submit"):
87
  if user_input:
88
+ # Summarize if the query is feedback-related
89
+ if "summarize" in user_input.lower():
90
+ summary = summarize_review(user_input)
91
+ st.markdown(f"**Summary:** \n{summary}")
92
+ elif "insight" in user_input.lower() or "feedback" in user_input.lower():
93
+ system_message = (
94
+ "You are a helpful assistant providing actionable insights "
95
+ "from customer feedback to help businesses improve their services."
96
+ )
97
+ # Use the last summarized text if available
98
+ last_summary = st.session_state.get("last_summary", "")
99
+ query_input = last_summary if last_summary else user_input
100
+ response = generate_response(system_message, query_input, st.session_state.chat_history)
101
+
102
+ if response:
103
+ # Update chat history
104
+ st.session_state.chat_history.append({"role": "user", "content": user_input})
105
+ st.session_state.chat_history.append({"role": "assistant", "content": response})
106
+ st.markdown(f"**Insight:** \n{response}")
 
 
107
  else:
108
+ st.warning("No response generated. Please try again later.")
109
+ else:
110
+ st.warning("Please specify if you want to 'summarize' or get 'insights'.")
111
 
112
+ # Store the last summary for insights
113
+ if "summarize" in user_input.lower():
114
+ st.session_state["last_summary"] = summary
115
  else:
116
+ st.warning("Please enter customer reviews or ask for insights.")