SmartPrompt

Wisej.AI.SmartPrompt

Namespace: Wisej.AI

Assembly: Wisej.AI (3.5.0.0)

Represents a smart prompt component that can process and manage prompts with tools and parameters.

public class SmartPrompt : SmartObject, IToolProvider, ICloneable

The SmartPrompt class provides functionality to manage prompts, tools, and parameters. It supports cloning and asynchronous operations to ask questions using a smart hub or endpoint.


SmartPrompt prompt = new SmartPrompt("You are a weather expert");
prompt.Start += (s, e) => Console.WriteLine("Processing started.");
prompt.Done += (s, e) => Console.WriteLine("Processing done.");
await prompt.AskAsync(new OpenAIEndpoint(), "What is the weather today?");

Constructors

SmartPrompt(text)

Initializes a new instance of the SmartPrompt class with the specified text.

Name
Type
Description

text

The initial text for the prompt. Default is null.

Properties

PromptDictionaries

IList<IDictionary<String, String>>: Gets the collection of prompt dictionaries.

The prompt dictionaries are loaded from the AI directory and embedded resources.

Text

String: Gets or sets the text of the smart prompt. (Default: null)

The text is resolved using the ResolvePrompt method.

Methods

AskAsync(hub, question, image)

Asynchronously asks a question using the specified smart hub.

Parameter
Type
Description

hub

The smart hub to use.

question

The question to ask.

image

An optional image to include in the question. Default is null.

Returns: Task<Message>. A task representing the asynchronous operation, with a Message result.

Throws:

AskAsync(endpoint, question, image)

Asynchronously asks a question using the specified smart endpoint.

Parameter
Type
Description

endpoint

The smart endpoint to use.

question

The question to ask.

image

An optional image to include. Default is null.

Returns: Task<Message>. A task representing the asynchronous operation, with a Message result.

Throws:

Clone()

Creates a new instance of the SmartPrompt class that is a copy of the current instance.

Returns: SmartPrompt. A new SmartPrompt object that is a copy of this instance.

RemoveTool(tool)

Removes a tool from the smart prompt.

Parameter
Type
Description

tool

The tool to remove.

Returns: SmartPrompt. The current SmartPrompt instance.

Throws:

RemoveTools(target)

Removes the tools from the specified object.

Parameter
Type
Description

target

The target object containing tools.

Returns: SmartPrompt. The current SmartPrompt instance.

ResolvePrompt(key)

Resolves the prompt text for the specified key.

Parameter
Type
Description

key

The key to resolve.

Returns: String. The resolved prompt text, or the key if not found.

SavePrompts(filePath)

Saves the prompts to the specified file path.

Parameter
Type
Description

filePath

The file path to save the prompts to.

UseTool(tool)

Adds a tool to the smart prompt.

Parameter
Type
Description

tool

The tool to add.

Returns: SmartPrompt. The current SmartPrompt instance.

Throws:

UseTools(target)

Uses the tools from the specified target object.

Parameter
Type
Description

target

The target object containing tools.

Returns: SmartPrompt. The current SmartPrompt instance.

Inherited By

Name
Description

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

Implements

Name
Description

Represents a provider that supplies tools.

Last updated