# SmartPrompt

Namespace: **Wisej.AI**

Assembly: **Wisej.AI** (3.5.0.0)

* [SmartObject](/ai/components/api/wisej.ai.smartobject.md)
  * [SmartPrompt](/ai/components/api/smartprompt.md)

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

{% tabs %}
{% tab title="C#" %}

```csharp
public class SmartPrompt : SmartObject, IToolProvider, ICloneable
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class SmartPrompt
    Inherits SmartObject
    Implements IToolProvider, ICloneable
```

{% endtab %}
{% endtabs %}

The [SmartPrompt](/ai/components/api/smartprompt.md) class provides functionality to manage prompts, tools, and parameters. It supports cloning and asynchronous operations to ask questions using a smart hub or endpoint.

```csharp

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

### ![](/files/ptrKjmmRoQB76pvrIqh0) SmartPrompt(text)

Initializes a new instance of the [SmartPrompt](/ai/components/api/smartprompt.md) class with the specified text.

| Name     | Type                                                          | Description                                         |
| -------- | ------------------------------------------------------------- | --------------------------------------------------- |
| **text** | [String](https://docs.microsoft.com/dotnet/api/system.string) | The initial text for the prompt. Default is `null`. |

## Properties

### ![](/files/6srAlWaUVvAWWpvmGKFp) PromptDictionaries

[IList\<IDictionary\<String, String>>](https://docs.microsoft.com/dotnet/api/system.collections.generic.ilist-1): Gets the collection of prompt dictionaries.

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

### ![](/files/ptrKjmmRoQB76pvrIqh0) Text

[String](https://docs.microsoft.com/dotnet/api/system.string): Gets or sets the text of the smart prompt. (Default: `null`)

The text is resolved using the [ResolvePrompt](#resolveprompt-key) method.

## Methods

### ![](/files/ptrKjmmRoQB76pvrIqh0) AskAsync(hub, question, image)

Asynchronously asks a question using the specified smart hub.

| Parameter                                  | Type                                                                | Description                                                      |
| ------------------------------------------ | ------------------------------------------------------------------- | ---------------------------------------------------------------- |
| **hub**                                    | [SmartHub](/ai/components/api/smarthub.md)                          | The smart hub to use.                                            |
| **question**                               | [String](https://docs.microsoft.com/dotnet/api/system.string)       | The question to ask.                                             |
| **image** ![](/files/52BqKf9SltWQ97FbQSBF) | [Image](https://docs.microsoft.com/dotnet/api/system.drawing.image) | An optional image to include in the question. Default is `null`. |

**Returns:** [Task\<Message>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task representing the asynchronous operation, with a [Message](/ai/components/api/smartsession/wisej.ai.smartsession.message.md) result.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the hub or question is null.

### ![](/files/ptrKjmmRoQB76pvrIqh0) AskAsync(endpoint, question, image)

Asynchronously asks a question using the specified smart endpoint.

| Parameter                                  | Type                                                                | Description                                      |
| ------------------------------------------ | ------------------------------------------------------------------- | ------------------------------------------------ |
| **endpoint**                               | [SmartEndpoint](/ai/components/api/smartendpoint.md)                | The smart endpoint to use.                       |
| **question**                               | [String](https://docs.microsoft.com/dotnet/api/system.string)       | The question to ask.                             |
| **image** ![](/files/52BqKf9SltWQ97FbQSBF) | [Image](https://docs.microsoft.com/dotnet/api/system.drawing.image) | An optional image to include. Default is `null`. |

**Returns:** [Task\<Message>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task representing the asynchronous operation, with a [Message](/ai/components/api/smartsession/wisej.ai.smartsession.message.md) result.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the endpoint or question is null.

### ![](/files/ptrKjmmRoQB76pvrIqh0) Clone()

Creates a new instance of the [SmartPrompt](/ai/components/api/smartprompt.md) class that is a copy of the current instance.

**Returns:** [SmartPrompt](/ai/components/api/smartprompt.md). A new [SmartPrompt](/ai/components/api/smartprompt.md) object that is a copy of this instance.

### ![](/files/ptrKjmmRoQB76pvrIqh0) RemoveTool(tool)

Removes a tool from the smart prompt.

| Parameter | Type                                                              | Description         |
| --------- | ----------------------------------------------------------------- | ------------------- |
| **tool**  | [Delegate](https://docs.microsoft.com/dotnet/api/system.delegate) | The tool to remove. |

**Returns:** [SmartPrompt](/ai/components/api/smartprompt.md). The current [SmartPrompt](/ai/components/api/smartprompt.md) instance.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the tool is null.

### ![](/files/ptrKjmmRoQB76pvrIqh0) RemoveTools(target)

Removes the tools from the specified object.

| Parameter  | Type                                                          | Description                         |
| ---------- | ------------------------------------------------------------- | ----------------------------------- |
| **target** | [Object](https://docs.microsoft.com/dotnet/api/system.object) | The target object containing tools. |

**Returns:** [SmartPrompt](/ai/components/api/smartprompt.md). The current [SmartPrompt](/ai/components/api/smartprompt.md) instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) ResolvePrompt(key)

Resolves the prompt text for the specified key.

| Parameter | Type                                                          | Description         |
| --------- | ------------------------------------------------------------- | ------------------- |
| **key**   | [String](https://docs.microsoft.com/dotnet/api/system.string) | The key to resolve. |

**Returns:** [String](https://docs.microsoft.com/dotnet/api/system.string). The resolved prompt text, or the key if not found.

### ![](/files/6srAlWaUVvAWWpvmGKFp) SavePrompts(filePath)

Saves the prompts to the specified file path.

| Parameter    | Type                                                          | Description                           |
| ------------ | ------------------------------------------------------------- | ------------------------------------- |
| **filePath** | [String](https://docs.microsoft.com/dotnet/api/system.string) | The file path to save the prompts to. |

### ![](/files/ptrKjmmRoQB76pvrIqh0) UseTool(tool)

Adds a tool to the smart prompt.

| Parameter | Type                                                              | Description      |
| --------- | ----------------------------------------------------------------- | ---------------- |
| **tool**  | [Delegate](https://docs.microsoft.com/dotnet/api/system.delegate) | The tool to add. |

**Returns:** [SmartPrompt](/ai/components/api/smartprompt.md). The current [SmartPrompt](/ai/components/api/smartprompt.md) instance.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the tool is null.

### ![](/files/ptrKjmmRoQB76pvrIqh0) UseTools(target)

Uses the tools from the specified target object.

| Parameter  | Type                                                          | Description                         |
| ---------- | ------------------------------------------------------------- | ----------------------------------- |
| **target** | [Object](https://docs.microsoft.com/dotnet/api/system.object) | The target object containing tools. |

**Returns:** [SmartPrompt](/ai/components/api/smartprompt.md). The current [SmartPrompt](/ai/components/api/smartprompt.md) instance.

## Inherited By

| Name                                                                                  | Description                                                                      |
| ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| [SmartAgentPrompt](/ai/components/api/smartprompt/wisej.ai.smartagentprompt.md)       | TODO:                                                                            |
| [SmartParallelPrompt](/ai/components/api/smartprompt/wisej.ai.smartparallelprompt.md) | Represents a smart parallel prompt that can execute multiple tasks concurrently. |

## Implements

| Name                                                                              | Description                                |
| --------------------------------------------------------------------------------- | ------------------------------------------ |
| [IToolProvider](/ai/components/api/smarttool/wisej.ai.smarttool.itoolprovider.md) | Represents a provider that supplies tools. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/ai/components/api/smartprompt.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
