MarkupExtensions
Namespace: Wisej.AI
Assembly: Wisej.AI
Provides extension methods for configuring and handling events on SmartEndpoint, SmartHttpEndpoint, SmartHub, and SmartSession objects.
- C#
- VB.NET
public class MarkupExtensions
Public Class MarkupExtensions
The MarkupExtensions class offers a fluent API for setting properties and subscribing to events on various smart endpoint and session types. These extension methods enable concise and readable configuration of endpoints and event handlers.
Methods
ApiKey<T>(endpoint, value)
Sets the API key for the specified HTTP endpoint.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartHttpEndpoint. | |
| endpoint | T | The HTTP endpoint to configure. |
| value | String | The API key. |
Returns: T. The configured HTTP endpoint instance.
Authentication<T>(endpoint, value)
Sets the authentication string for the specified HTTP endpoint.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartHttpEndpoint. | |
| endpoint | T | The HTTP endpoint to configure. |
| value | String | The authentication string. |
Returns: T. The configured HTTP endpoint instance.
ContextWindow<T>(endpoint, value)
Sets the context window size for the specified endpoint.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartEndpoint. | |
| endpoint | T | The endpoint to configure. |
| value | Int32 | The context window size. |
Returns: T. The configured endpoint instance.
EmbeddingModel<T>(endpoint, value)
Sets the embedding model for the specified endpoint.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartEndpoint. | |
| endpoint | T | The endpoint to configure. |
| value | String | The embedding model name. |
Returns: T. The configured endpoint instance.
Headers<T>(endpoint, value)
Sets the HTTP headers for the specified HTTP endpoint.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartHttpEndpoint. | |
| endpoint | T | The HTTP endpoint to configure. |
| value | NameValueCollection | A NameValueCollection containing the headers. |
Returns: T. The configured HTTP endpoint instance.
MaxOutputTokens<T>(endpoint, value)
Sets the maximum number of output tokens for the specified endpoint.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartEndpoint. | |
| endpoint | T | The endpoint to configure. |
| value | Int32 | The maximum number of output tokens. |
Returns: T. The configured endpoint instance.
Model<T>(endpoint, value)
Sets the model name for the specified endpoint.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartEndpoint. | |
| endpoint | T | The endpoint to configure. |
| value | String | The model name to assign. |
Returns: T. The configured endpoint instance.
Name<T>(endpoint, value)
Sets the name for the specified endpoint.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartEndpoint. | |
| endpoint | T | The endpoint to configure. |
| value | String | The name to assign. |
Returns: T. The configured endpoint instance.
OnAfterInvokeTool<T>(object, action)
Subscribes to the AfterInvokeTool event on the specified object.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartObject. | |
| object | T | The SmartObject to subscribe to. |
| action | Action<InvokeToolEventArgs> | The action to invoke when the event is raised. |
Returns: T. The configured instance.
OnAfterResponseReceived<T>(object, action)
Subscribes to the AfterResponseReceived event on the specified object.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartObject. | |
| object | T | The SmartObject to subscribe to. |
| action | Action<MessagesEventArgs> | The action to invoke when the event is raised. |
Returns: T. The configured instance.
OnBeforeInvokeTool<T>(object, action)
Subscribes to the BeforeInvokeTool event on the specified object.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartObject. | |
| object | T | The SmartObject to subscribe to. |
| action | Action<InvokeToolEventArgs> | The action to invoke when the event is raised. |
Returns: T. The configured instance.
OnBeforeSendRequest<T>(object, action)
Subscribes to the BeforeSendRequest event on the specified object.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartObject. | |
| object | T | The SmartObject to subscribe to. |
| action | Action<MessagesEventArgs> | The action to invoke when the event is raised. |
Returns: T. The configured instance.
OnConvertParameter<T>(object, action)
Subscribes to the ConvertParameter event on the specified object.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartObject. | |
| object | T | The SmartObject to subscribe to. |
| action | Action<ConvertParameterEventArgs> | The action to invoke when the event is raised. |
Returns: T. The configured instance.
OnDone<T>(object, action)
Subscribes to the Done event on the specified object.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartObject. | |
| object | T | The SmartObject to subscribe to. |
| action | Action | The action to invoke when the event is raised. |
Returns: T. The configured instance.
OnError<T>(object, action)
Subscribes to the Error event on the specified object.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartObject. | |
| object | T | The SmartObject to subscribe to. |
| action | Action<ErrorEventArgs> | The action to invoke when the event is raised. |
Returns: T. The configured instance.
OnPrepareMessages<T>(object, action)
Subscribes to the PrepareMessage event on the specified object.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartObject. | |
| object | T | The SmartObject to subscribe to. |
| action | Action<MessagesEventArgs> | The action to invoke when the event is raised, receiving the event arguments. |
Returns: T. The configured instance.
OnStart<T>(object, action)
Subscribes to the Start event on the specified object.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartObject. | |
| object | T | The SmartObject to subscribe to. |
| action | Action | The action to invoke when the event is raised. |
Returns: T. The configured instance.
RetryDelay<T>(endpoint, value)
Sets the retry delay (in milliseconds) for the specified HTTP endpoint.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartHttpEndpoint. | |
| endpoint | T | The HTTP endpoint to configure. |
| value | Int32 | The retry delay in milliseconds. |
Returns: T. The configured HTTP endpoint instance.
SystemPrompt<T>(endpoint, value)
Sets the system prompt for the specified endpoint.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartEndpoint. | |
| endpoint | T | The endpoint to configure. |
| value | String | The system prompt text. |
Returns: T. The configured endpoint instance.
Text<T>(prompt, value)
Sets the Text for the specified SmartPrompt.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartPrompt. | |
| prompt | T | The SmartPrompt to configure. |
| value | String | The text string. |
Returns: T. The configured SmartPrompt instance.
URL<T>(endpoint, value)
Sets the URL for the specified HTTP endpoint.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartHttpEndpoint. | |
| endpoint | T | The HTTP endpoint to configure. |
| value | String | The URL to assign. |
Returns: T. The configured HTTP endpoint instance.
UseNativeTools<T>(endpoint, value)
Specifies whether to use native tools for the specified endpoint.
| Parameter | Type | Description |
|---|---|---|
| T | A type derived from SmartEndpoint. | |
| endpoint | T | The endpoint to configure. |
| value | Boolean | True to use native tools; otherwise, false. |
Returns: T. The configured endpoint instance.