Skip to content

Commit

Permalink
Merge pull request #952 from vinodkiran/FEATURE/analytic-llmonitor
Browse files Browse the repository at this point in the history
Adding support for LLMonitor
  • Loading branch information
HenryHengZJ authored Sep 21, 2023
2 parents 171c765 + e312c6e commit eda5609
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 4 deletions.
32 changes: 32 additions & 0 deletions packages/components/credentials/LLMonitorApi.credential.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { INodeParams, INodeCredential } from '../src/Interface'

class LLMonitorApi implements INodeCredential {
label: string
name: string
version: number
description: string
inputs: INodeParams[]

constructor() {
this.label = 'LLMonitor API'
this.name = 'llmonitorApi'
this.version = 1.0
this.description = 'Refer to <a target="_blank" href="https://llmonitor.com/docs">official guide</a> to get APP ID'
this.inputs = [
{
label: 'APP ID',
name: 'llmonitorAppId',
type: 'password',
placeholder: '<LLMonitor_APP_ID>'
},
{
label: 'Endpoint',
name: 'llmonitorEndpoint',
type: 'string',
default: 'https://app.llmonitor.com'
}
]
}
}

module.exports = { credClass: LLMonitorApi }
33 changes: 33 additions & 0 deletions packages/components/nodes/analytic/LLMonitor/LLMonitor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { INode, INodeParams } from '../../../src/Interface'

class LLMonitor_Analytic implements INode {
label: string
name: string
version: number
description: string
type: string
icon: string
category: string
baseClasses: string[]
inputs?: INodeParams[]
credential: INodeParams

constructor() {
this.label = 'LLMonitor'
this.name = 'llmonitor'
this.version = 1.0
this.type = 'LLMonitor'
this.icon = 'llmonitor.png'
this.category = 'Analytic'
this.baseClasses = [this.type]
this.inputs = []
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['llmonitorApi']
}
}
}

module.exports = { nodeClass: LLMonitor_Analytic }
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"langfuse-langchain": "^1.0.14-alpha.0",
"langsmith": "^0.0.32",
"linkifyjs": "^4.1.1",
"llmonitor": "^0.5.5",
"mammoth": "^1.5.1",
"moment": "^2.29.3",
"mysql2": "^3.5.1",
Expand Down
18 changes: 14 additions & 4 deletions packages/components/src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Logger } from 'winston'
import { Server } from 'socket.io'
import { Client } from 'langsmith'
import { LangChainTracer } from 'langchain/callbacks'
import { LLMonitorHandler } from 'langchain/callbacks/handlers/llmonitor'
import { getCredentialData, getCredentialParam } from './utils'
import { ICommonObject, INodeData } from './Interface'
import CallbackHandler from 'langfuse-langchain'
Expand Down Expand Up @@ -194,11 +195,11 @@ export const additionalCallbacks = async (nodeData: INodeData, options: ICommonO
for (const provider in analytic) {
const providerStatus = analytic[provider].status as boolean
if (providerStatus) {
const credentialId = analytic[provider].credentialId as string
const credentialData = await getCredentialData(credentialId ?? '', options)
if (provider === 'langSmith') {
const credentialId = analytic[provider].credentialId as string
const langSmithProject = analytic[provider].projectName as string

const credentialData = await getCredentialData(credentialId ?? '', options)
const langSmithApiKey = getCredentialParam('langSmithApiKey', credentialData, nodeData)
const langSmithEndpoint = getCredentialParam('langSmithEndpoint', credentialData, nodeData)

Expand All @@ -214,13 +215,11 @@ export const additionalCallbacks = async (nodeData: INodeData, options: ICommonO
})
callbacks.push(tracer)
} else if (provider === 'langFuse') {
const credentialId = analytic[provider].credentialId as string
const flushAt = analytic[provider].flushAt as string
const flushInterval = analytic[provider].flushInterval as string
const requestTimeout = analytic[provider].requestTimeout as string
const release = analytic[provider].release as string

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

const handler = new CallbackHandler(langFuseOptions)
callbacks.push(handler)
} else if (provider === 'llmonitor') {
const llmonitorAppId = getCredentialParam('llmonitorAppId', credentialData, nodeData)
const llmonitorEndpoint = getCredentialParam('llmonitorEndpoint', credentialData, nodeData)

const llmonitorFields: ICommonObject = {
appId: llmonitorAppId,
apiUrl: llmonitorEndpoint ?? 'https://app.llmonitor.com'
}

const handler = new LLMonitorHandler(llmonitorFields)
callbacks.push(handler)
}
}
}
Expand Down
Binary file added packages/ui/src/assets/images/llmonitor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions packages/ui/src/ui-component/dialog/AnalyseFlowDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { Input } from 'ui-component/input/Input'
import { StyledButton } from 'ui-component/button/StyledButton'
import langsmithPNG from 'assets/images/langchain.png'
import langfusePNG from 'assets/images/langfuse.png'
import llmonitorPNG from 'assets/images/llmonitor.png'

// store
import { HIDE_CANVAS_DIALOG, SHOW_CANVAS_DIALOG } from 'store/actions'
Expand Down Expand Up @@ -115,6 +116,26 @@ const analyticProviders = [
optional: true
}
]
},
{
label: 'LLMonitor',
name: 'llmonitor',
icon: llmonitorPNG,
url: 'https://llmonitor.com',
inputs: [
{
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['llmonitorApi']
},
{
label: 'On/Off',
name: 'status',
type: 'boolean',
optional: true
}
]
}
]

Expand Down

0 comments on commit eda5609

Please sign in to comment.