Replies: 3 comments 1 reply
-
I just finished a streamlit-langgchain app which uses persistence although it is not chat based. Mating the two state machines is tricky but doable. The code ihere and the streamlit app can be run from the streamlit cloud here. Note that I did have to add a classmethod to SqliteServer asin my original post so that Streamlit's multiple threads would be tolerated. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Simpler than my approach. Thank you
From: Eugene Yurtsev ***@***.***>
Sent: Thursday, April 11, 2024 4:17 PM
To: langchain-ai/langchain ***@***.***>
Cc: Tom Evslin ***@***.***>; Author ***@***.***>
Subject: Re: [langchain-ai/langchain] need for ability to support check_same_thread=False in SqliteSaver so can deploy langgraph with memory in Streamlit (Discussion #20169)
You can use the initializer directly
saver = SqliteSaver(conn=sqlite3.connect(conn_string, check_same_thread=False))
—
Reply to this email directly, view it on GitHub <#20169 (reply in thread)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AGLSBBUYIHLBAA3ISMGPVXTY43VT7AVCNFSM6AAAAABF5BY3TWVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TAOBYGU3TS> .
You are receiving this because you authored the thread. <https://github.com/notifications/beacon/AGLSBBQVJICZ7GNTLJG7OGLY43VT7A5CNFSM6AAAAABF5BY3TWWGG33NNVSW45C7OR4XAZNRIRUXGY3VONZWS33OINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQARKXEG.gif> Message ID: ***@***.*** ***@***.***> >
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks to both of you! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Checked
Feature request
support check_same_thread=False in SqliteSaver so can deploy langgraph with memory in Streamlit. Can be done either by allowing the parameter directly in SqliteSaver.from_conn_string or adding another class method for this purpose
Motivation
Streamlit is a popular framework for deploying applications and obviously more suitable for broad deployment than Jupyter notebooks. Making the langgraph state machine work with the streamlit state machine is possible altho non-trivial. however, streamlit spawns many threads so, if the sqlite connection is established for memory in one thread, it will invariably get used in another and cause an error. This can be avoided by telling sqlite not to check for same thread; but this sqlite option is not available thru langgraph's SqliteSaver.from_conn_string,
Proposal (If applicable)
below works but is a kluge:
def from_conn_stringx(cls, conn_string: str,) -> "SqliteSaver":
return SqliteSaver(conn=sqlite3.connect(conn_string, check_same_thread=False))
SqliteSaver.from_conn_stringx=classmethod(from_conn_stringx)
self.memory = SqliteSaver.from_conn_stringx(":memory:")
Beta Was this translation helpful? Give feedback.
All reactions