toParallelToolCalls

inline fun <TArgs : Tool.Args, TResult : ToolResult> Flow<TArgs>.toParallelToolCalls(safeTool: SafeTool<TArgs, TResult>, concurrency: Int = 16): Flow<SafeTool.Result<TResult>>(source)

Transforms a flow of arguments into a flow of results by asynchronously executing the given tool in parallel.

Return

a flow of results wrapped in SafeTool.Result for each input argument.

Parameters

TArgs

the type of the arguments required by the tool, extending Tool.Args.

TResult

the type of the result produced by the tool, extending ToolResult.

safeTool

the tool to be executed for each input argument.

concurrency

the maximum number of parallel executions allowed. Defaults to 16.


inline fun <TArgs : Tool.Args, TResult : ToolResult> Flow<TArgs>.toParallelToolCalls(tool: Tool<TArgs, TResult>, concurrency: Int = 16): Flow<SafeTool.Result<TResult>>(source)

Executes the given tool in parallel for each element in the flow of arguments, up to the specified level of concurrency.

Return

A flow emitting the results of the tool executions wrapped in a SafeTool.Result object.

Parameters

TArgs

The type of arguments consumed by the tool.

TResult

The type of result produced by the tool.

tool

The tool instance to be executed in parallel.

concurrency

The maximum number of concurrent executions. Default value is 16.


inline fun <TArgs : Tool.Args, TResult : ToolResult> Flow<TArgs>.toParallelToolCalls(toolClass: KClass<out Tool<TArgs, TResult>>, concurrency: Int = 16): Flow<SafeTool.Result<TResult>>(source)

Transforms a Flow of tool argument objects into a Flow of parallel tool execution results, using the specified tool class.

Return

A Flow containing the results of the tool executions, wrapped in SafeTool.Result.

Parameters

TArgs

The type of the tool arguments that the Flow emits.

TResult

The type of the results produced by the tool.

toolClass

The class of the tool to be invoked in parallel for processing the arguments.

concurrency

The maximum number of parallel executions allowed. Default is 16.