File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
backend/retrieval_graph/researcher_graph Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change 1010from langchain_core .runnables import RunnableConfig
1111from langgraph .constants import Send
1212from langgraph .graph import END , START , StateGraph
13+ from langgraph .config import get_stream_writer
1314from typing_extensions import TypedDict
1415
1516from backend import retrieval
@@ -67,8 +68,10 @@ async def retrieve_documents(
6768 Returns:
6869 dict[str, list[Document]]: A dictionary with a 'documents' key containing the list of retrieved documents.
6970 """
71+ writer = get_stream_writer ()
7072 with retrieval .make_retriever (config ) as retriever :
7173 response = await retriever .ainvoke (state .query , config )
74+ writer ({"retrieve_documents" : {"index" : state .index , "documents" : response }})
7275 return {"documents" : response }
7376
7477
Original file line number Diff line number Diff line change @@ -826,6 +826,9 @@ export function GraphProvider({ children }: { children: ReactNode }) {
826826 }
827827 } ,
828828 onUpdateEvent : handleUpdateEvent ,
829+ onCustomEvent : ( event ) => {
830+ console . log ( "Custom event" , event ) ;
831+ } ,
829832 onFinish : async ( state , meta ) => {
830833 setIsStreaming ( false ) ;
831834 const currentState = streamStateRef . current ;
@@ -1092,7 +1095,7 @@ export function GraphProvider({ children }: { children: ReactNode }) {
10921095 metadata : userId ? { user_id : userId } : undefined ,
10931096 streamResumable : true ,
10941097 onDisconnect : "continue" ,
1095- streamMode : [ "messages" , "messages -tuple", "updates " ] ,
1098+ streamMode : [ "messages-tuple" , "custom " ] ,
10961099 } ,
10971100 ) ;
10981101 } catch ( error ) {
You can’t perform that action at this time.
0 commit comments