mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
a7c1ab881c
* added: Neo4j database connectivity, Neo4j credentials, supports the usage of the GraphCypherQaChain node and modifies the FewShotPromptTemplate node to handle variables from the prefix field. * Merge branch 'main' of github.com:FlowiseAI/Flowise into feature/graphragsupport * revert pnpm-lock.yaml * add: neo4j package * Refactor GraphCypherQAChain: Update version to 1.0, remove memory input, and enhance prompt handling - Changed version from 2.0 to 1.0. - Removed the 'Memory' input parameter from the GraphCypherQAChain. - Made 'cypherPrompt' optional and improved error handling for prompt validation. - Updated the 'init' and 'run' methods to streamline input processing and response handling. - Enhanced streaming response logic based on the 'returnDirect' flag. * Refactor GraphCypherQAChain: Simplify imports and update init method signature - Consolidated import statements for better readability. - Removed the 'input' and 'options' parameters from the 'init' method, streamlining its signature to only accept 'nodeData'. * add output, format final response, fix optional inputs --------- Co-authored-by: Henry <hzj94@hotmail.com>
81 lines
2.4 KiB
TypeScript
81 lines
2.4 KiB
TypeScript
import { getBaseClasses, getCredentialData } from '../../../src/utils'
|
|
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
|
import { Neo4jGraph } from '@langchain/community/graphs/neo4j_graph'
|
|
|
|
class Neo4j_Graphs implements INode {
|
|
label: string
|
|
name: string
|
|
version: number
|
|
type: string
|
|
icon: string
|
|
category: string
|
|
description: string
|
|
baseClasses: string[]
|
|
credential: INodeParams
|
|
inputs: INodeParams[]
|
|
|
|
constructor() {
|
|
this.label = 'Neo4j'
|
|
this.name = 'Neo4j'
|
|
this.version = 1.0
|
|
this.type = 'Neo4j'
|
|
this.icon = 'neo4j.svg'
|
|
this.category = 'Graph'
|
|
this.description = 'Connect with Neo4j graph database'
|
|
this.baseClasses = [this.type, ...getBaseClasses(Neo4jGraph)]
|
|
this.credential = {
|
|
label: 'Connect Credential',
|
|
name: 'credential',
|
|
type: 'credential',
|
|
credentialNames: ['neo4jApi']
|
|
}
|
|
this.inputs = [
|
|
{
|
|
label: 'Database',
|
|
name: 'database',
|
|
type: 'string',
|
|
placeholder: 'neo4j',
|
|
optional: true
|
|
},
|
|
{
|
|
label: 'Timeout (ms)',
|
|
name: 'timeoutMs',
|
|
type: 'number',
|
|
default: 5000,
|
|
optional: true
|
|
},
|
|
{
|
|
label: 'Enhanced Schema',
|
|
name: 'enhancedSchema',
|
|
type: 'boolean',
|
|
default: false,
|
|
optional: true
|
|
}
|
|
]
|
|
}
|
|
|
|
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
|
const database = nodeData.inputs?.database as string
|
|
const timeoutMs = nodeData.inputs?.timeoutMs as number
|
|
const enhancedSchema = nodeData.inputs?.enhancedSchema as boolean
|
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
|
|
|
const neo4jConfig = {
|
|
url: credentialData?.url,
|
|
username: credentialData?.username,
|
|
password: credentialData?.password
|
|
}
|
|
|
|
const neo4jGraph = await Neo4jGraph.initialize({
|
|
...neo4jConfig,
|
|
...(database && { database }),
|
|
...(timeoutMs && { timeoutMs }),
|
|
...(enhancedSchema && { enhancedSchema })
|
|
})
|
|
|
|
return neo4jGraph
|
|
}
|
|
}
|
|
|
|
module.exports = { nodeClass: Neo4j_Graphs }
|