Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -134,30 +134,6 @@ def get_response(system_message, chat_history, user_text, max_new_tokens=256):
|
|
134 |
)
|
135 |
)
|
136 |
|
137 |
-
# Debug: Output the prompt being sent (for troubleshooting)
|
138 |
-
st.write("DEBUG: Prompt sent to language model:")
|
139 |
-
st.write(prompt.format(system_message=system_message, chat_history=filtered_history, user_text=user_text))
|
140 |
-
|
141 |
-
chat = prompt | hf.bind(skip_prompt=True) | StrOutputParser(output_key='content')
|
142 |
-
response = chat.invoke(input=dict(system_message=system_message, user_text=user_text, chat_history=filtered_history))
|
143 |
-
response = response.split("HAL:")[-1].strip()
|
144 |
-
if not response:
|
145 |
-
response = "Certainly, here is an in-depth explanation: [Fallback explanation]."
|
146 |
-
|
147 |
-
chat_history.append({'role': 'user', 'content': user_text})
|
148 |
-
chat_history.append({'role': 'assistant', 'content': response})
|
149 |
-
|
150 |
-
if sentiment == "NEGATIVE" and not user_text.strip().endswith("?"):
|
151 |
-
response = "I'm sorry you're feeling this way. I'm here to help. What can I do to assist you further?"
|
152 |
-
chat_history[-1]['content'] = response
|
153 |
-
|
154 |
-
follow_up = generate_follow_up(user_text)
|
155 |
-
chat_history.append({'role': 'assistant', 'content': follow_up})
|
156 |
-
|
157 |
-
# Debug: Output generated follow-up for troubleshooting.
|
158 |
-
st.write("DEBUG: Generated follow-up question:", follow_up)
|
159 |
-
|
160 |
-
return response, follow_up, chat_history, None
|
161 |
|
162 |
# --- Chat UI ---
|
163 |
st.title("🚀 HAL - Your NASA AI Assistant")
|
|
|
134 |
)
|
135 |
)
|
136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
# --- Chat UI ---
|
139 |
st.title("🚀 HAL - Your NASA AI Assistant")
|