File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed
llama-index-integrations/protocols/llama-index-protocols-ag-ui
llama_index/protocols/ag_ui Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 1212from llama_index .core .workflow .events import Event , StartEvent , StopEvent
1313from llama_index .protocols .ag_ui .events import (
1414 MessagesSnapshotWorkflowEvent ,
15+ StateSnapshotWorkflowEvent ,
1516 TextMessageChunkWorkflowEvent ,
1617 ToolCallChunkWorkflowEvent ,
1718)
@@ -134,6 +135,7 @@ async def chat(
134135
135136 # Save state to context for tools to use
136137 await ctx .store .set ("state" , state )
138+ ctx .write_event_to_stream (StateSnapshotWorkflowEvent (snapshot = state ))
137139
138140 if state :
139141 for msg in chat_history [::- 1 ]:
@@ -250,6 +252,13 @@ async def handle_tool_call(
250252 kwargs [tool .ctx_param_name ] = ctx
251253
252254 tool_output = await tool .acall (** kwargs )
255+
256+ # Update the state snapshot
257+ current_state = await ctx .store .get ("state" , default = {})
258+ ctx .write_event_to_stream (
259+ StateSnapshotWorkflowEvent (snapshot = current_state )
260+ )
261+
253262 return ToolCallResultEvent (
254263 tool_call_id = ev .tool_call_id ,
255264 tool_name = ev .tool_name ,
Original file line number Diff line number Diff line change @@ -75,10 +75,6 @@ async def stream_response():
7575 # Finish the run
7676 _ = await handler
7777
78- # Update the state
79- state = await handler .ctx .store .get ("state" , default = {})
80- yield workflow_event_to_sse (StateSnapshotWorkflowEvent (snapshot = state ))
81-
8278 yield workflow_event_to_sse (
8379 RunFinishedWorkflowEvent (
8480 timestamp = timestamp (),
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ dev = [
2828
2929[project ]
3030name = " llama-index-protocols-ag-ui"
31- version = " 0.2.1 "
31+ version = " 0.2.2 "
3232description = " llama-index protocols AG-UI integration"
3333authors = [
3434 {
name =
" Logan Markewich" ,
email =
" [email protected] " },
You can’t perform that action at this time.
0 commit comments