mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
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:
@@ -20,6 +20,7 @@ export type NodeParamsType =
|
||||
| 'date'
|
||||
| 'file'
|
||||
| 'folder'
|
||||
| 'tabs'
|
||||
|
||||
export type CommonType = string | number | boolean | undefined | null
|
||||
|
||||
@@ -63,6 +64,8 @@ export interface INodeOutputsValue {
|
||||
name: string
|
||||
baseClasses: string[]
|
||||
description?: string
|
||||
hidden?: boolean
|
||||
isAnchor?: boolean
|
||||
}
|
||||
|
||||
export interface INodeParams {
|
||||
@@ -85,7 +88,11 @@ export interface INodeParams {
|
||||
additionalParams?: boolean
|
||||
loadMethod?: string
|
||||
hidden?: boolean
|
||||
variables?: ICommonObject[]
|
||||
hideCodeExecute?: boolean
|
||||
codeExample?: string
|
||||
hint?: Record<string, string>
|
||||
tabIdentifier?: string
|
||||
tabs?: Array<INodeParams>
|
||||
}
|
||||
|
||||
export interface INodeExecutionData {
|
||||
@@ -109,6 +116,7 @@ export interface INodeProperties {
|
||||
filePath?: string
|
||||
badge?: string
|
||||
deprecateMessage?: string
|
||||
hideOutput?: boolean
|
||||
}
|
||||
|
||||
export interface INode extends INodeProperties {
|
||||
@@ -151,6 +159,7 @@ export interface IUsedTool {
|
||||
tool: string
|
||||
toolInput: object
|
||||
toolOutput: string | object
|
||||
sourceDocuments?: ICommonObject[]
|
||||
}
|
||||
|
||||
export interface IMultiAgentNode {
|
||||
@@ -166,6 +175,27 @@ export interface IMultiAgentNode {
|
||||
recursionLimit?: number
|
||||
moderations?: Moderation[]
|
||||
multiModalMessageContent?: MessageContentImageUrl[]
|
||||
checkpointMemory?: any
|
||||
}
|
||||
|
||||
type SeqAgentType = 'agent' | 'condition' | 'end' | 'start' | 'tool' | 'state' | 'llm'
|
||||
|
||||
export interface ISeqAgentNode {
|
||||
id: string
|
||||
node: any
|
||||
name: string
|
||||
label: string
|
||||
type: SeqAgentType
|
||||
output: string
|
||||
llm?: any
|
||||
startLLM?: any
|
||||
predecessorAgents?: ISeqAgentNode[]
|
||||
recursionLimit?: number
|
||||
moderations?: Moderation[]
|
||||
multiModalMessageContent?: MessageContentImageUrl[]
|
||||
checkpointMemory?: any
|
||||
agentInterruptToolNode?: any
|
||||
agentInterruptToolFunc?: any
|
||||
}
|
||||
|
||||
export interface ITeamState {
|
||||
@@ -176,13 +206,31 @@ export interface ITeamState {
|
||||
team_members: string[]
|
||||
next: string
|
||||
instructions: string
|
||||
summarization: string
|
||||
}
|
||||
|
||||
export interface ISeqAgentsState {
|
||||
messages: {
|
||||
value: (x: BaseMessage[], y: BaseMessage[]) => BaseMessage[]
|
||||
default: () => BaseMessage[]
|
||||
}
|
||||
}
|
||||
|
||||
export interface IAgentReasoning {
|
||||
agentName: string
|
||||
messages: string[]
|
||||
next: string
|
||||
instructions: string
|
||||
next?: string
|
||||
instructions?: string
|
||||
usedTools?: IUsedTool[]
|
||||
sourceDocuments?: ICommonObject[]
|
||||
state?: ICommonObject
|
||||
nodeName?: string
|
||||
}
|
||||
|
||||
export interface IAction {
|
||||
id?: string
|
||||
elements?: Array<{ type: string; label: string }>
|
||||
mapping?: { approve: string; reject: string; toolCalls: any[] }
|
||||
}
|
||||
|
||||
export interface IFileUpload {
|
||||
|
||||
@@ -11,6 +11,7 @@ import { Runnable, RunnableSequence, RunnablePassthrough } from '@langchain/core
|
||||
import { Serializable } from '@langchain/core/load/serializable'
|
||||
import { renderTemplate } from '@langchain/core/prompts'
|
||||
import { ChatGeneration } from '@langchain/core/outputs'
|
||||
import { Document } from '@langchain/core/documents'
|
||||
import { BaseChain, SerializedLLMChain } from 'langchain/chains'
|
||||
import {
|
||||
CreateReactAgentParams,
|
||||
@@ -421,7 +422,8 @@ export class AgentExecutor extends BaseChain<ChainValues, AgentExecutorOutput> {
|
||||
{
|
||||
sessionId: this.sessionId,
|
||||
chatId: this.chatId,
|
||||
input: this.input
|
||||
input: this.input,
|
||||
state: inputs
|
||||
}
|
||||
)
|
||||
usedTools.push({
|
||||
@@ -556,7 +558,8 @@ export class AgentExecutor extends BaseChain<ChainValues, AgentExecutorOutput> {
|
||||
{
|
||||
sessionId: this.sessionId,
|
||||
chatId: this.chatId,
|
||||
input: this.input
|
||||
input: this.input,
|
||||
state: inputs
|
||||
}
|
||||
)
|
||||
if (typeof observation === 'string' && observation.includes(SOURCE_DOCUMENTS_PREFIX)) {
|
||||
|
||||
@@ -208,20 +208,22 @@ export const getNodeModulesPackagePath = (packageName: string): string => {
|
||||
*/
|
||||
export const getInputVariables = (paramValue: string): string[] => {
|
||||
if (typeof paramValue !== 'string') return []
|
||||
let returnVal = paramValue
|
||||
const returnVal = paramValue
|
||||
const variableStack = []
|
||||
const inputVariables = []
|
||||
let startIdx = 0
|
||||
const endIdx = returnVal.length
|
||||
|
||||
while (startIdx < endIdx) {
|
||||
const substr = returnVal.substring(startIdx, startIdx + 1)
|
||||
|
||||
// Check for escaped curly brackets
|
||||
if (substr === '\\' && (returnVal[startIdx + 1] === '{' || returnVal[startIdx + 1] === '}')) {
|
||||
startIdx += 2 // Skip the escaped bracket
|
||||
continue
|
||||
}
|
||||
// Store the opening double curly bracket
|
||||
if (substr === '{') {
|
||||
variableStack.push({ substr, startIdx: startIdx + 1 })
|
||||
}
|
||||
|
||||
// Found the complete variable
|
||||
if (substr === '}' && variableStack.length > 0 && variableStack[variableStack.length - 1].substr === '{') {
|
||||
const variableStartIdx = variableStack[variableStack.length - 1].startIdx
|
||||
@@ -729,7 +731,7 @@ export const getVars = async (appDataSource: DataSource, databaseEntities: IData
|
||||
const variables = ((await appDataSource.getRepository(databaseEntities['Variable']).find()) as IVariable[]) ?? []
|
||||
|
||||
// override variables defined in overrideConfig
|
||||
// nodeData.inputs.variables is an Object, check each property and override the variable
|
||||
// nodeData.inputs.vars is an Object, check each property and override the variable
|
||||
if (nodeData?.inputs?.vars) {
|
||||
for (const propertyName of Object.getOwnPropertyNames(nodeData.inputs.vars)) {
|
||||
const foundVar = variables.find((v) => v.name === propertyName)
|
||||
|
||||
Reference in New Issue
Block a user