Feature/seq agents (#2798)

* update build functions

* sequential agents

* update langchain to 0.2, added sequential agent nodes

* add marketplace templates

* update howto wordings

* Merge branch 'main' into feature/Seq-Agents

# Conflicts:
#	pnpm-lock.yaml

* update deprecated functions and add new sequential nodes

* add marketplace templates

* update marketplace templates, add structured output to llm node

* add multi agents template

* update llm node with bindmodels

* update cypress version

* update templates sticky note wordings

* update tool node to include human in loop action

* update structured outputs error from models

* update cohere package to resolve google genai pipeThrough bug

* update mistral package version, added message reconstruction before invoke seq agent

* add HITL to agent

* update state messages restructuring

* update load and split methods for s3 directory
This commit is contained in:
Henry Heng
2024-07-22 17:46:14 +01:00
committed by GitHub
parent 34d0e4302c
commit bca4de0c63
152 changed files with 55307 additions and 35236 deletions
+57 -37
View File
@@ -269,7 +269,8 @@ export const getEndingNodes = (
endingNodeData.category !== 'Chains' &&
endingNodeData.category !== 'Agents' &&
endingNodeData.category !== 'Engine' &&
endingNodeData.category !== 'Multi Agents'
endingNodeData.category !== 'Multi Agents' &&
endingNodeData.category !== 'Sequential Agents'
) {
error = new InternalFlowiseError(StatusCodes.INTERNAL_SERVER_ERROR, `Ending node must be either a Chain or Agent or Engine`)
continue
@@ -416,42 +417,55 @@ const checkIfDocLoaderShouldBeIgnored = (
return false
}
/**
* Build langchain from start to end
* @param {string[]} startingNodeIds
* @param {IReactFlowNode[]} reactFlowNodes
* @param {INodeDirectedGraph} graph
* @param {IDepthQueue} depthQueue
* @param {IComponentNodes} componentNodes
* @param {string} question
* @param {string} chatId
* @param {string} chatflowid
* @param {DataSource} appDataSource
* @param {ICommonObject} overrideConfig
* @param {CachePool} cachePool
*/
export const buildFlow = async (
startingNodeIds: string[],
reactFlowNodes: IReactFlowNode[],
reactFlowEdges: IReactFlowEdge[],
graph: INodeDirectedGraph,
depthQueue: IDepthQueue,
componentNodes: IComponentNodes,
question: string,
chatHistory: IMessage[],
chatId: string,
sessionId: string,
chatflowid: string,
appDataSource: DataSource,
overrideConfig?: ICommonObject,
cachePool?: CachePool,
isUpsert?: boolean,
stopNodeId?: string,
uploads?: IFileUpload[],
baseURL?: string,
socketIO?: Server,
type BuildFlowParams = {
startingNodeIds: string[]
reactFlowNodes: IReactFlowNode[]
reactFlowEdges: IReactFlowEdge[]
graph: INodeDirectedGraph
depthQueue: IDepthQueue
componentNodes: IComponentNodes
question: string
chatHistory: IMessage[]
chatId: string
sessionId: string
chatflowid: string
appDataSource: DataSource
overrideConfig?: ICommonObject
cachePool?: CachePool
isUpsert?: boolean
stopNodeId?: string
uploads?: IFileUpload[]
baseURL?: string
socketIO?: Server
socketIOClientId?: string
) => {
}
/**
* Build flow from start to end
* @param {BuildFlowParams} params
*/
export const buildFlow = async ({
startingNodeIds,
reactFlowNodes,
reactFlowEdges,
graph,
depthQueue,
componentNodes,
question,
chatHistory,
chatId,
sessionId,
chatflowid,
appDataSource,
overrideConfig,
cachePool,
isUpsert,
stopNodeId,
uploads,
baseURL,
socketIO,
socketIOClientId
}: BuildFlowParams) => {
const flowNodes = cloneDeep(reactFlowNodes)
let upsertHistory: Record<string, any> = {}
@@ -779,9 +793,15 @@ export const getVariableValue = (
const variablePaths = Object.keys(variableDict)
variablePaths.sort() // Sort by length of variable path because longer path could possibly contains nested variable
variablePaths.forEach((path) => {
const variableValue = variableDict[path]
let variableValue: object | string = variableDict[path]
// Replace all occurrence
if (typeof variableValue === 'object') {
// Just get the id of variableValue object if it is agentflow node, to avoid circular JSON error
if (Object.prototype.hasOwnProperty.call(variableValue, 'predecessorAgents')) {
const nodeId = variableValue['id']
variableValue = { id: nodeId }
}
const stringifiedValue = JSON.stringify(JSON.stringify(variableValue))
if (stringifiedValue.startsWith('"') && stringifiedValue.endsWith('"')) {
// get rid of the double quotes