Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -124,10 +124,11 @@ def get_response(system_message, chat_history, user_text, max_new_tokens=512):
|
|
| 124 |
filtered_history = "\n".join(f"{msg['role']}: {msg['content']}" for msg in chat_history)
|
| 125 |
|
| 126 |
prompt = PromptTemplate.from_template(
|
| 127 |
-
"[INST]
|
| 128 |
"User: {user_text}.\n [/INST]\n"
|
| 129 |
-
"AI: Provide a detailed explanation. Use a conversational tone. "
|
| 130 |
"π¨ Answer **only in English**."
|
|
|
|
| 131 |
"\nHAL:"
|
| 132 |
)
|
| 133 |
|
|
@@ -142,13 +143,14 @@ def get_response(system_message, chat_history, user_text, max_new_tokens=512):
|
|
| 142 |
|
| 143 |
follow_up = generate_follow_up(user_text)
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
])
|
| 150 |
|
| 151 |
-
return response, follow_up
|
|
|
|
|
|
|
| 152 |
|
| 153 |
# β
Streamlit UI
|
| 154 |
st.title("π HAL - NASA AI Assistant")
|
|
|
|
| 124 |
filtered_history = "\n".join(f"{msg['role']}: {msg['content']}" for msg in chat_history)
|
| 125 |
|
| 126 |
prompt = PromptTemplate.from_template(
|
| 127 |
+
"[INST] You are a helpful AI assistant.\n\nCurrent Conversation:\n{chat_history}\n\n"
|
| 128 |
"User: {user_text}.\n [/INST]\n"
|
| 129 |
+
"AI: Provide a detailed explanation with depth. Use a conversational tone. "
|
| 130 |
"π¨ Answer **only in English**."
|
| 131 |
+
"Ensure a friendly, engaging tone."
|
| 132 |
"\nHAL:"
|
| 133 |
)
|
| 134 |
|
|
|
|
| 143 |
|
| 144 |
follow_up = generate_follow_up(user_text)
|
| 145 |
|
| 146 |
+
# β
Preserve conversation history
|
| 147 |
+
st.session_state.chat_history.append({'role': 'user', 'content': user_text})
|
| 148 |
+
st.session_state.chat_history.append({'role': 'assistant', 'content': response})
|
| 149 |
+
st.session_state.chat_history.append({'role': 'assistant', 'content': follow_up})
|
|
|
|
| 150 |
|
| 151 |
+
return response, follow_up
|
| 152 |
+
|
| 153 |
+
#return response, follow_up, chat_history, None
|
| 154 |
|
| 155 |
# β
Streamlit UI
|
| 156 |
st.title("π HAL - NASA AI Assistant")
|