MCPcopy
hub / github.com/FlowiseAI/Flowise / additionalCallbacks

Function additionalCallbacks

packages/components/src/handler.ts:516–690  ·  view source on GitHub ↗
(nodeData: INodeData, options: ICommonObject)

Source from the content-addressed store, hash-verified

514}
515
516export const additionalCallbacks = async (nodeData: INodeData, options: ICommonObject) => {
517 try {
518 if (!options.analytic && !tracingEnvEnabled()) return []
519
520 const initial = options.analytic ? JSON.parse(options.analytic) : {}
521 const { analytic, envCredentials } = applyEnvTracingProviders(initial)
522 const callbacks: any = []
523
524 for (const provider in analytic) {
525 const providerStatus = analytic[provider].status as boolean
526 if (providerStatus) {
527 const credentialData =
528 envCredentials[provider] ?? (await getCredentialData((analytic[provider].credentialId as string) ?? '', options))
529 if (provider === 'langSmith') {
530 const langSmithProject = analytic[provider].projectName as string
531
532 const langSmithApiKey = getCredentialParam('langSmithApiKey', credentialData, nodeData)
533 const langSmithEndpoint = getCredentialParam('langSmithEndpoint', credentialData, nodeData)
534
535 const client = new Client({
536 apiUrl: langSmithEndpoint ?? 'https://api.smith.langchain.com',
537 apiKey: langSmithApiKey
538 })
539
540 let langSmithField: LangChainTracerFields = {
541 projectName: langSmithProject ?? 'default',
542 //@ts-ignore
543 client
544 }
545
546 if (nodeData?.inputs?.analytics?.langSmith) {
547 langSmithField = { ...langSmithField, ...nodeData?.inputs?.analytics?.langSmith }
548 }
549
550 const tracer = new LangChainTracer(langSmithField)
551 callbacks.push(tracer)
552 } else if (provider === 'langFuse') {
553 const release = analytic[provider].release as string
554
555 const langFuseSecretKey = getCredentialParam('langFuseSecretKey', credentialData, nodeData)
556 const langFusePublicKey = getCredentialParam('langFusePublicKey', credentialData, nodeData)
557 const langFuseEndpoint = getCredentialParam('langFuseEndpoint', credentialData, nodeData)
558
559 let langFuseOptions: any = {
560 secretKey: langFuseSecretKey,
561 publicKey: langFusePublicKey,
562 baseUrl: langFuseEndpoint ?? 'https://cloud.langfuse.com',
563 sdkIntegration: 'Flowise'
564 }
565 if (release) langFuseOptions.release = release
566 if (options.chatId) langFuseOptions.sessionId = options.chatId
567
568 if (nodeData?.inputs?.analytics?.langFuse) {
569 langFuseOptions = { ...langFuseOptions, ...nodeData?.inputs?.analytics?.langFuse }
570 }
571
572 const handler = new CallbackHandler(langFuseOptions)
573 callbacks.push(handler)

Callers 15

runMethod · 0.90
runPredictionFunction · 0.90
runMethod · 0.90
runMethod · 0.90
runMethod · 0.90
runMethod · 0.90
runMethod · 0.90
runMethod · 0.90
runMethod · 0.90
runMethod · 0.90
runMethod · 0.90
runMethod · 0.90

Calls 9

tracingEnvEnabledFunction · 0.90
applyEnvTracingProvidersFunction · 0.90
getCredentialDataFunction · 0.90
getCredentialParamFunction · 0.90
getArizeTracerFunction · 0.85
getPhoenixTracerFunction · 0.85
getOpikTracerFunction · 0.85
parseMethod · 0.65
updateMethod · 0.65

Tested by

no test coverage detected