AIExtensionsContainerDesktop.QueryIAIExtensionsContainer Event
Fires before a request is sent to the AI service and allows you to specify the AI service container to process the request.
Namespace: DevExpress.AIIntegration
Assembly: DevExpress.AIIntegration.Desktop.v24.2.dll
NuGet Package: DevExpress.AIIntegration.Desktop
#Declaration
public static event EventHandler<AIExtensionsContainerQueryEventArgs> QueryIAIExtensionsContainer
#Event Data
The QueryIAIExtensionsContainer event's data class is DevExpress.AIIntegration.AIExtensionsContainerQueryEventArgs.
#Remarks
Handle the QueryIAIExtensionsContainer
event to switch between default and local AI service containers to process the request.
Event Argument | Type | Description |
---|---|---|
e. |
IAIExtensions |
Gets or sets the AI service container that will handle the request. |
e. |
object |
The target DevExpress UI control that initiated the AI request. |
The following code snippet handles the QueryIAIExtensionsContainer
event to use the WilliamShakespeareStyleExtension
only when requests are initiated by the richEditControl
:
using DevExpress.AIIntegration;
var localContainer = new AIExtensionsContainerLocal(AIExtensionsContainerDesktop.Default);
localContainer.Register<ChangeStyleRequest, WilliamShakespeareStyleExtension>();
AIExtensionsContainerDesktop.QueryIAIExtensionsContainer += (s, e) => {
if (e.Source == richEditControl)
e.Container = localContainer;
};
// ...
// A custom extension based on the DevExpress ChangeStyleExtension.
// The example overrides the GetSystemPrompt method to customize the pre-built prompt.
public class WilliamShakespeareStyleExtension : ChangeStyleExtension {
public WilliamShakespeareStyleExtension(IServiceProvider serviceProvider) : base(serviceProvider) { }
protected override string GetSystemPrompt(ChangeStyleRequest request) {
return "Rewrite this text in the William Shakespeare style.";
}
}