sourize
commited on
Commit
Β·
7c89a46
1
Parent(s):
7278faf
Commit
Browse files
app.py
CHANGED
|
@@ -98,7 +98,9 @@ generator = load_pipeline()
|
|
| 98 |
|
| 99 |
# ββ Streamlit UI ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 100 |
st.set_page_config(layout="centered")
|
| 101 |
-
st.title("π§
|
|
|
|
|
|
|
| 102 |
|
| 103 |
# initialize chat history
|
| 104 |
if "history" not in st.session_state:
|
|
@@ -129,14 +131,15 @@ Assistant:"""
|
|
| 129 |
# generate reply
|
| 130 |
with st.spinner("Thinkingβ¦"):
|
| 131 |
try:
|
| 132 |
-
#
|
| 133 |
-
|
| 134 |
-
#
|
| 135 |
-
reply = raw[len(prompt):].strip()
|
| 136 |
-
# 3) If it ever slurps in "User:" or "Assistant:", cut there
|
| 137 |
for marker in ["User:", "Assistant:"]:
|
| 138 |
if marker in reply:
|
| 139 |
reply = reply.split(marker)[0].strip()
|
|
|
|
|
|
|
|
|
|
| 140 |
except Exception as e:
|
| 141 |
reply = "I'm sorry, something went wrong."
|
| 142 |
st.error(f"Generation error: {e}")
|
|
|
|
| 98 |
|
| 99 |
# ββ Streamlit UI ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 100 |
st.set_page_config(layout="centered")
|
| 101 |
+
st.title("π§ DeepTalks")
|
| 102 |
+
st.subheader("Your personal AI Companion") # Add subheader
|
| 103 |
+
st.markdown("---")
|
| 104 |
|
| 105 |
# initialize chat history
|
| 106 |
if "history" not in st.session_state:
|
|
|
|
| 131 |
# generate reply
|
| 132 |
with st.spinner("Thinkingβ¦"):
|
| 133 |
try:
|
| 134 |
+
# pipeline was set up with `return_full_text=False`, so we get just the reply
|
| 135 |
+
reply = generator(prompt)[0]["generated_text"].strip()
|
| 136 |
+
# strip any accidental echoes
|
|
|
|
|
|
|
| 137 |
for marker in ["User:", "Assistant:"]:
|
| 138 |
if marker in reply:
|
| 139 |
reply = reply.split(marker)[0].strip()
|
| 140 |
+
# if it somehow ends up empty, backstop with an apology
|
| 141 |
+
if not reply:
|
| 142 |
+
reply = "I'm sorry, I didn't catch that. Could you rephrase?"
|
| 143 |
except Exception as e:
|
| 144 |
reply = "I'm sorry, something went wrong."
|
| 145 |
st.error(f"Generation error: {e}")
|