@@ -93,35 +93,20 @@ def execute(self, state: dict) -> dict:
93
93
94
94
# Use tqdm to add progress bar
95
95
for i , chunk in enumerate (tqdm (doc , desc = "Processing chunks" , disable = not self .verbose )):
96
- if self . node_config . get ( "schema" , None ) is None and len (doc ) == 1 :
96
+ if len (doc ) == 1 :
97
97
prompt = PromptTemplate (
98
98
template = template_no_chunks ,
99
99
input_variables = ["question" ],
100
100
partial_variables = {"context" : chunk .page_content ,
101
101
"format_instructions" : format_instructions })
102
- elif self .node_config .get ("schema" , None ) is not None and len (doc ) == 1 :
103
- prompt = PromptTemplate (
104
- template = template_no_chunks_with_schema ,
105
- input_variables = ["question" ],
106
- partial_variables = {"context" : chunk .page_content ,
107
- "format_instructions" : format_instructions ,
108
- "schema" : self .node_config .get ("schema" , None )
109
- })
110
- elif self .node_config .get ("schema" , None ) is None and len (doc ) > 1 :
102
+
103
+ else :
111
104
prompt = PromptTemplate (
112
105
template = template_chunks ,
113
106
input_variables = ["question" ],
114
107
partial_variables = {"context" : chunk .page_content ,
115
108
"chunk_id" : i + 1 ,
116
109
"format_instructions" : format_instructions })
117
- elif self .node_config .get ("schema" , None ) is not None and len (doc ) > 1 :
118
- prompt = PromptTemplate (
119
- template = template_chunks_with_schema ,
120
- input_variables = ["question" ],
121
- partial_variables = {"context" : chunk .page_content ,
122
- "chunk_id" : i + 1 ,
123
- "format_instructions" : format_instructions ,
124
- "schema" : self .node_config .get ("schema" , None )})
125
110
126
111
# Dynamically name the chains based on their index
127
112
chain_name = f"chunk{ i + 1 } "
@@ -147,4 +132,4 @@ def execute(self, state: dict) -> dict:
147
132
148
133
# Update the state with the generated answer
149
134
state .update ({self .output [0 ]: answer })
150
- return state
135
+ return state
0 commit comments