mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
Merge branch 'main' into bugfix/Concurrent-Chat-Session
# Conflicts: # packages/components/nodes/agents/OpenAIFunctionAgent/OpenAIFunctionAgent.ts
This commit is contained in:
@@ -350,12 +350,33 @@
|
||||
{
|
||||
"label": "Top K",
|
||||
"name": "topK",
|
||||
"description": "Number of top results to fetch. Defaults to 4",
|
||||
"placeholder": "4",
|
||||
"description": "Number of top results to fetch. Defaults to 5",
|
||||
"placeholder": "5",
|
||||
"type": "number",
|
||||
"additionalParams": true,
|
||||
"optional": true,
|
||||
"id": "vectara_0-input-topK-number"
|
||||
},
|
||||
{
|
||||
"label": "MMR K",
|
||||
"name": "mmrK",
|
||||
"description": "The number of results to rerank if MMR is enabled.",
|
||||
"placeholder": "50",
|
||||
"type": "number",
|
||||
"additionalParams": true,
|
||||
"optional": true,
|
||||
"id": "vectara_0-input-mmrK-number"
|
||||
},
|
||||
{
|
||||
"label": "MMR Diversity Bias",
|
||||
"name": "mmrDiversityBias",
|
||||
"step": 0.1,
|
||||
"description": "Diversity Bias parameter for MMR, if enabled. 0.0 means no diversiry bias, 1.0 means maximum diversity bias. Defaults to 0.0 (MMR disabled).",
|
||||
"placeholder": "0.0",
|
||||
"type": "number",
|
||||
"additionalParams": true,
|
||||
"optional": true,
|
||||
"id": "vectara_0-input-mmrDiversityBias-number"
|
||||
}
|
||||
],
|
||||
"inputAnchors": [
|
||||
@@ -374,7 +395,9 @@
|
||||
"sentencesBefore": "",
|
||||
"sentencesAfter": "",
|
||||
"lambda": "",
|
||||
"topK": ""
|
||||
"topK": "",
|
||||
"mmrK": "",
|
||||
"mmrDiversityBias": ""
|
||||
},
|
||||
"outputAnchors": [
|
||||
{
|
||||
|
||||
@@ -361,7 +361,8 @@ export class App {
|
||||
const chatflow = await this.AppDataSource.getRepository(ChatFlow).findOneBy({
|
||||
id: req.params.id
|
||||
})
|
||||
if (chatflow && chatflow.chatbotConfig) {
|
||||
if (!chatflow) return res.status(404).send(`Chatflow ${req.params.id} not found`)
|
||||
if (chatflow.chatbotConfig) {
|
||||
try {
|
||||
const parsedConfig = JSON.parse(chatflow.chatbotConfig)
|
||||
return res.json(parsedConfig)
|
||||
@@ -369,7 +370,7 @@ export class App {
|
||||
return res.status(500).send(`Error parsing Chatbot Config for Chatflow ${req.params.id}`)
|
||||
}
|
||||
}
|
||||
return res.status(404).send(`Chatbot Config for Chatflow ${req.params.id} not found`)
|
||||
return res.status(200).send('OK')
|
||||
})
|
||||
|
||||
// Save chatflow
|
||||
@@ -521,7 +522,7 @@ export class App {
|
||||
res.status(404).send(`Chatflow ${chatflowid} not found`)
|
||||
return
|
||||
}
|
||||
const chatId = (req.query?.chatId as string) ?? (await getChatId(chatflowid))
|
||||
const chatId = req.query?.chatId as string
|
||||
const memoryType = req.query?.memoryType as string | undefined
|
||||
const sessionId = req.query?.sessionId as string | undefined
|
||||
const chatType = req.query?.chatType as string | undefined
|
||||
@@ -545,7 +546,8 @@ export class App {
|
||||
return res.status(500).send('Error clearing chat messages')
|
||||
}
|
||||
|
||||
const deleteOptions: FindOptionsWhere<ChatMessage> = { chatflowid, chatId }
|
||||
const deleteOptions: FindOptionsWhere<ChatMessage> = { chatflowid }
|
||||
if (chatId) deleteOptions.chatId = chatId
|
||||
if (memoryType) deleteOptions.memoryType = memoryType
|
||||
if (sessionId) deleteOptions.sessionId = sessionId
|
||||
if (chatType) deleteOptions.chatType = chatType
|
||||
@@ -633,7 +635,7 @@ export class App {
|
||||
return res.json(result)
|
||||
})
|
||||
|
||||
// Delete all chatmessages from chatflowid
|
||||
// Delete all credentials from chatflowid
|
||||
this.app.delete('/api/v1/credentials/:id', async (req: Request, res: Response) => {
|
||||
const results = await this.AppDataSource.getRepository(Credential).delete({ id: req.params.id })
|
||||
return res.json(results)
|
||||
@@ -1790,23 +1792,6 @@ export class App {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get first chat message id
|
||||
* @param {string} chatflowid
|
||||
* @returns {string}
|
||||
*/
|
||||
export async function getChatId(chatflowid: string): Promise<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 getAllChatFlow(): Promise<IChatFlow[]> {
|
||||
|
||||
@@ -547,7 +547,11 @@ export const getVariableValue = (
|
||||
variablePaths.forEach((path) => {
|
||||
const variableValue = variableDict[path]
|
||||
// Replace all occurrence
|
||||
returnVal = returnVal.split(path).join(variableValue)
|
||||
if (typeof variableValue === 'object') {
|
||||
returnVal = returnVal.split(path).join(JSON.stringify(variableValue).replace(/"/g, '\\"'))
|
||||
} else {
|
||||
returnVal = returnVal.split(path).join(variableValue)
|
||||
}
|
||||
})
|
||||
return returnVal
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user