mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 11:00:55 +03:00
fix: zep memory
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { IChildProcessMessage, IReactFlowNode, IReactFlowObject, IRunChatflowMessageValue, INodeData } from './Interface'
|
||||
import { buildLangchain, constructGraphs, getEndingNode, getStartingNodes, resolveVariables } from './utils'
|
||||
import { getChatId } from './index'
|
||||
|
||||
export class ChildProcess {
|
||||
/**
|
||||
@@ -76,6 +77,7 @@ export class ChildProcess {
|
||||
const { startingNodeIds, depthQueue } = getStartingNodes(nonDirectedGraph, endingNodeId)
|
||||
|
||||
/*** BFS to traverse from Starting Nodes to Ending Node ***/
|
||||
const chatId = await getChatId(chatflow.id)
|
||||
const reactFlowNodes = await buildLangchain(
|
||||
startingNodeIds,
|
||||
nodes,
|
||||
@@ -83,7 +85,7 @@ export class ChildProcess {
|
||||
depthQueue,
|
||||
componentNodes,
|
||||
incomingInput.question,
|
||||
'',
|
||||
chatId,
|
||||
incomingInput?.overrideConfig
|
||||
)
|
||||
|
||||
|
||||
@@ -506,15 +506,8 @@ export class App {
|
||||
})
|
||||
if (!chatflow) return res.status(404).send(`Chatflow ${chatflowid} not found`)
|
||||
|
||||
// first chatmessage id as the unique chat id
|
||||
const firstChatMessage = await this.AppDataSource.getRepository(ChatMessage)
|
||||
.createQueryBuilder('cm')
|
||||
.select('cm.id')
|
||||
.where('chatflowid = :chatflowid', { chatflowid })
|
||||
.orderBy('cm.createdDate', 'ASC')
|
||||
.getOne()
|
||||
if (!firstChatMessage) return res.status(500).send(`Chatflow ${chatflowid} first message not found`)
|
||||
const chatId = firstChatMessage.id
|
||||
const chatId = await getChatId(chatflow.id)
|
||||
if (!chatId) return res.status(500).send(`Chatflow ${chatflowid} first message not found`)
|
||||
|
||||
if (!isInternal) {
|
||||
await this.validateKey(req, res, chatflow)
|
||||
@@ -672,6 +665,18 @@ export class App {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getChatId(chatflowid: string) {
|
||||
// first chatmessage id as the unique chat id
|
||||
const firstChatMessage = await getDataSource()
|
||||
.getRepository(ChatMessage)
|
||||
.createQueryBuilder('cm')
|
||||
.select('cm.id')
|
||||
.where('chatflowid = :chatflowid', { chatflowid })
|
||||
.orderBy('cm.createdDate', 'ASC')
|
||||
.getOne()
|
||||
return firstChatMessage ? firstChatMessage.id : ''
|
||||
}
|
||||
|
||||
let serverApp: App | undefined
|
||||
|
||||
export async function start(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user