Spaces:
Sleeping
Sleeping
Improving models' conversation
Browse files
app.py
CHANGED
@@ -71,6 +71,16 @@ Provide an approach or solution from a data-centric perspective.
|
|
71 |
)
|
72 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
##############################################################################
|
75 |
# STREAMLIT APP
|
76 |
##############################################################################
|
@@ -124,8 +134,14 @@ if st.button("Start/Continue Conversation"):
|
|
124 |
)
|
125 |
st.session_state.conversation.append(("Analyst", analyst_resp))
|
126 |
|
|
|
|
|
|
|
|
|
127 |
for speaker, text in st.session_state.conversation:
|
128 |
if speaker == "User":
|
129 |
st.markdown(f"**{speaker}:** {text}")
|
|
|
|
|
130 |
else:
|
131 |
st.markdown(f"<div style='display:none'>{speaker}: {text}</div>", unsafe_allow_html=True)
|
|
|
71 |
)
|
72 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
73 |
|
74 |
+
def summarize_conversation(conversation):
|
75 |
+
"""
|
76 |
+
Summarize the entire conversation to produce a comprehensive plan.
|
77 |
+
"""
|
78 |
+
summary = "Here is the summarized plan based on the discussion:\n"
|
79 |
+
for speaker, text in conversation:
|
80 |
+
if speaker != "User":
|
81 |
+
summary += f"- {speaker}: {text}\n"
|
82 |
+
return summary
|
83 |
+
|
84 |
##############################################################################
|
85 |
# STREAMLIT APP
|
86 |
##############################################################################
|
|
|
134 |
)
|
135 |
st.session_state.conversation.append(("Analyst", analyst_resp))
|
136 |
|
137 |
+
# Generate the summary after the conversation
|
138 |
+
final_plan = summarize_conversation(st.session_state.conversation)
|
139 |
+
st.session_state.conversation.append(("Summary", final_plan))
|
140 |
+
|
141 |
for speaker, text in st.session_state.conversation:
|
142 |
if speaker == "User":
|
143 |
st.markdown(f"**{speaker}:** {text}")
|
144 |
+
elif speaker == "Summary":
|
145 |
+
st.markdown(f"**{speaker}:** {text}")
|
146 |
else:
|
147 |
st.markdown(f"<div style='display:none'>{speaker}: {text}</div>", unsafe_allow_html=True)
|