add tools for plugins

This commit is contained in:
Henry
2023-04-11 15:10:39 +01:00
parent 02d8284f58
commit a94d841bb7
7 changed files with 131 additions and 0 deletions
@@ -0,0 +1,43 @@
import { INode, INodeData, INodeParams } from '../../../src/Interface'
class AIPlugin implements INode {
label: string
name: string
description: string
type: string
icon: string
category: string
baseClasses: string[]
inputs?: INodeParams[]
constructor() {
this.label = 'AI Plugin'
this.name = 'aiPlugin'
this.type = 'AIPlugin'
this.icon = 'aiplugin.svg'
this.category = 'Tools'
this.description = 'Execute actions using ChatGPT Plugin Url'
this.inputs = [
{
label: 'Plugin Url',
name: 'pluginUrl',
type: 'string',
placeholder: 'https://www.klarna.com/.well-known/ai-plugin.json'
}
]
}
async getBaseClasses(): Promise<string[]> {
return ['Tool']
}
async init(nodeData: INodeData): Promise<any> {
const { AIPluginTool } = await import('langchain/tools')
const pluginUrl = nodeData.inputs?.pluginUrl as string
const aiplugin = await AIPluginTool.fromPluginUrl(pluginUrl)
return aiplugin
}
}
module.exports = { nodeClass: AIPlugin }
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-plug" 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="M9.785 6l8.215 8.215l-2.054 2.054a5.81 5.81 0 1 1 -8.215 -8.215l2.054 -2.054z"></path>
<path d="M4 20l3.5 -3.5"></path>
<path d="M15 4l-3.5 3.5"></path>
<path d="M20 9l-3.5 3.5"></path>
</svg>

After

Width:  |  Height:  |  Size: 498 B