mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 13:00:56 +03:00
add custom tool
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import path from 'path'
|
||||
import { IChildProcessMessage, IReactFlowNode, IReactFlowObject, IRunChatflowMessageValue, INodeData } from './Interface'
|
||||
import { buildLangchain, constructGraphs, getEndingNode, getStartingNodes, resolveVariables } from './utils'
|
||||
import { buildLangchain, constructGraphs, getEndingNode, getStartingNodes, getUserHome, resolveVariables } from './utils'
|
||||
import { DataSource } from 'typeorm'
|
||||
import { ChatFlow } from './entity/ChatFlow'
|
||||
import { ChatMessage } from './entity/ChatMessage'
|
||||
import { Tool } from './entity/Tool'
|
||||
|
||||
export class ChildProcess {
|
||||
/**
|
||||
@@ -22,6 +27,8 @@ export class ChildProcess {
|
||||
|
||||
await sendToParentProcess('start', '_')
|
||||
|
||||
const childAppDataSource = await initDB()
|
||||
|
||||
// Create a Queue and add our initial node in it
|
||||
const { endingNodeData, chatflow, chatId, incomingInput, componentNodes } = messageValue
|
||||
|
||||
@@ -84,6 +91,7 @@ export class ChildProcess {
|
||||
componentNodes,
|
||||
incomingInput.question,
|
||||
chatId,
|
||||
childAppDataSource,
|
||||
incomingInput?.overrideConfig
|
||||
)
|
||||
|
||||
@@ -115,6 +123,22 @@ export class ChildProcess {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initalize DB in child process
|
||||
* @returns {DataSource}
|
||||
*/
|
||||
async function initDB() {
|
||||
const homePath = path.join(getUserHome(), '.flowise')
|
||||
const childAppDataSource = new DataSource({
|
||||
type: 'sqlite',
|
||||
database: path.resolve(homePath, 'database.sqlite'),
|
||||
synchronize: true,
|
||||
entities: [ChatFlow, ChatMessage, Tool],
|
||||
migrations: []
|
||||
})
|
||||
return await childAppDataSource.initialize()
|
||||
}
|
||||
|
||||
/**
|
||||
* Send data back to parent process
|
||||
* @param {string} key Key of message
|
||||
|
||||
Reference in New Issue
Block a user