Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,44 +1,33 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from langchain.
|
| 3 |
-
from langchain.prompts import ChatPromptTemplate
|
| 4 |
-
from langchain.transformers import JsonSegmenter
|
| 5 |
|
| 6 |
-
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
|
| 10 |
|
| 11 |
-
# Initialize the
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
max_tokens=1024, # Maximum tokens per inference (adjust as needed)
|
| 16 |
)
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
#
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
for turn in conversation_turns:
|
| 29 |
-
current_prompt = prompt_template.format(conversation_turn=turn)
|
| 30 |
-
response = llm.run(text=current_prompt)
|
| 31 |
-
summary = response["text"].strip() # Extract summarized highlights
|
| 32 |
-
highlights.append(summary)
|
| 33 |
|
| 34 |
-
# Streamlit app
|
| 35 |
-
st.title("Conversation Highlights Generator")
|
| 36 |
-
|
| 37 |
-
# Display conversation data
|
| 38 |
-
st.subheader("Conversation Data:")
|
| 39 |
-
st.code(data, language="json")
|
| 40 |
-
|
| 41 |
-
# Display predicted highlights
|
| 42 |
-
st.subheader("Predicted Highlights:")
|
| 43 |
-
for i, highlight in enumerate(highlights, 1):
|
| 44 |
-
st.write(f"{i}. {highlight}")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from langchain.prompts import ConversationChain, ConversationTurnPromptTemplate, ListSummarizationPromptTemplate
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
st.title("Call Center Conversation Highlights")
|
| 5 |
|
| 6 |
+
# Text area for user input
|
| 7 |
+
conversation_text = st.text_area("Paste your call center conversation: ")
|
| 8 |
|
| 9 |
+
# Initialize the conversation chain
|
| 10 |
+
conversation_chain = ConversationChain(
|
| 11 |
+
turn_prompt_template=ConversationTurnPromptTemplate(),
|
| 12 |
+
summary_prompt_template=ListSummarizationPromptTemplate(prompt_text="Please summarize the key points in bullet points."),
|
|
|
|
| 13 |
)
|
| 14 |
|
| 15 |
+
# Run analysis and display highlights
|
| 16 |
+
if conversation_text:
|
| 17 |
+
# Segment the conversation based on line breaks
|
| 18 |
+
conversation_segments = conversation_text.split("\n")
|
| 19 |
|
| 20 |
+
# Generate highlight summaries
|
| 21 |
+
highlights = []
|
| 22 |
+
for segment in conversation_segments:
|
| 23 |
+
response = conversation_chain.run(text=segment)
|
| 24 |
+
highlights.extend(response["summaries"])
|
| 25 |
|
| 26 |
+
# Display extracted highlights
|
| 27 |
+
st.header("Extracted Highlights:")
|
| 28 |
+
for highlight in highlights:
|
| 29 |
+
st.write(f"- {highlight}")
|
| 30 |
|
| 31 |
+
else:
|
| 32 |
+
st.write("Please enter the call center conversation to analyze.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|