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.
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.
Returns: Task<Message>. A task representing the asynchronous operation, with a Message result.
Throws:
ArgumentNullException Thrown when the hub or question is null.
AskAsync(endpoint, question, image)

Asynchronously asks a question using the specified smart endpoint.
Returns: Task<Message>. A task representing the asynchronous operation, with a Message result.
Throws:
ArgumentNullException Thrown when the endpoint or question is null.
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.
Returns: SmartPrompt. The current SmartPrompt instance.
Throws:
ArgumentNullException Thrown when the tool is null.
RemoveTools(target)

Removes the tools from the specified object.
Returns: SmartPrompt. The current SmartPrompt instance.
ResolvePrompt(key)

Resolves the prompt text for the specified key.
Returns: String. The resolved prompt text, or the key if not found.
SavePrompts(filePath)

Saves the prompts to the specified file path.
UseTool(tool)

Adds a tool to the smart prompt.
Returns: SmartPrompt. The current SmartPrompt instance.
Throws:
ArgumentNullException Thrown when the tool is null.
UseTools(target)

Uses the tools from the specified target object.
Returns: SmartPrompt. The current SmartPrompt instance.
Inherited By
TODO:
Represents a smart parallel prompt that can execute multiple tasks concurrently.
Implements
Represents a provider that supplies tools.
Last updated