Skip to main content

SmartParallelPrompt

Namespace: Wisej.AI.Prompts

Assembly: Wisej.AI

Represents a smart parallel prompt that can execute multiple tasks concurrently.

public class SmartParallelPrompt : SmartPrompt

This class extends the SmartPrompt class and provides functionality to run multiple prompts in parallel.

Constructors​

SmartParallelPrompt(text)​

Initializes a new instance of the SmartParallelPrompt class with optional text.

NameTypeDescription
textStringThe text associated with the prompt. Default is null.

Properties​

Count​

Int32: Gets the total count of tasks to be processed.

CurrentIndex​

Int32: Gets the current index of the task being processed.

Methods​

OnProgress(args)​

Raises the Progress event.

ParameterTypeDescription
argsEventArgsThe event data.

RunAsync(hub, inputs)​

Executes the prompt tasks asynchronously in parallel.

ParameterTypeDescription
hubSmartHubThe smart hub used for executing the tasks.
inputsString[]An array of input strings for the tasks.

Returns: Task<Message[]>. A task that represents the asynchronous operation. The task result contains an array of Message objects.

This method runs each input through the AskAsync method and tracks the progress using the CurrentIndex property.


var smartPrompt = new SmartParallelPrompt();
var messages = await smartPrompt.RunAsync(hub, new string[] { "input1", "input2" });

Throws:

Events​

Progress​

EventHandler Occurs when progress is made in the execution of the parallel tasks.

Implements​

NameDescription
IToolProviderRepresents a provider that supplies tools.