mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
feat: unique chat id
This commit is contained in:
@@ -83,6 +83,7 @@ export class ChildProcess {
|
||||
depthQueue,
|
||||
componentNodes,
|
||||
incomingInput.question,
|
||||
'',
|
||||
incomingInput?.overrideConfig
|
||||
)
|
||||
|
||||
|
||||
@@ -506,6 +506,16 @@ 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
|
||||
|
||||
if (!isInternal) {
|
||||
await this.validateKey(req, res, chatflow)
|
||||
}
|
||||
@@ -618,6 +628,7 @@ export class App {
|
||||
depthQueue,
|
||||
this.nodesPool.componentNodes,
|
||||
incomingInput.question,
|
||||
chatId,
|
||||
incomingInput?.overrideConfig
|
||||
)
|
||||
|
||||
|
||||
@@ -182,6 +182,7 @@ export const buildLangchain = async (
|
||||
depthQueue: IDepthQueue,
|
||||
componentNodes: IComponentNodes,
|
||||
question: string,
|
||||
chatId: string,
|
||||
overrideConfig?: ICommonObject
|
||||
) => {
|
||||
const flowNodes = cloneDeep(reactFlowNodes)
|
||||
@@ -214,7 +215,7 @@ export const buildLangchain = async (
|
||||
if (overrideConfig) flowNodeData = replaceInputsWithConfig(flowNodeData, overrideConfig)
|
||||
const reactFlowNodeData: INodeData = resolveVariables(flowNodeData, flowNodes, question)
|
||||
|
||||
flowNodes[nodeIndex].data.instance = await newNodeInstance.init(reactFlowNodeData, question)
|
||||
flowNodes[nodeIndex].data.instance = await newNodeInstance.init(reactFlowNodeData, question, { chatId })
|
||||
} catch (e: any) {
|
||||
console.error(e)
|
||||
throw new Error(e)
|
||||
|
||||
Reference in New Issue
Block a user