subgraphWithTask

inline fun <Input, ProvidedResult : SubgraphResult> AIAgentSubgraphBuilderBase<*, *>.subgraphWithTask(toolSelectionStrategy: ToolSelectionStrategy, finishTool: ProvideSubgraphResult<ProvidedResult>, llmModel: LLModel? = null, llmParams: LLMParams? = null, noinline defineTask: suspend AIAgentContextBase.(input: Input) -> String): AIAgentSubgraphDelegate<Input, ProvidedResult>(source)

Creates a subgraph, which performs one specific task, defined by defineTask, using the tools defined by toolSelectionStrategy. When LLM believes that the task is finished, it will call finishTool, generating ProvidedResult as its argument. The generated ProvidedResult is the result of this subgraph. The subgraph returns a wrapper SafeTool.Result to handle cases when the model didn't reach the finish condition or didn't generate a final ProvidedResult due to an error (reported as SafeTool.Result.Failure)

Use this function if you need the agent to perform a single task which outputs a structured result.


inline fun <Input, ProvidedResult : SubgraphResult> AIAgentSubgraphBuilderBase<*, *>.subgraphWithTask(tools: List<Tool<*, *>>, finishTool: ProvideSubgraphResult<ProvidedResult>, llmModel: LLModel? = null, llmParams: LLMParams? = null, noinline defineTask: suspend AIAgentContextBase.(input: Input) -> String): AIAgentSubgraphDelegate<Input, ProvidedResult>(source)

Creates a subgraph with a task definition and specified tools. The subgraph uses the provided tools to process input and execute the defined task, eventually producing a result through the provided finish tool.

Return

A delegate representing the subgraph that processes the input and produces a result through the finish tool.

Parameters

tools

The list of tools that are available for use within the subgraph.

finishTool

The tool responsible for producing the final result of the subgraph.

llmModel

An optional language model to be used in the subgraph. If not specified, a default model may be used.

llmParams

Optional parameters to customize the behavior of the language model in the subgraph.

defineTask

A suspend function that defines the task to be executed by the subgraph based on the given input.


inline fun <Input> AIAgentSubgraphBuilderBase<*, *>.subgraphWithTask(toolSelectionStrategy: ToolSelectionStrategy, llmModel: LLModel? = null, llmParams: LLMParams? = null, noinline defineTask: suspend AIAgentContextBase.(input: Input) -> String): AIAgentSubgraphDelegate<Input, StringSubgraphResult>(source)

subgraphWithTask with StringSubgraphResult result.


inline fun <Input> AIAgentSubgraphBuilderBase<*, *>.subgraphWithTask(tools: List<Tool<*, *>>, llmModel: LLModel? = null, llmParams: LLMParams? = null, noinline defineTask: suspend AIAgentContextBase.(input: Input) -> String): AIAgentSubgraphDelegate<Input, StringSubgraphResult>(source)

Creates a subgraph with a predefined task definition using the provided tools, model, and parameters.

This function allows you to define a subgraph where a specific task is executed as part of the AI agent's strategy graph. The task is determined based on the provided task definition logic, which is executed in the given context.

Return

A delegate representing the constructed subgraph with task execution capabilities.

Parameters

tools

A list of tools available for use within the subgraph.

llmModel

An optional language model to be used within the subgraph. Defaults to null.

llmParams

Optional parameters for the language model. Defaults to null.

defineTask

A suspendable function that defines the task for the subgraph, given an input in the context.