AIAgentSubgraph

open class AIAgentSubgraph<Input, Output>(val name: String, val start: StartNode<Input>, val finish: FinishNode<Output>, toolSelectionStrategy: ToolSelectionStrategy, llmModel: LLModel? = null, llmParams: LLMParams? = null) : AIAgentNodeBase<Input, Output> , ExecutionPointNode(source)

AIAgentSubgraph represents a structured subgraph within an AI agent workflow. It serves as a logical segment containing a defined starting and ending point. The subgraph is responsible for executing tasks in a step-by-step manner, managing iterations, and handling tool selection strategies.

Parameters

Input

The type of input data accepted by the subgraph.

Output

The type of output data returned by the subgraph.

name

The name of the subgraph.

start

The starting node of the subgraph, which initiates the processing.

finish

The finishing node of the subgraph, which concludes the processing.

toolSelectionStrategy

Strategy determining which tools should be available during this subgraph's execution.

llmModel

Optional LLModel override for the subgraph execution.

llmParams

Optional LLMParams override for the prompt for the subgraph execution.

Inheritors

Constructors

Link copied to clipboard
constructor(name: String, start: StartNode<Input>, finish: FinishNode<Output>, toolSelectionStrategy: ToolSelectionStrategy, llmModel: LLModel? = null, llmParams: LLMParams? = null)

Properties

Link copied to clipboard

Represents the directed edges connecting the current node in the AI agent strategy graph to other nodes. Each edge defines the flow and transformation of output data from this node to another.

Link copied to clipboard
Link copied to clipboard
val id: String

Represents the unique identifier of the AI agent node.

Link copied to clipboard
open override val inputType: KType

The KType of the Input

Link copied to clipboard
open override val name: String
Link copied to clipboard
open override val outputType: KType

The KType of the Output

Link copied to clipboard

Functions

Link copied to clipboard
open fun addEdge(edge: AIAgentEdge<Output, *>)

Adds a directed edge from the current node, enabling connections between this node and other nodes in the AI agent strategy graph.

Link copied to clipboard
open override fun enforceExecutionPoint(node: AIAgentNodeBase<*, *>, input: Any?)

Sets a forced node for the entity.

Link copied to clipboard
open suspend override fun execute(context: AIAgentContextBase, input: Input): Output?

Executes the desired operation based on the input and the provided context. This function determines the execution strategy based on the tool selection strategy configured in the class.

Link copied to clipboard
suspend fun executeUnsafe(context: AIAgentContextBase, input: Any?): Any?

Executes the node operation using the provided execution context and input, bypassing type safety checks. This method internally calls the type-safe execute method after casting the input. The lifecycle hooks onBeforeNode and onAfterNode are invoked before and after the execution respectively.

Link copied to clipboard

Creates a directed edge from this AIAgentNodeBase to another AIAgentNodeBase, allowing data to flow from the output of the current node to the input of the specified node.

Link copied to clipboard
open override fun getExecutionPoint(): ExecutionPoint?

Retrieves the current execution point, which consists of a specific node in the execution graph and an optional input. If no forced node is defined, the method returns null.

Link copied to clipboard
open override fun resetExecutionPoint()

Resets the currently enforced execution point for the AI agent, including clearing any forced node and input data. Once the execution point is reset, the system will revert to its default execution behavior without targeting a specific node explicitly.

Link copied to clipboard

Resolves the edge associated with the provided node output and execution context. Iterates through available edges and identifies the first edge that can successfully process the given node output within the provided context. If a resolvable edge is found, it returns a ResolvedEdge containing the edge and its output. Otherwise, returns null.