Julia Ostheimer
commited on
Commit
·
6e72fd0
1
Parent(s):
353eb66
Make chat_history only available for each session by invoking agent with unique session_hash
Browse files
app.py
CHANGED
|
@@ -102,7 +102,7 @@ graph_builder.add_edge("generate", END)
|
|
| 102 |
graph = graph_builder.compile(checkpointer=memory)
|
| 103 |
# -----
|
| 104 |
|
| 105 |
-
def bot(message, history, source_history) -> list[Any]:
|
| 106 |
"""Generate bot response and history from message.
|
| 107 |
|
| 108 |
With multi-modal inputs text and each file is treated as separate message.
|
|
@@ -120,9 +120,11 @@ def bot(message, history, source_history) -> list[Any]:
|
|
| 120 |
ingest_document(file, vector_store)
|
| 121 |
|
| 122 |
# create text response
|
| 123 |
-
# TODO: see how state can be set in chat interface
|
| 124 |
user_input_prompt = message.get("text")
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
response = graph.invoke(
|
| 128 |
{"messages": [{"role": "user", "content": user_input_prompt}]},
|
|
|
|
| 102 |
graph = graph_builder.compile(checkpointer=memory)
|
| 103 |
# -----
|
| 104 |
|
| 105 |
+
def bot(message, history, source_history, request: gr.Request) -> list[Any]:
|
| 106 |
"""Generate bot response and history from message.
|
| 107 |
|
| 108 |
With multi-modal inputs text and each file is treated as separate message.
|
|
|
|
| 120 |
ingest_document(file, vector_store)
|
| 121 |
|
| 122 |
# create text response
|
|
|
|
| 123 |
user_input_prompt = message.get("text")
|
| 124 |
+
current_session_id = request.session_hash
|
| 125 |
+
logger.info("This is the current session id", session_id=current_session_id)
|
| 126 |
+
|
| 127 |
+
config = {"configurable": {"thread_id": current_session_id}, "callbacks": [langfuse_handler], "stream": False}
|
| 128 |
|
| 129 |
response = graph.invoke(
|
| 130 |
{"messages": [{"role": "user", "content": user_input_prompt}]},
|