mirror of
https://github.com/lfnovo/open-notebook.git
synced 2026-05-05 23:37:58 +00:00
Initial commit with all features
This commit is contained in:
commit
bcd260a28b
52 changed files with 6897 additions and 0 deletions
18
stream_app/utils.py
Normal file
18
stream_app/utils.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import streamlit as st
|
||||
|
||||
from open_notebook.graphs.chat import ThreadState, graph
|
||||
|
||||
|
||||
def setup_stream_state(session_id) -> None:
|
||||
"""
|
||||
Sets the value of the current session_id for langgraph thread state.
|
||||
If there is no existing thread state for this session_id, it creates a new one.
|
||||
"""
|
||||
existing_state = graph.get_state({"configurable": {"thread_id": session_id}}).values
|
||||
if len(existing_state.keys()) == 0:
|
||||
st.session_state[session_id] = ThreadState(
|
||||
messages=[], context=None, notebook=None, context_config={}, response=None
|
||||
)
|
||||
else:
|
||||
st.session_state[session_id] = existing_state
|
||||
st.session_state["active_session"] = session_id
|
||||
Loading…
Add table
Add a link
Reference in a new issue