Skip to main content

MarkupExtensions

Namespace: Wisej.AI

Assembly: Wisej.AI

Provides extension methods for configuring and handling events on SmartEndpoint, SmartHttpEndpoint, SmartHub, and SmartSession objects.

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.

ParameterTypeDescription
TA type derived from SmartHttpEndpoint.
endpointTThe HTTP endpoint to configure.
valueStringThe API key.

Returns: T. The configured HTTP endpoint instance.

Authentication<T>(endpoint, value)

Sets the authentication string for the specified HTTP endpoint.

ParameterTypeDescription
TA type derived from SmartHttpEndpoint.
endpointTThe HTTP endpoint to configure.
valueStringThe authentication string.

Returns: T. The configured HTTP endpoint instance.

ContextWindow<T>(endpoint, value)

Sets the context window size for the specified endpoint.

ParameterTypeDescription
TA type derived from SmartEndpoint.
endpointTThe endpoint to configure.
valueInt32The context window size.

Returns: T. The configured endpoint instance.

EmbeddingModel<T>(endpoint, value)

Sets the embedding model for the specified endpoint.

ParameterTypeDescription
TA type derived from SmartEndpoint.
endpointTThe endpoint to configure.
valueStringThe embedding model name.

Returns: T. The configured endpoint instance.

Headers<T>(endpoint, value)

Sets the HTTP headers for the specified HTTP endpoint.

ParameterTypeDescription
TA type derived from SmartHttpEndpoint.
endpointTThe HTTP endpoint to configure.
valueNameValueCollectionA 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.

ParameterTypeDescription
TA type derived from SmartEndpoint.
endpointTThe endpoint to configure.
valueInt32The maximum number of output tokens.

Returns: T. The configured endpoint instance.

Model<T>(endpoint, value)

Sets the model name for the specified endpoint.

ParameterTypeDescription
TA type derived from SmartEndpoint.
endpointTThe endpoint to configure.
valueStringThe model name to assign.

Returns: T. The configured endpoint instance.

Name<T>(endpoint, value)

Sets the name for the specified endpoint.

ParameterTypeDescription
TA type derived from SmartEndpoint.
endpointTThe endpoint to configure.
valueStringThe name to assign.

Returns: T. The configured endpoint instance.

OnAfterInvokeTool<T>(object, action)

Subscribes to the AfterInvokeTool event on the specified object.

ParameterTypeDescription
TA type derived from SmartObject.
objectTThe SmartObject to subscribe to.
actionAction<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.

ParameterTypeDescription
TA type derived from SmartObject.
objectTThe SmartObject to subscribe to.
actionAction<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.

ParameterTypeDescription
TA type derived from SmartObject.
objectTThe SmartObject to subscribe to.
actionAction<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.

ParameterTypeDescription
TA type derived from SmartObject.
objectTThe SmartObject to subscribe to.
actionAction<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.

ParameterTypeDescription
TA type derived from SmartObject.
objectTThe SmartObject to subscribe to.
actionAction<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.

ParameterTypeDescription
TA type derived from SmartObject.
objectTThe SmartObject to subscribe to.
actionActionThe 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.

ParameterTypeDescription
TA type derived from SmartObject.
objectTThe SmartObject to subscribe to.
actionAction<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.

ParameterTypeDescription
TA type derived from SmartObject.
objectTThe SmartObject to subscribe to.
actionAction<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.

ParameterTypeDescription
TA type derived from SmartObject.
objectTThe SmartObject to subscribe to.
actionActionThe 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.

ParameterTypeDescription
TA type derived from SmartHttpEndpoint.
endpointTThe HTTP endpoint to configure.
valueInt32The retry delay in milliseconds.

Returns: T. The configured HTTP endpoint instance.

SystemPrompt<T>(endpoint, value)

Sets the system prompt for the specified endpoint.

ParameterTypeDescription
TA type derived from SmartEndpoint.
endpointTThe endpoint to configure.
valueStringThe system prompt text.

Returns: T. The configured endpoint instance.

Text<T>(prompt, value)

Sets the Text for the specified SmartPrompt.

ParameterTypeDescription
TA type derived from SmartPrompt.
promptTThe SmartPrompt to configure.
valueStringThe text string.

Returns: T. The configured SmartPrompt instance.

URL<T>(endpoint, value)

Sets the URL for the specified HTTP endpoint.

ParameterTypeDescription
TA type derived from SmartHttpEndpoint.
endpointTThe HTTP endpoint to configure.
valueStringThe URL to assign.

Returns: T. The configured HTTP endpoint instance.

UseNativeTools<T>(endpoint, value)

Specifies whether to use native tools for the specified endpoint.

ParameterTypeDescription
TA type derived from SmartEndpoint.
endpointTThe endpoint to configure.
valueBooleanTrue to use native tools; otherwise, false.

Returns: T. The configured endpoint instance.