@@ -163,17 +163,29 @@ export function bindOutputSchema<T extends Runnable>(loadedSequence: T) {
163
163
"schema" in loadedSequence . first &&
164
164
"last" in loadedSequence &&
165
165
loadedSequence . last !== null &&
166
- typeof loadedSequence . last === "object" &&
167
- "bound" in loadedSequence . last &&
168
- loadedSequence . last . bound !== null &&
169
- typeof loadedSequence . last . bound === "object" &&
170
- "withStructuredOutput" in loadedSequence . last . bound &&
171
- typeof loadedSequence . last . bound . withStructuredOutput === "function"
166
+ typeof loadedSequence . last === "object"
172
167
) {
173
- // eslint-disable-next-line no-param-reassign
174
- loadedSequence . last . bound = loadedSequence . last . bound . withStructuredOutput (
175
- loadedSequence . first . schema
176
- ) ;
168
+ if (
169
+ "bound" in loadedSequence . last &&
170
+ loadedSequence . last . bound !== null &&
171
+ typeof loadedSequence . last . bound === "object" &&
172
+ "withStructuredOutput" in loadedSequence . last . bound &&
173
+ typeof loadedSequence . last . bound . withStructuredOutput === "function"
174
+ ) {
175
+ // eslint-disable-next-line no-param-reassign
176
+ loadedSequence . last . bound =
177
+ loadedSequence . last . bound . withStructuredOutput (
178
+ loadedSequence . first . schema
179
+ ) ;
180
+ } else if (
181
+ "withStructuredOutput" in loadedSequence . last &&
182
+ typeof loadedSequence . last . withStructuredOutput === "function"
183
+ ) {
184
+ // eslint-disable-next-line no-param-reassign
185
+ loadedSequence . last = loadedSequence . last . withStructuredOutput (
186
+ loadedSequence . first . schema
187
+ ) ;
188
+ }
177
189
}
178
190
return loadedSequence ;
179
191
}
0 commit comments