mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 11:01:18 +03:00
fix: childprocess chatId.
This commit is contained in:
@@ -39,7 +39,7 @@ class ZepMemory_Memory implements INode {
|
|||||||
label: 'Session Id',
|
label: 'Session Id',
|
||||||
name: 'sessionId',
|
name: 'sessionId',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
placeholder: 'if empty, chatId will be used automatically',
|
description: 'if empty, chatId will be used automatically',
|
||||||
default: '',
|
default: '',
|
||||||
additionalParams: true
|
additionalParams: true
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { IChildProcessMessage, IReactFlowNode, IReactFlowObject, IRunChatflowMessageValue, INodeData } from './Interface'
|
import { IChildProcessMessage, IReactFlowNode, IReactFlowObject, IRunChatflowMessageValue, INodeData } from './Interface'
|
||||||
import { buildLangchain, constructGraphs, getEndingNode, getStartingNodes, resolveVariables } from './utils'
|
import { buildLangchain, constructGraphs, getEndingNode, getStartingNodes, resolveVariables } from './utils'
|
||||||
import { getChatId } from './index'
|
|
||||||
|
|
||||||
export class ChildProcess {
|
export class ChildProcess {
|
||||||
/**
|
/**
|
||||||
@@ -24,7 +23,7 @@ export class ChildProcess {
|
|||||||
await sendToParentProcess('start', '_')
|
await sendToParentProcess('start', '_')
|
||||||
|
|
||||||
// Create a Queue and add our initial node in it
|
// Create a Queue and add our initial node in it
|
||||||
const { endingNodeData, chatflow, incomingInput, componentNodes } = messageValue
|
const { endingNodeData, chatflow, chatId, incomingInput, componentNodes } = messageValue
|
||||||
|
|
||||||
let nodeToExecuteData: INodeData
|
let nodeToExecuteData: INodeData
|
||||||
let addToChatFlowPool: any = {}
|
let addToChatFlowPool: any = {}
|
||||||
@@ -77,7 +76,6 @@ export class ChildProcess {
|
|||||||
const { startingNodeIds, depthQueue } = getStartingNodes(nonDirectedGraph, endingNodeId)
|
const { startingNodeIds, depthQueue } = getStartingNodes(nonDirectedGraph, endingNodeId)
|
||||||
|
|
||||||
/*** BFS to traverse from Starting Nodes to Ending Node ***/
|
/*** BFS to traverse from Starting Nodes to Ending Node ***/
|
||||||
const chatId = await getChatId(chatflow.id)
|
|
||||||
const reactFlowNodes = await buildLangchain(
|
const reactFlowNodes = await buildLangchain(
|
||||||
startingNodeIds,
|
startingNodeIds,
|
||||||
nodes,
|
nodes,
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ export interface IDatabaseExport {
|
|||||||
|
|
||||||
export interface IRunChatflowMessageValue {
|
export interface IRunChatflowMessageValue {
|
||||||
chatflow: IChatFlow
|
chatflow: IChatFlow
|
||||||
|
chatId: string
|
||||||
incomingInput: IncomingInput
|
incomingInput: IncomingInput
|
||||||
componentNodes: IComponentNodes
|
componentNodes: IComponentNodes
|
||||||
endingNodeData?: INodeData
|
endingNodeData?: INodeData
|
||||||
|
|||||||
@@ -441,9 +441,11 @@ export class App {
|
|||||||
if (!fs.existsSync(childpath)) childpath = 'ChildProcess.ts'
|
if (!fs.existsSync(childpath)) childpath = 'ChildProcess.ts'
|
||||||
|
|
||||||
const childProcess = fork(childpath, [], { signal })
|
const childProcess = fork(childpath, [], { signal })
|
||||||
|
const chatId = await getChatId(chatflow.id)
|
||||||
|
|
||||||
const value = {
|
const value = {
|
||||||
chatflow,
|
chatflow,
|
||||||
|
chatId,
|
||||||
incomingInput,
|
incomingInput,
|
||||||
componentNodes: cloneDeep(this.nodesPool.componentNodes),
|
componentNodes: cloneDeep(this.nodesPool.componentNodes),
|
||||||
endingNodeData
|
endingNodeData
|
||||||
@@ -665,6 +667,11 @@ export class App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get first chat message id
|
||||||
|
* @param {string} chatflowid
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
export async function getChatId(chatflowid: string) {
|
export async function getChatId(chatflowid: string) {
|
||||||
// first chatmessage id as the unique chat id
|
// first chatmessage id as the unique chat id
|
||||||
const firstChatMessage = await getDataSource()
|
const firstChatMessage = await getDataSource()
|
||||||
|
|||||||
Reference in New Issue
Block a user