Is it possible to cancel an invoked graph #32343
snedev-lime
started this conversation in
General
Replies: 1 comment
-
^ bump |
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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have the following setup:
final_state = await graph.ainvoke(initial_state)
which goes into the loop, picks some tools makes calls to OpenAI and so on, and at the end I stream back the result to the client by:
async for chunk in self.llm.astream(final_messages):
yield chunk.content
and this is all done thru a websocket, so my question is there a way for me to handle the case when an user closes the window or clicks Stop Generating, to stop the ainvoke process? I saw that there was an approach for this but just for JS, is there something for Python, or achieve this in some way, tips and things to look at would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions