mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
Feature/lang graph (#2319)
* add langgraph * datasource: initial commit * datasource: datasource details and chunks * datasource: Document Store Node * more changes * Document Store - Base functionality * Document Store Loader Component * Document Store Loader Component * before merging the modularity PR * after merging the modularity PR * preview mode * initial draft PR * fixes * minor updates and fixes * preview with loader and splitter * preview with credential * show stored chunks * preview update... * edit config * save, preview and other changes * save, preview and other changes * save, process and other changes * save, process and other changes * alpha1 - for internal testing * rerouting urls * bug fix on new leader create * pagination support for chunks * delete document store * Update pnpm-lock.yaml * doc store card view * Update store files to use updated storage functions, Document Store Table View and other changes * ui changes * add expanded chunk dialog, improve ui * change throw Error to InternalError * Bug Fixes and removal of subFolder, adding of view chunks for store * lint fixes * merge changes * DocumentStoreStatus component * ui changes for doc store * add remove metadata key field, add custom document loader * add chatflows used doc store chips * add types/interfaces to DocumentStore Services * document loader list dialog title bar color change * update interfaces * Whereused Chatflow Name and Added chunkNo to retain order of created chunks. * use typeorm order chunkNo, ui changes * update tabler icons react * cleanup agents * add pysandbox tool * add abort functionality, loading next agent * add empty view svg * update chatflow tool with chatId * rename to agentflows * update worker for prompt input values * update dashboard to agentflows, agentcanvas * fix marketplace use template * add agentflow templates * resolve merge conflict * update baseURL --------- Co-authored-by: vinodkiran <vinodkiran@usa.net> Co-authored-by: Vinod Paidimarry <vinodkiran@outlook.in>
This commit is contained in:
@@ -46,7 +46,7 @@ const deleteApiKey = async (id: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
const verifyApiKey = async (paramApiKey: string): Promise<any> => {
|
||||
const verifyApiKey = async (paramApiKey: string): Promise<string> => {
|
||||
try {
|
||||
const apiKey = await getApiKey(paramApiKey)
|
||||
if (!apiKey) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FindOptionsWhere } from 'typeorm'
|
||||
import { DeleteResult, FindOptionsWhere } from 'typeorm'
|
||||
import { StatusCodes } from 'http-status-codes'
|
||||
import { chatType, IChatMessage } from '../../Interface'
|
||||
import { utilGetChatMessage } from '../../utils/getChatMessage'
|
||||
@@ -36,7 +36,7 @@ const getAllChatMessages = async (
|
||||
endDate?: string,
|
||||
messageId?: string,
|
||||
feedback?: boolean
|
||||
): Promise<any> => {
|
||||
): Promise<ChatMessage[]> => {
|
||||
try {
|
||||
const dbResponse = await utilGetChatMessage(
|
||||
chatflowId,
|
||||
@@ -71,7 +71,7 @@ const getAllInternalChatMessages = async (
|
||||
endDate?: string,
|
||||
messageId?: string,
|
||||
feedback?: boolean
|
||||
): Promise<any> => {
|
||||
): Promise<ChatMessage[]> => {
|
||||
try {
|
||||
const dbResponse = await utilGetChatMessage(
|
||||
chatflowId,
|
||||
@@ -94,7 +94,11 @@ const getAllInternalChatMessages = async (
|
||||
}
|
||||
}
|
||||
|
||||
const removeAllChatMessages = async (chatId: string, chatflowid: string, deleteOptions: FindOptionsWhere<ChatMessage>): Promise<any> => {
|
||||
const removeAllChatMessages = async (
|
||||
chatId: string,
|
||||
chatflowid: string,
|
||||
deleteOptions: FindOptionsWhere<ChatMessage>
|
||||
): Promise<DeleteResult> => {
|
||||
try {
|
||||
const appServer = getRunningExpressApp()
|
||||
|
||||
@@ -120,9 +124,32 @@ const removeAllChatMessages = async (chatId: string, chatflowid: string, deleteO
|
||||
}
|
||||
}
|
||||
|
||||
const abortChatMessage = async (chatId: string, chatflowid: string) => {
|
||||
try {
|
||||
const appServer = getRunningExpressApp()
|
||||
|
||||
const endingNodeData = appServer.chatflowPool.activeChatflows[`${chatflowid}_${chatId}`]?.endingNodeData as any
|
||||
|
||||
if (endingNodeData && endingNodeData.signal) {
|
||||
try {
|
||||
endingNodeData.signal.abort()
|
||||
await appServer.chatflowPool.remove(`${chatflowid}_${chatId}`)
|
||||
} catch (e) {
|
||||
logger.error(`[server]: Error aborting chat message for ${chatflowid}, chatId ${chatId}: ${e}`)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
throw new InternalFlowiseError(
|
||||
StatusCodes.INTERNAL_SERVER_ERROR,
|
||||
`Error: chatMessagesService.abortChatMessage - ${getErrorMessage(error)}`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
createChatMessage,
|
||||
getAllChatMessages,
|
||||
getAllInternalChatMessages,
|
||||
removeAllChatMessages
|
||||
removeAllChatMessages,
|
||||
abortChatMessage
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { StatusCodes } from 'http-status-codes'
|
||||
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
|
||||
import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
|
||||
import { IChatFlow } from '../../Interface'
|
||||
import { ChatflowType, IChatFlow } from '../../Interface'
|
||||
import { ChatFlow } from '../../database/entities/ChatFlow'
|
||||
import { getAppVersion, getTelemetryFlowObj, isFlowValidForStream, constructGraphs, getEndingNodes } from '../../utils'
|
||||
import logger from '../../utils/logger'
|
||||
@@ -47,6 +47,11 @@ const checkIfChatflowIsValidForStreaming = async (chatflowId: string): Promise<a
|
||||
isStreaming = isFlowValidForStream(nodes, endingNodeData)
|
||||
}
|
||||
|
||||
// If it is a Multi Agents, always enable streaming
|
||||
if (endingNodes.filter((node) => node.data.category === 'Multi Agents').length > 0) {
|
||||
return { isStreaming: true }
|
||||
}
|
||||
|
||||
const dbResponse = { isStreaming: isStreaming }
|
||||
return dbResponse
|
||||
} catch (error) {
|
||||
@@ -99,11 +104,14 @@ const deleteChatflow = async (chatflowId: string): Promise<any> => {
|
||||
}
|
||||
}
|
||||
|
||||
const getAllChatflows = async (): Promise<IChatFlow[]> => {
|
||||
const getAllChatflows = async (type?: ChatflowType): Promise<IChatFlow[]> => {
|
||||
try {
|
||||
const appServer = getRunningExpressApp()
|
||||
const dbResponse = await appServer.AppDataSource.getRepository(ChatFlow).find()
|
||||
return dbResponse
|
||||
if (type === 'MULTIAGENT') {
|
||||
return dbResponse.filter((chatflow) => chatflow.type === type)
|
||||
}
|
||||
return dbResponse.filter((chatflow) => chatflow.type === 'CHATFLOW' || !chatflow.type)
|
||||
} catch (error) {
|
||||
throw new InternalFlowiseError(
|
||||
StatusCodes.INTERNAL_SERVER_ERROR,
|
||||
@@ -114,6 +122,7 @@ const getAllChatflows = async (): Promise<IChatFlow[]> => {
|
||||
|
||||
const getChatflowByApiKey = async (apiKeyId: string): Promise<any> => {
|
||||
try {
|
||||
// Here we only get chatflows that are bounded by the apikeyid and chatflows that are not bounded by any apikey
|
||||
const appServer = getRunningExpressApp()
|
||||
const dbResponse = await appServer.AppDataSource.getRepository(ChatFlow)
|
||||
.createQueryBuilder('cf')
|
||||
|
||||
@@ -44,6 +44,25 @@ const getAllTemplates = async () => {
|
||||
}
|
||||
templates.push(template)
|
||||
})
|
||||
|
||||
marketplaceDir = path.join(__dirname, '..', '..', '..', 'marketplaces', 'agentflows')
|
||||
jsonsInDir = fs.readdirSync(marketplaceDir).filter((file) => path.extname(file) === '.json')
|
||||
jsonsInDir.forEach((file, index) => {
|
||||
const filePath = path.join(__dirname, '..', '..', '..', 'marketplaces', 'agentflows', file)
|
||||
const fileData = fs.readFileSync(filePath)
|
||||
const fileDataObj = JSON.parse(fileData.toString())
|
||||
const template = {
|
||||
id: index,
|
||||
templateName: file.split('.json')[0],
|
||||
flowData: fileData.toString(),
|
||||
badge: fileDataObj?.badge,
|
||||
framework: fileDataObj?.framework,
|
||||
categories: fileDataObj?.categories,
|
||||
type: 'Agentflow',
|
||||
description: fileDataObj?.description || ''
|
||||
}
|
||||
templates.push(template)
|
||||
})
|
||||
const sortedTemplates = templates.sort((a, b) => a.templateName.localeCompare(b.templateName))
|
||||
const FlowiseDocsQnAIndex = sortedTemplates.findIndex((tmp) => tmp.templateName === 'Flowise Docs QnA')
|
||||
if (FlowiseDocsQnAIndex > 0) {
|
||||
|
||||
Reference in New Issue
Block a user