sourize commited on
Commit
7c89a46
Β·
1 Parent(s): 7278faf
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -98,7 +98,9 @@ generator = load_pipeline()
98
 
99
  # ── Streamlit UI ──────────────────────────────────────────────────────────
100
  st.set_page_config(layout="centered")
101
- st.title("🧠 Memory-Aware Phi-2 Chat")
 
 
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
- # 1) raw generation
133
- raw = generator(prompt)[0]["generated_text"]
134
- # 2) Remove the prompt prefix (so you only see new content)
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}")