@@ -83,35 +83,35 @@ def execute(self, state: dict) -> dict:
83
83
84
84
# Use tqdm to add progress bar
85
85
for i , chunk in enumerate (tqdm (doc , desc = "Processing chunks" , disable = not self .verbose )):
86
- if self .node_config [ "schema" ] is None and len (doc ) == 1 :
86
+ if self .node_config ( "schema" , None ) is None and len (doc ) == 1 :
87
87
prompt = PromptTemplate (
88
88
template = template_no_chunks ,
89
89
input_variables = ["question" ],
90
90
partial_variables = {"context" : chunk .page_content ,
91
91
"format_instructions" : format_instructions })
92
- elif self .node_config [ "schema" ] is not None and len (doc ) == 1 :
92
+ elif self .node_config ( "schema" , None ) is not None and len (doc ) == 1 :
93
93
prompt = PromptTemplate (
94
94
template = template_no_chunks_with_schema ,
95
95
input_variables = ["question" ],
96
96
partial_variables = {"context" : chunk .page_content ,
97
97
"format_instructions" : format_instructions ,
98
- "schema" : self .node_config [ "schema" ]
98
+ "schema" : self .node_config ( "schema" , None )
99
99
})
100
- elif self .node_config [ "schema" ] is None and len (doc ) > 1 :
100
+ elif self .node_config ( "schema" , None ) is None and len (doc ) > 1 :
101
101
prompt = PromptTemplate (
102
102
template = template_chunks ,
103
103
input_variables = ["question" ],
104
104
partial_variables = {"context" : chunk .page_content ,
105
105
"chunk_id" : i + 1 ,
106
106
"format_instructions" : format_instructions })
107
- elif self .node_config [ "schema" ] is not None and len (doc ) > 1 :
107
+ elif self .node_config ( "schema" , None ) is not None and len (doc ) > 1 :
108
108
prompt = PromptTemplate (
109
109
template = template_chunks_with_schema ,
110
110
input_variables = ["question" ],
111
111
partial_variables = {"context" : chunk .page_content ,
112
112
"chunk_id" : i + 1 ,
113
113
"format_instructions" : format_instructions ,
114
- "schema" : self .node_config [ "schema" ] })
114
+ "schema" : self .node_config ( "schema" , None ) })
115
115
116
116
# Dynamically name the chains based on their index
117
117
chain_name = f"chunk{ i + 1 } "
0 commit comments