ChijoTheDatascientist
commited on
Commit
•
75a7e4b
1
Parent(s):
526fc48
Testing mistralai/Mistral-7B-Instruct-v0.3 to generate insights
Browse files
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 |
-
#
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
else:
|
108 |
-
st.warning("No response generated. Please try again later.")
|
109 |
else:
|
110 |
-
st.warning("
|
|
|
|
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
|
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.")
|