Skip to content

Commit 5d87a91

Browse files
authored
Merge pull request FlowiseAI#952 from vinodkiran/FEATURE/analytic-llmonitor
Adding support for LLMonitor
2 parents c077d44 + a028757 commit 5d87a91

File tree

7 files changed

+101
-4
lines changed

7 files changed

+101
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { INodeParams, INodeCredential } from '../src/Interface'
2+
3+
class LLMonitorApi implements INodeCredential {
4+
label: string
5+
name: string
6+
version: number
7+
description: string
8+
inputs: INodeParams[]
9+
10+
constructor() {
11+
this.label = 'LLMonitor API'
12+
this.name = 'llmonitorApi'
13+
this.version = 1.0
14+
this.description = 'Refer to <a target="_blank" href="https://llmonitor.com/docs">official guide</a> to get APP ID'
15+
this.inputs = [
16+
{
17+
label: 'APP ID',
18+
name: 'llmonitorAppId',
19+
type: 'password',
20+
placeholder: '<LLMonitor_APP_ID>'
21+
},
22+
{
23+
label: 'Endpoint',
24+
name: 'llmonitorEndpoint',
25+
type: 'string',
26+
default: 'https://app.llmonitor.com'
27+
}
28+
]
29+
}
30+
}
31+
32+
module.exports = { credClass: LLMonitorApi }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { INode, INodeParams } from '../../../src/Interface'
2+
3+
class LLMonitor_Analytic implements INode {
4+
label: string
5+
name: string
6+
version: number
7+
description: string
8+
type: string
9+
icon: string
10+
category: string
11+
baseClasses: string[]
12+
inputs?: INodeParams[]
13+
credential: INodeParams
14+
15+
constructor() {
16+
this.label = 'LLMonitor'
17+
this.name = 'llmonitor'
18+
this.version = 1.0
19+
this.type = 'LLMonitor'
20+
this.icon = 'llmonitor.png'
21+
this.category = 'Analytic'
22+
this.baseClasses = [this.type]
23+
this.inputs = []
24+
this.credential = {
25+
label: 'Connect Credential',
26+
name: 'credential',
27+
type: 'credential',
28+
credentialNames: ['llmonitorApi']
29+
}
30+
}
31+
}
32+
33+
module.exports = { nodeClass: LLMonitor_Analytic }
Loading

packages/components/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"langfuse-langchain": "^1.0.14-alpha.0",
4747
"langsmith": "^0.0.32",
4848
"linkifyjs": "^4.1.1",
49+
"llmonitor": "^0.5.5",
4950
"mammoth": "^1.5.1",
5051
"moment": "^2.29.3",
5152
"mysql2": "^3.5.1",

packages/components/src/handler.ts

+14-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Logger } from 'winston'
44
import { Server } from 'socket.io'
55
import { Client } from 'langsmith'
66
import { LangChainTracer } from 'langchain/callbacks'
7+
import { LLMonitorHandler } from 'langchain/callbacks/handlers/llmonitor'
78
import { getCredentialData, getCredentialParam } from './utils'
89
import { ICommonObject, INodeData } from './Interface'
910
import CallbackHandler from 'langfuse-langchain'
@@ -194,11 +195,11 @@ export const additionalCallbacks = async (nodeData: INodeData, options: ICommonO
194195
for (const provider in analytic) {
195196
const providerStatus = analytic[provider].status as boolean
196197
if (providerStatus) {
198+
const credentialId = analytic[provider].credentialId as string
199+
const credentialData = await getCredentialData(credentialId ?? '', options)
197200
if (provider === 'langSmith') {
198-
const credentialId = analytic[provider].credentialId as string
199201
const langSmithProject = analytic[provider].projectName as string
200202

201-
const credentialData = await getCredentialData(credentialId ?? '', options)
202203
const langSmithApiKey = getCredentialParam('langSmithApiKey', credentialData, nodeData)
203204
const langSmithEndpoint = getCredentialParam('langSmithEndpoint', credentialData, nodeData)
204205

@@ -214,13 +215,11 @@ export const additionalCallbacks = async (nodeData: INodeData, options: ICommonO
214215
})
215216
callbacks.push(tracer)
216217
} else if (provider === 'langFuse') {
217-
const credentialId = analytic[provider].credentialId as string
218218
const flushAt = analytic[provider].flushAt as string
219219
const flushInterval = analytic[provider].flushInterval as string
220220
const requestTimeout = analytic[provider].requestTimeout as string
221221
const release = analytic[provider].release as string
222222

223-
const credentialData = await getCredentialData(credentialId ?? '', options)
224223
const langFuseSecretKey = getCredentialParam('langFuseSecretKey', credentialData, nodeData)
225224
const langFusePublicKey = getCredentialParam('langFusePublicKey', credentialData, nodeData)
226225
const langFuseEndpoint = getCredentialParam('langFuseEndpoint', credentialData, nodeData)
@@ -237,6 +236,17 @@ export const additionalCallbacks = async (nodeData: INodeData, options: ICommonO
237236

238237
const handler = new CallbackHandler(langFuseOptions)
239238
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)
240250
}
241251
}
242252
}
1.69 KB
Loading

packages/ui/src/ui-component/dialog/AnalyseFlowDialog.js

+21
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { Input } from 'ui-component/input/Input'
3131
import { StyledButton } from 'ui-component/button/StyledButton'
3232
import langsmithPNG from 'assets/images/langchain.png'
3333
import langfusePNG from 'assets/images/langfuse.png'
34+
import llmonitorPNG from 'assets/images/llmonitor.png'
3435

3536
// store
3637
import { HIDE_CANVAS_DIALOG, SHOW_CANVAS_DIALOG } from 'store/actions'
@@ -115,6 +116,26 @@ const analyticProviders = [
115116
optional: true
116117
}
117118
]
119+
},
120+
{
121+
label: 'LLMonitor',
122+
name: 'llmonitor',
123+
icon: llmonitorPNG,
124+
url: 'https://llmonitor.com',
125+
inputs: [
126+
{
127+
label: 'Connect Credential',
128+
name: 'credential',
129+
type: 'credential',
130+
credentialNames: ['llmonitorApi']
131+
},
132+
{
133+
label: 'On/Off',
134+
name: 'status',
135+
type: 'boolean',
136+
optional: true
137+
}
138+
]
118139
}
119140
]
120141

0 commit comments

Comments
 (0)