(returnIds: ICommonObject, output: string | object, shutdown = false)
| 1150 | } |
| 1151 | |
| 1152 | async onChainEnd(returnIds: ICommonObject, output: string | object, shutdown = false) { |
| 1153 | if (Object.prototype.hasOwnProperty.call(this.handlers, 'langSmith')) { |
| 1154 | const chainRun: RunTree | undefined = this.handlers['langSmith'].chainRun[returnIds['langSmith'].chainRun] |
| 1155 | if (chainRun) { |
| 1156 | await chainRun.end({ |
| 1157 | outputs: { |
| 1158 | output |
| 1159 | } |
| 1160 | }) |
| 1161 | await chainRun.patchRun() |
| 1162 | } |
| 1163 | } |
| 1164 | |
| 1165 | if (Object.prototype.hasOwnProperty.call(this.handlers, 'langFuse')) { |
| 1166 | const span: LangfuseSpanClient | undefined = this.handlers['langFuse'].span[returnIds['langFuse'].span] |
| 1167 | if (span) { |
| 1168 | span.end({ |
| 1169 | output |
| 1170 | }) |
| 1171 | const langfuseTraceClient = this.handlers['langFuse'].trace[returnIds['langFuse'].trace] |
| 1172 | if (langfuseTraceClient) { |
| 1173 | langfuseTraceClient.update({ |
| 1174 | output: { |
| 1175 | output |
| 1176 | } |
| 1177 | }) |
| 1178 | } |
| 1179 | if (shutdown) { |
| 1180 | const langfuse: Langfuse = this.handlers['langFuse'].client |
| 1181 | await langfuse.shutdownAsync() |
| 1182 | } |
| 1183 | } |
| 1184 | } |
| 1185 | |
| 1186 | if (Object.prototype.hasOwnProperty.call(this.handlers, 'lunary')) { |
| 1187 | const chainEventId = returnIds['lunary'].chainEvent |
| 1188 | const monitor = this.handlers['lunary'].client |
| 1189 | |
| 1190 | if (monitor && chainEventId) { |
| 1191 | await monitor.trackEvent('chain', 'end', { |
| 1192 | runId: chainEventId, |
| 1193 | output |
| 1194 | }) |
| 1195 | } |
| 1196 | } |
| 1197 | |
| 1198 | if (Object.prototype.hasOwnProperty.call(this.handlers, 'langWatch')) { |
| 1199 | const span: LangWatchSpan | undefined = this.handlers['langWatch'].span[returnIds['langWatch'].span] |
| 1200 | if (span) { |
| 1201 | span.end({ |
| 1202 | output: autoconvertTypedValues(output) |
| 1203 | }) |
| 1204 | } |
| 1205 | } |
| 1206 | |
| 1207 | if (Object.prototype.hasOwnProperty.call(this.handlers, 'arize')) { |
| 1208 | const chainSpan: Span | undefined = this.handlers['arize'].chainSpan[returnIds['arize'].chainSpan] |
| 1209 | if (chainSpan) { |
no test coverage detected