mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
Merge branch 'main' into feature/Prompt-Chaining
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { initializeAgentExecutor, AgentExecutor } from 'langchain/agents'
|
||||
import { Tool } from 'langchain/tools'
|
||||
import { initializeAgentExecutor, AgentExecutor, Tool } from 'langchain/agents'
|
||||
import { BaseChatModel } from 'langchain/chat_models/base'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { SqlDatabaseChain } from 'langchain/chains'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { DataSource } from 'typeorm'
|
||||
import { SqlDatabase } from 'langchain/sql_db'
|
||||
import { BaseLLM } from 'langchain/llms/base'
|
||||
|
||||
class SqlDatabaseChain_Chains implements INode {
|
||||
label: string
|
||||
name: string
|
||||
type: string
|
||||
icon: string
|
||||
category: string
|
||||
baseClasses: string[]
|
||||
description: string
|
||||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'Sql Database Chain'
|
||||
this.name = 'sqlDatabaseChain'
|
||||
this.type = 'SqlDatabaseChain'
|
||||
this.icon = 'sqlchain.svg'
|
||||
this.category = 'Chains'
|
||||
this.description = 'Answer questions over a SQL database'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(SqlDatabaseChain)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'LLM',
|
||||
name: 'llm',
|
||||
type: 'BaseLLM'
|
||||
},
|
||||
{
|
||||
label: 'Database',
|
||||
name: 'database',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
label: 'SQlite',
|
||||
name: 'sqlite'
|
||||
}
|
||||
],
|
||||
default: 'sqlite'
|
||||
},
|
||||
{
|
||||
label: 'Database File Path',
|
||||
name: 'dbFilePath',
|
||||
type: 'string',
|
||||
placeholder: 'C:/Users/chinook.db'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const databaseType = nodeData.inputs?.database
|
||||
const llm = nodeData.inputs?.llm as BaseLLM
|
||||
const dbFilePath = nodeData.inputs?.dbFilePath
|
||||
|
||||
const datasource = new DataSource({
|
||||
type: databaseType,
|
||||
database: dbFilePath
|
||||
})
|
||||
|
||||
const db = await SqlDatabase.fromDataSourceParams({
|
||||
appDataSource: datasource
|
||||
})
|
||||
|
||||
const chain = new SqlDatabaseChain({
|
||||
llm,
|
||||
database: db
|
||||
})
|
||||
return chain
|
||||
}
|
||||
|
||||
async run(nodeData: INodeData, input: string): Promise<string> {
|
||||
const chain = nodeData.instance as SqlDatabaseChain
|
||||
const res = await chain.run(input)
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: SqlDatabaseChain_Chains }
|
||||
@@ -0,0 +1,7 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-sql" 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="M12 8a2 2 0 0 1 2 2v4a2 2 0 1 1 -4 0v-4a2 2 0 0 1 2 -2z"></path>
|
||||
<path d="M17 8v8h4"></path>
|
||||
<path d="M13 15l1 1"></path>
|
||||
<path d="M3 15a1 1 0 0 0 1 1h2a1 1 0 0 0 1 -1v-2a1 1 0 0 0 -1 -1h-2a1 1 0 0 1 -1 -1v-2a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 560 B |
@@ -0,0 +1,41 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { AIPluginTool } from 'langchain/tools'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
|
||||
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.baseClasses = [this.type, ...getBaseClasses(AIPluginTool)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Plugin Url',
|
||||
name: 'pluginUrl',
|
||||
type: 'string',
|
||||
placeholder: 'https://www.klarna.com/.well-known/ai-plugin.json'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
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 |
Reference in New Issue
Block a user