@@ -4,6 +4,7 @@ import { Logger } from 'winston'
4
4
import { Server } from 'socket.io'
5
5
import { Client } from 'langsmith'
6
6
import { LangChainTracer } from 'langchain/callbacks'
7
+ import { LLMonitorHandler } from 'langchain/callbacks/handlers/llmonitor'
7
8
import { getCredentialData , getCredentialParam } from './utils'
8
9
import { ICommonObject , INodeData } from './Interface'
9
10
import CallbackHandler from 'langfuse-langchain'
@@ -194,11 +195,11 @@ export const additionalCallbacks = async (nodeData: INodeData, options: ICommonO
194
195
for ( const provider in analytic ) {
195
196
const providerStatus = analytic [ provider ] . status as boolean
196
197
if ( providerStatus ) {
198
+ const credentialId = analytic [ provider ] . credentialId as string
199
+ const credentialData = await getCredentialData ( credentialId ?? '' , options )
197
200
if ( provider === 'langSmith' ) {
198
- const credentialId = analytic [ provider ] . credentialId as string
199
201
const langSmithProject = analytic [ provider ] . projectName as string
200
202
201
- const credentialData = await getCredentialData ( credentialId ?? '' , options )
202
203
const langSmithApiKey = getCredentialParam ( 'langSmithApiKey' , credentialData , nodeData )
203
204
const langSmithEndpoint = getCredentialParam ( 'langSmithEndpoint' , credentialData , nodeData )
204
205
@@ -214,13 +215,11 @@ export const additionalCallbacks = async (nodeData: INodeData, options: ICommonO
214
215
} )
215
216
callbacks . push ( tracer )
216
217
} else if ( provider === 'langFuse' ) {
217
- const credentialId = analytic [ provider ] . credentialId as string
218
218
const flushAt = analytic [ provider ] . flushAt as string
219
219
const flushInterval = analytic [ provider ] . flushInterval as string
220
220
const requestTimeout = analytic [ provider ] . requestTimeout as string
221
221
const release = analytic [ provider ] . release as string
222
222
223
- const credentialData = await getCredentialData ( credentialId ?? '' , options )
224
223
const langFuseSecretKey = getCredentialParam ( 'langFuseSecretKey' , credentialData , nodeData )
225
224
const langFusePublicKey = getCredentialParam ( 'langFusePublicKey' , credentialData , nodeData )
226
225
const langFuseEndpoint = getCredentialParam ( 'langFuseEndpoint' , credentialData , nodeData )
@@ -237,6 +236,17 @@ export const additionalCallbacks = async (nodeData: INodeData, options: ICommonO
237
236
238
237
const handler = new CallbackHandler ( langFuseOptions )
239
238
callbacks . push ( handler )
239
+ } else if ( provider === 'llmonitor' ) {
240
+ const llmonitorAppId = getCredentialParam ( 'llmonitorAppId' , credentialData , nodeData )
241
+ const llmonitorEndpoint = getCredentialParam ( 'llmonitorEndpoint' , credentialData , nodeData )
242
+
243
+ const llmonitorFields : ICommonObject = {
244
+ appId : llmonitorAppId ,
245
+ apiUrl : llmonitorEndpoint ?? 'https://app.llmonitor.com'
246
+ }
247
+
248
+ const handler = new LLMonitorHandler ( llmonitorFields )
249
+ callbacks . push ( handler )
240
250
}
241
251
}
242
252
}
0 commit comments