Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -65,27 +65,29 @@ def simulate_conversation(chain: LLMChain, name1: str, name2: str, total_message
|
|
65 |
return None
|
66 |
|
67 |
def summarize_conversation(chain: LLMChain, conversation: str, name1: str, name2: str):
|
|
|
68 |
st.write("**Summarizing the conversation...**")
|
69 |
print("Summarizing the conversation...")
|
70 |
|
|
|
71 |
summary_prompt = f"""
|
72 |
The following is a conversation between {name1} and {name2}:
|
73 |
{conversation}
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
Summary: <your summary here>
|
80 |
"""
|
81 |
|
82 |
try:
|
83 |
response = chain.run(chat_history="", input=summary_prompt)
|
|
|
84 |
return response.strip()
|
85 |
except Exception as e:
|
86 |
st.error(f"Error summarizing conversation: {e}")
|
87 |
print(f"Error summarizing conversation: {e}")
|
88 |
-
return "No summary available due to error."
|
89 |
|
90 |
def main():
|
91 |
st.title("LLM Conversation Simulation")
|
|
|
65 |
return None
|
66 |
|
67 |
def summarize_conversation(chain: LLMChain, conversation: str, name1: str, name2: str):
|
68 |
+
"""Use the LLM to summarize the completed conversation and provide a title."""
|
69 |
st.write("**Summarizing the conversation...**")
|
70 |
print("Summarizing the conversation...")
|
71 |
|
72 |
+
# Updated prompt to clearly request a title and summary in the desired format
|
73 |
summary_prompt = f"""
|
74 |
The following is a conversation between {name1} and {name2}:
|
75 |
{conversation}
|
76 |
|
77 |
+
Please provide:
|
78 |
+
- A short and descriptive title of the conversation on one line, starting with "Title:".
|
79 |
+
- A summary of the conversation on the next line, starting with "Summary:".
|
80 |
+
The summary should be a few short sentences highlighting the main points, tone, and conclusion.
|
|
|
81 |
"""
|
82 |
|
83 |
try:
|
84 |
response = chain.run(chat_history="", input=summary_prompt)
|
85 |
+
# Just return the response as-is. The model should follow the instructions given.
|
86 |
return response.strip()
|
87 |
except Exception as e:
|
88 |
st.error(f"Error summarizing conversation: {e}")
|
89 |
print(f"Error summarizing conversation: {e}")
|
90 |
+
return "Title: No Title\nSummary: No summary available due to error."
|
91 |
|
92 |
def main():
|
93 |
st.title("LLM Conversation Simulation")
|