mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 09:01:06 +03:00
Merge pull request #495 from ivalkshfoeif/feature/motorhead-memory
Feature/Motorhead Memory
This commit is contained in:
@@ -0,0 +1,98 @@
|
|||||||
|
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||||
|
import { getBaseClasses } from '../../../src/utils'
|
||||||
|
import { ICommonObject } from '../../../src'
|
||||||
|
import { MotorheadMemory, MotorheadMemoryInput } from 'langchain/memory'
|
||||||
|
|
||||||
|
class MotorMemory_Memory implements INode {
|
||||||
|
label: string
|
||||||
|
name: string
|
||||||
|
description: string
|
||||||
|
type: string
|
||||||
|
icon: string
|
||||||
|
category: string
|
||||||
|
baseClasses: string[]
|
||||||
|
inputs: INodeParams[]
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.label = 'Motorhead Memory'
|
||||||
|
this.name = 'motorheadMemory'
|
||||||
|
this.type = 'MotorheadMemory'
|
||||||
|
this.icon = 'memory.svg'
|
||||||
|
this.category = 'Memory'
|
||||||
|
this.description = 'Remembers previous conversational back and forths directly'
|
||||||
|
this.baseClasses = [this.type, ...getBaseClasses(MotorheadMemory)]
|
||||||
|
this.inputs = [
|
||||||
|
{
|
||||||
|
label: 'Base URL',
|
||||||
|
name: 'baseURL',
|
||||||
|
type: 'string',
|
||||||
|
optional: true,
|
||||||
|
description: 'To use the online version, leave the URL blank. More details at https://getmetal.io.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Memory Key',
|
||||||
|
name: 'memoryKey',
|
||||||
|
type: 'string',
|
||||||
|
default: 'chat_history'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Session Id',
|
||||||
|
name: 'sessionId',
|
||||||
|
type: 'string',
|
||||||
|
description: 'if empty, chatId will be used automatically',
|
||||||
|
default: '',
|
||||||
|
additionalParams: true,
|
||||||
|
optional: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'API Key',
|
||||||
|
name: 'apiKey',
|
||||||
|
type: 'string',
|
||||||
|
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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||||
|
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
|
||||||
|
|
||||||
|
let obj: MotorheadMemoryInput = {
|
||||||
|
returnMessages: true,
|
||||||
|
sessionId: sessionId ? sessionId : chatId,
|
||||||
|
memoryKey
|
||||||
|
}
|
||||||
|
|
||||||
|
if (baseURL) {
|
||||||
|
obj = {
|
||||||
|
...obj,
|
||||||
|
url: baseURL
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
obj = {
|
||||||
|
...obj,
|
||||||
|
apiKey,
|
||||||
|
clientId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new MotorheadMemory(obj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { nodeClass: MotorMemory_Memory }
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-book" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||||
|
<path d="M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"></path>
|
||||||
|
<path d="M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"></path>
|
||||||
|
<path d="M3 6l0 13"></path>
|
||||||
|
<path d="M12 6l0 13"></path>
|
||||||
|
<path d="M21 6l0 13"></path>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 495 B |
Reference in New Issue
Block a user