add credentials

This commit is contained in:
Henry
2023-07-15 14:25:52 +01:00
parent aee0a51f73
commit 413d654493
37 changed files with 1858 additions and 126 deletions
@@ -1,5 +1,5 @@
import { INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses } from '../../../src/utils'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { ICommonObject } from '../../../src'
import { MotorheadMemory, MotorheadMemoryInput } from 'langchain/memory'
@@ -11,6 +11,7 @@ class MotorMemory_Memory implements INode {
icon: string
category: string
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
constructor() {
@@ -21,6 +22,14 @@ class MotorMemory_Memory implements INode {
this.category = 'Memory'
this.description = 'Remembers previous conversational back and forths directly'
this.baseClasses = [this.type, ...getBaseClasses(MotorheadMemory)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
optional: true,
description: 'Only needed when using hosted solution - https://getmetal.io',
credentialNames: ['motorheadMemoryApi']
}
this.inputs = [
{
label: 'Base URL',
@@ -43,22 +52,6 @@ class MotorMemory_Memory implements INode {
default: '',
additionalParams: true,
optional: true
},
{
label: 'API Key',
name: 'apiKey',
type: 'password',
description: 'Only needed when using hosted solution - https://getmetal.io',
additionalParams: true,
optional: true
},
{
label: 'Client ID',
name: 'clientId',
type: 'string',
description: 'Only needed when using hosted solution - https://getmetal.io',
additionalParams: true,
optional: true
}
]
}
@@ -67,11 +60,13 @@ class MotorMemory_Memory implements INode {
const memoryKey = nodeData.inputs?.memoryKey as string
const baseURL = nodeData.inputs?.baseURL as string
const sessionId = nodeData.inputs?.sessionId as string
const apiKey = nodeData.inputs?.apiKey as string
const clientId = nodeData.inputs?.clientId as string
const chatId = options?.chatId as string
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const apiKey = getCredentialParam('apiKey', credentialData, nodeData)
const clientId = getCredentialParam('clientId', credentialData, nodeData)
let obj: MotorheadMemoryInput = {
returnMessages: true,
sessionId: sessionId ? sessionId : chatId,
@@ -0,0 +1,29 @@
import { INodeParams, INodeCredential } from '../../../src/Interface'
class MotorheadMemoryApi implements INodeCredential {
label: string
name: string
description: string
inputs: INodeParams[]
constructor() {
this.label = 'Motorhead Memory API'
this.name = 'motorheadMemoryApi'
this.description =
'Refer to <a target="_blank" href="https://docs.getmetal.io/misc-get-keys">official guide</a> on how to create API key and Client ID on Motorhead Memory'
this.inputs = [
{
label: 'Client ID',
name: 'clientId',
type: 'string'
},
{
label: 'API Key',
name: 'apiKey',
type: 'password'
}
]
}
}
module.exports = { credClass: MotorheadMemoryApi }
@@ -1,6 +1,6 @@
import { SystemMessage } from 'langchain/schema'
import { INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses } from '../../../src/utils'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { ZepMemory, ZepMemoryInput } from 'langchain/memory/zep'
import { ICommonObject } from '../../../src'
@@ -12,6 +12,7 @@ class ZepMemory_Memory implements INode {
icon: string
category: string
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
constructor() {
@@ -22,6 +23,14 @@ class ZepMemory_Memory implements INode {
this.category = 'Memory'
this.description = 'Summarizes the conversation and stores the memory in zep server'
this.baseClasses = [this.type, ...getBaseClasses(ZepMemory)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
optional: true,
description: 'Configure JWT authentication on your Zep instance (Optional)',
credentialNames: ['zepMemoryApi']
}
this.inputs = [
{
label: 'Base URL',
@@ -44,18 +53,12 @@ class ZepMemory_Memory implements INode {
additionalParams: true,
optional: true
},
{
label: 'API Key',
name: 'apiKey',
type: 'password',
additionalParams: true,
optional: true
},
{
label: 'Size',
name: 'k',
type: 'number',
default: '10',
step: 1,
description: 'Window of size k to surface the last k back-and-forths to use as memory.'
},
{
@@ -112,11 +115,13 @@ class ZepMemory_Memory implements INode {
const autoSummaryTemplate = nodeData.inputs?.autoSummaryTemplate as string
const autoSummary = nodeData.inputs?.autoSummary as boolean
const sessionId = nodeData.inputs?.sessionId as string
const apiKey = nodeData.inputs?.apiKey as string
const k = nodeData.inputs?.k as string
const chatId = options?.chatId as string
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const apiKey = getCredentialParam('apiKey', credentialData, nodeData)
const obj: ZepMemoryInput = {
baseURL,
sessionId: sessionId ? sessionId : chatId,
@@ -0,0 +1,24 @@
import { INodeParams, INodeCredential } from '../../../src/Interface'
class ZepMemoryApi implements INodeCredential {
label: string
name: string
description: string
inputs: INodeParams[]
constructor() {
this.label = 'Zep Memory Api'
this.name = 'zepMemoryApi'
this.description =
'Refer to <a target="_blank" href="https://docs.getzep.com/deployment/auth/">official guide</a> on how to create API key on Zep'
this.inputs = [
{
label: 'API Key',
name: 'apiKey',
type: 'password'
}
]
}
}
module.exports = { credClass: ZepMemoryApi }