mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
fix: zep memory
This commit is contained in:
@@ -35,6 +35,14 @@ class ZepMemory_Memory implements INode {
|
|||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Session Id',
|
||||||
|
name: 'sessionId',
|
||||||
|
type: 'string',
|
||||||
|
placeholder: 'if empty, chatId will be used automatically',
|
||||||
|
default: '',
|
||||||
|
additionalParams: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Auto Summary Template',
|
label: 'Auto Summary Template',
|
||||||
name: 'autoSummaryTemplate',
|
name: 'autoSummaryTemplate',
|
||||||
@@ -88,11 +96,13 @@ class ZepMemory_Memory implements INode {
|
|||||||
const inputKey = nodeData.inputs?.inputKey as string
|
const inputKey = nodeData.inputs?.inputKey as string
|
||||||
const autoSummaryTemplate = nodeData.inputs?.autoSummaryTemplate as string
|
const autoSummaryTemplate = nodeData.inputs?.autoSummaryTemplate as string
|
||||||
const autoSummary = nodeData.inputs?.autoSummary as boolean
|
const autoSummary = nodeData.inputs?.autoSummary as boolean
|
||||||
const sessionId = options?.chatId as string
|
const sessionId = nodeData.inputs?.sessionId as string
|
||||||
|
|
||||||
|
const chatId = options?.chatId as string
|
||||||
|
|
||||||
const obj: ZepMemoryInput = {
|
const obj: ZepMemoryInput = {
|
||||||
baseURL,
|
baseURL,
|
||||||
sessionId,
|
sessionId: sessionId ? sessionId : chatId,
|
||||||
aiPrefix,
|
aiPrefix,
|
||||||
humanPrefix,
|
humanPrefix,
|
||||||
returnMessages: true,
|
returnMessages: true,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
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 {
|
||||||
/**
|
/**
|
||||||
@@ -76,6 +77,7 @@ 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,
|
||||||
@@ -83,7 +85,7 @@ export class ChildProcess {
|
|||||||
depthQueue,
|
depthQueue,
|
||||||
componentNodes,
|
componentNodes,
|
||||||
incomingInput.question,
|
incomingInput.question,
|
||||||
'',
|
chatId,
|
||||||
incomingInput?.overrideConfig
|
incomingInput?.overrideConfig
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -506,15 +506,8 @@ export class App {
|
|||||||
})
|
})
|
||||||
if (!chatflow) return res.status(404).send(`Chatflow ${chatflowid} not found`)
|
if (!chatflow) return res.status(404).send(`Chatflow ${chatflowid} not found`)
|
||||||
|
|
||||||
// first chatmessage id as the unique chat id
|
const chatId = await getChatId(chatflow.id)
|
||||||
const firstChatMessage = await this.AppDataSource.getRepository(ChatMessage)
|
if (!chatId) return res.status(500).send(`Chatflow ${chatflowid} first message not found`)
|
||||||
.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
|
|
||||||
|
|
||||||
if (!isInternal) {
|
if (!isInternal) {
|
||||||
await this.validateKey(req, res, chatflow)
|
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
|
let serverApp: App | undefined
|
||||||
|
|
||||||
export async function start(): Promise<void> {
|
export async function start(): Promise<void> {
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ export const ChatMessage = ({ open, chatflowid, isDialog }) => {
|
|||||||
|
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
setMessages((prevMessages) => [...prevMessages, { message: userInput, type: 'userMessage' }])
|
setMessages((prevMessages) => [...prevMessages, { message: userInput, type: 'userMessage' }])
|
||||||
// waiting for first chatmessage uploaded, the first chatmessage id will be chatId for every components
|
// waiting for first chatmessage saved, the first chatmessage will be used in sendMessageAndGetPrediction
|
||||||
await addChatMessage(userInput, 'userMessage')
|
await addChatMessage(userInput, 'userMessage')
|
||||||
|
|
||||||
// Send user question and history to API
|
// Send user question and history to API
|
||||||
|
|||||||
Reference in New Issue
Block a user