Fix import issue in app.py by using session_manager instead of non-existent get_conversation_history
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ sys.path.append(str(Path(__file__).parent))
|
|
| 7 |
|
| 8 |
from utils.config import config
|
| 9 |
from core.llm import send_to_ollama, send_to_hf
|
| 10 |
-
from core.
|
| 11 |
|
| 12 |
st.set_page_config(page_title="AI Life Coach", page_icon="🧠", layout="wide")
|
| 13 |
|
|
@@ -79,7 +79,8 @@ if send_button and user_input.strip():
|
|
| 79 |
st.session_state.messages.append({"role": "user", "content": user_input})
|
| 80 |
|
| 81 |
# Get conversation history
|
| 82 |
-
|
|
|
|
| 83 |
conversation_history = conversation[-5:] # Last 5 messages
|
| 84 |
conversation_history.append({"role": "user", "content": user_input})
|
| 85 |
|
|
@@ -111,6 +112,10 @@ if send_button and user_input.strip():
|
|
| 111 |
conversation.append({"role": "user", "content": user_input})
|
| 112 |
conversation.append({"role": "assistant", "content": ai_response})
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
# Add assistant response to history
|
| 115 |
st.session_state.messages.append({"role": "assistant", "content": ai_response})
|
| 116 |
else:
|
|
|
|
| 7 |
|
| 8 |
from utils.config import config
|
| 9 |
from core.llm import send_to_ollama, send_to_hf
|
| 10 |
+
from core.session import session_manager
|
| 11 |
|
| 12 |
st.set_page_config(page_title="AI Life Coach", page_icon="🧠", layout="wide")
|
| 13 |
|
|
|
|
| 79 |
st.session_state.messages.append({"role": "user", "content": user_input})
|
| 80 |
|
| 81 |
# Get conversation history
|
| 82 |
+
user_session = session_manager.get_session("default_user")
|
| 83 |
+
conversation = user_session.get("conversation", [])
|
| 84 |
conversation_history = conversation[-5:] # Last 5 messages
|
| 85 |
conversation_history.append({"role": "user", "content": user_input})
|
| 86 |
|
|
|
|
| 112 |
conversation.append({"role": "user", "content": user_input})
|
| 113 |
conversation.append({"role": "assistant", "content": ai_response})
|
| 114 |
|
| 115 |
+
# Update session
|
| 116 |
+
user_session["conversation"] = conversation
|
| 117 |
+
session_manager.save_session("default_user", user_session)
|
| 118 |
+
|
| 119 |
# Add assistant response to history
|
| 120 |
st.session_state.messages.append({"role": "assistant", "content": ai_response})
|
| 121 |
else:
|