Initial commit with all features

This commit is contained in:
LUIS NOVO 2024-10-21 14:56:10 -03:00
commit bcd260a28b
52 changed files with 6897 additions and 0 deletions

18
stream_app/utils.py Normal file
View 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