Spaces:
Sleeping
Sleeping
updated session memory 2
Browse files
app.py
CHANGED
|
@@ -57,6 +57,9 @@ def chat_with_agent(question: str, file_uploads, history: list) -> tuple:
|
|
| 57 |
# Initialize or get session history
|
| 58 |
if session_id not in session_histories:
|
| 59 |
session_histories[session_id] = []
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
# Add the question to both histories immediately
|
| 62 |
history.append({"role": "user", "content": question})
|
|
@@ -104,6 +107,7 @@ def chat_with_agent(question: str, file_uploads, history: list) -> tuple:
|
|
| 104 |
|
| 105 |
# Format the session-specific conversation history
|
| 106 |
conversation_history = format_history_for_agent(session_histories[session_id])
|
|
|
|
| 107 |
|
| 108 |
# Prepare the full context for the agent
|
| 109 |
full_context = {
|
|
|
|
| 57 |
# Initialize or get session history
|
| 58 |
if session_id not in session_histories:
|
| 59 |
session_histories[session_id] = []
|
| 60 |
+
# If we have existing history, add it to the session history
|
| 61 |
+
if history:
|
| 62 |
+
session_histories[session_id].extend(history)
|
| 63 |
|
| 64 |
# Add the question to both histories immediately
|
| 65 |
history.append({"role": "user", "content": question})
|
|
|
|
| 107 |
|
| 108 |
# Format the session-specific conversation history
|
| 109 |
conversation_history = format_history_for_agent(session_histories[session_id])
|
| 110 |
+
print(f"Current conversation history:\n{conversation_history}") # Debug print
|
| 111 |
|
| 112 |
# Prepare the full context for the agent
|
| 113 |
full_context = {
|