add webbrowsertool

This commit is contained in:
Henry
2023-05-11 01:36:17 +01:00
parent 9f52463f41
commit fba6a33f30
3 changed files with 649 additions and 0 deletions
@@ -0,0 +1,47 @@
import { BaseLanguageModel } from 'langchain/base_language'
import { INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses } from '../../../src/utils'
import { WebBrowser } from 'langchain/tools/webbrowser'
import { Embeddings } from 'langchain/embeddings/base'
class WebBrowser_Tools implements INode {
label: string
name: string
description: string
type: string
icon: string
category: string
baseClasses: string[]
inputs: INodeParams[]
constructor() {
this.label = 'Web Browser'
this.name = 'webBrowser'
this.type = 'WebBrowser'
this.icon = 'webBrowser.svg'
this.category = 'Tools'
this.description = 'Gives agent the ability to visit a website and extract information'
this.inputs = [
{
label: 'Language Model',
name: 'model',
type: 'BaseLanguageModel'
},
{
label: 'Embeddings',
name: 'embeddings',
type: 'Embeddings'
}
]
this.baseClasses = [this.type, ...getBaseClasses(WebBrowser)]
}
async init(nodeData: INodeData): Promise<any> {
const model = nodeData.inputs?.model as BaseLanguageModel
const embeddings = nodeData.inputs?.embeddings as Embeddings
return new WebBrowser({ model, embeddings })
}
}
module.exports = { nodeClass: WebBrowser_Tools }
@@ -0,0 +1,12 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-world-www" 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="M19.5 7a9 9 0 0 0 -7.5 -4a8.991 8.991 0 0 0 -7.484 4"></path>
<path d="M11.5 3a16.989 16.989 0 0 0 -1.826 4"></path>
<path d="M12.5 3a16.989 16.989 0 0 1 1.828 4"></path>
<path d="M19.5 17a9 9 0 0 1 -7.5 4a8.991 8.991 0 0 1 -7.484 -4"></path>
<path d="M11.5 21a16.989 16.989 0 0 1 -1.826 -4"></path>
<path d="M12.5 21a16.989 16.989 0 0 0 1.828 -4"></path>
<path d="M2 10l1 4l1.5 -4l1.5 4l1 -4"></path>
<path d="M17 10l1 4l1.5 -4l1.5 4l1 -4"></path>
<path d="M9.5 10l1 4l1.5 -4l1.5 4l1 -4"></path>
</svg>

After

Width:  |  Height:  |  Size: 829 B