add custom tool

This commit is contained in:
Henry
2023-06-21 18:31:53 +01:00
parent 8c880199cd
commit 70da39629c
28 changed files with 1346 additions and 43 deletions
+21 -1
View File
@@ -2,7 +2,18 @@
* Types
*/
export type NodeParamsType = 'options' | 'string' | 'number' | 'boolean' | 'password' | 'json' | 'code' | 'date' | 'file' | 'folder'
export type NodeParamsType =
| 'asyncOptions'
| 'options'
| 'string'
| 'number'
| 'boolean'
| 'password'
| 'json'
| 'code'
| 'date'
| 'file'
| 'folder'
export type CommonType = string | number | boolean | undefined | null
@@ -16,6 +27,10 @@ export interface ICommonObject {
[key: string]: any | CommonType | ICommonObject | CommonType[] | ICommonObject[]
}
export type IDatabaseEntity = {
[key: string]: any
}
export interface IAttachment {
content: string
contentType: string
@@ -50,6 +65,7 @@ export interface INodeParams {
placeholder?: string
fileType?: string
additionalParams?: boolean
loadMethod?: string
}
export interface INodeExecutionData {
@@ -74,6 +90,9 @@ export interface INodeProperties {
export interface INode extends INodeProperties {
inputs?: INodeParams[]
output?: INodeOutputsValue[]
loadMethods?: {
[key: string]: (nodeData: INodeData, options?: ICommonObject) => Promise<INodeOptionsValue[]>
}
init?(nodeData: INodeData, input: string, options?: ICommonObject): Promise<any>
run?(nodeData: INodeData, input: string, options?: ICommonObject): Promise<string | ICommonObject>
}
@@ -83,6 +102,7 @@ export interface INodeData extends INodeProperties {
inputs?: ICommonObject
outputs?: ICommonObject
instance?: any
loadMethod?: string // method to load async options
}
export interface IMessage {
+30 -1
View File
@@ -18,6 +18,7 @@ export const notEmptyRegex = '(.|\\s)*\\S(.|\\s)*' //return true if string is no
*/
export const getBaseClasses = (targetClass: any) => {
const baseClasses: string[] = []
const skipClassNames = ['BaseLangChain', 'Serializable']
if (targetClass instanceof Function) {
let baseClass = targetClass
@@ -26,7 +27,7 @@ export const getBaseClasses = (targetClass: any) => {
const newBaseClass = Object.getPrototypeOf(baseClass)
if (newBaseClass && newBaseClass !== Object && newBaseClass.name) {
baseClass = newBaseClass
baseClasses.push(baseClass.name)
if (!skipClassNames.includes(baseClass.name)) baseClasses.push(baseClass.name)
} else {
break
}
@@ -284,3 +285,31 @@ const handleEscapeDoubleQuote = (value: string): string => {
}
return newValue === '' ? value : newValue
}
export const availableDependencies = [
'@dqbd/tiktoken',
'@getzep/zep-js',
'@huggingface/inference',
'@pinecone-database/pinecone',
'@supabase/supabase-js',
'axios',
'cheerio',
'chromadb',
'cohere-ai',
'd3-dsv',
'form-data',
'graphql',
'html-to-text',
'langchain',
'linkifyjs',
'mammoth',
'moment',
'node-fetch',
'pdf-parse',
'pdfjs-dist',
'playwright',
'puppeteer',
'srt-parser-2',
'typeorm',
'weaviate-ts-client'
]