Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,13 +11,15 @@ if "chat_history" not in st.session_state:
|
|
| 11 |
st.session_state.chat_history = [] # Each item is a dict: {"role": "user"/"assistant", "content": "..."}
|
| 12 |
|
| 13 |
def render_assistant_history():
|
| 14 |
-
"""Render only the assistant responses from the conversation history."""
|
| 15 |
chat_container = st.container()
|
| 16 |
chat_md = ""
|
| 17 |
for msg in st.session_state.chat_history:
|
| 18 |
if msg["role"] == "assistant":
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
|
| 22 |
st.title("Conversation Script Generator Using Groq API")
|
| 23 |
|
|
@@ -40,7 +42,7 @@ is_ready = bool(theme and left_speaker and right_speaker and contact_name)
|
|
| 40 |
|
| 41 |
if st.button("Generate Conversation", disabled=not is_ready):
|
| 42 |
prompt = f"""
|
| 43 |
-
|
| 44 |
syntax and should be diverse and creative
|
| 45 |
Script Structure & Formatting Rules
|
| 46 |
1️ Contact Name (Title)
|
|
@@ -165,7 +167,6 @@ for left ones
|
|
| 165 |
Right Speaker: {right_speaker}
|
| 166 |
Right: {right_speaker}>
|
| 167 |
for right ones
|
| 168 |
-
|
| 169 |
"""
|
| 170 |
if additional_details.strip():
|
| 171 |
prompt += f"\nAdditional Details: {additional_details}\n"
|
|
|
|
| 11 |
st.session_state.chat_history = [] # Each item is a dict: {"role": "user"/"assistant", "content": "..."}
|
| 12 |
|
| 13 |
def render_assistant_history():
|
| 14 |
+
"""Render only the assistant responses from the conversation history with proper line breaks."""
|
| 15 |
chat_container = st.container()
|
| 16 |
chat_md = ""
|
| 17 |
for msg in st.session_state.chat_history:
|
| 18 |
if msg["role"] == "assistant":
|
| 19 |
+
# Replace newline characters with <br> for proper line breaks in markdown.
|
| 20 |
+
formatted_content = msg["content"].replace("\n", "<br>")
|
| 21 |
+
chat_md += f"**Assistant:**<br>{formatted_content}<br><br>"
|
| 22 |
+
chat_container.markdown(chat_md, unsafe_allow_html=True)
|
| 23 |
|
| 24 |
st.title("Conversation Script Generator Using Groq API")
|
| 25 |
|
|
|
|
| 42 |
|
| 43 |
if st.button("Generate Conversation", disabled=not is_ready):
|
| 44 |
prompt = f"""
|
| 45 |
+
Youe Task is to generate an engaging script which is a conversation between two people on iMessage for meme purposes.. It should strictly follow a given
|
| 46 |
syntax and should be diverse and creative
|
| 47 |
Script Structure & Formatting Rules
|
| 48 |
1️ Contact Name (Title)
|
|
|
|
| 167 |
Right Speaker: {right_speaker}
|
| 168 |
Right: {right_speaker}>
|
| 169 |
for right ones
|
|
|
|
| 170 |
"""
|
| 171 |
if additional_details.strip():
|
| 172 |
prompt += f"\nAdditional Details: {additional_details}\n"
|