CCockrum commited on
Commit
f77e366
Β·
verified Β·
1 Parent(s): e653ea8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
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] {system_message}\n\nCurrent Conversation:\n{chat_history}\n\n"
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
- chat_history.extend([
146
- {'role': 'user', 'content': user_text},
147
- {'role': 'assistant', 'content': response},
148
- {'role': 'assistant', 'content': follow_up}
149
- ])
150
 
151
- return response, follow_up, chat_history, None
 
 
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")