@@ -150,44 +150,32 @@ def _init_workflow(self) -> Workflow:
150150 The built workflow ready to execute.
151151 """
152152
153+ # Create executor instances
154+ document_processing = DocumentProcessExecutor (
155+ id = "document_processing" , app_context = self .app_context
156+ )
157+ rai_analysis = RAIExecutor (id = "rai_analysis" , app_context = self .app_context )
158+ summarizing = SummarizeExecutor (id = "summarizing" , app_context = self .app_context )
159+ gap_analysis = GapExecutor (id = "gap_analysis" , app_context = self .app_context )
160+
153161 workflow = (
154- WorkflowBuilder (start_executor = "document_processing" )
155- .register_executor (
156- lambda : DocumentProcessExecutor (
157- id = "document_processing" , app_context = self .app_context
158- ),
159- name = "document_processing" ,
160- )
161- .register_executor (
162- lambda : RAIExecutor (id = "rai_analysis" , app_context = self .app_context ),
163- name = "rai_analysis" ,
164- )
165- .register_executor (
166- lambda : SummarizeExecutor (
167- id = "summarizing" , app_context = self .app_context
168- ),
169- name = "summarizing" ,
170- )
171- .register_executor (
172- lambda : GapExecutor (id = "gap_analysis" , app_context = self .app_context ),
173- name = "gap_analysis" ,
174- )
162+ WorkflowBuilder (start_executor = document_processing )
175163 # Edges define the execution flow and can include conditions for branching logic.
176164 # In this case, we conditionally branch to the RAI analysis step based on the
177165 # application configuration, allowing it to be toggled on/off without code changes.
178166 .add_edge (
179- source = " document_processing" ,
180- target = " rai_analysis" ,
167+ source = document_processing ,
168+ target = rai_analysis ,
181169 condition = lambda _ : self .app_context .configuration .app_rai_enabled ,
182170 )
183- .add_edge (source = " rai_analysis" , target = " summarizing" )
171+ .add_edge (source = rai_analysis , target = summarizing )
184172 # If RAI analysis is disabled, the summarizing step will execute immediately after document processing
185173 .add_edge (
186- source = " document_processing" ,
187- target = " summarizing" ,
174+ source = document_processing ,
175+ target = summarizing ,
188176 condition = lambda _ : not self .app_context .configuration .app_rai_enabled ,
189177 )
190- .add_edge (source = " summarizing" , target = " gap_analysis" )
178+ .add_edge (source = summarizing , target = gap_analysis )
191179 .build ()
192180 )
193181
0 commit comments