blazor-devexpress-dot-aiintegration-dot-blazor-dot-chat-dot-dxaichat-6035c465.md
Specifies a template used to display function call details appended to a message when the IncludeFunctionCallInfo property is enabled.
Namespace : DevExpress.AIIntegration.Blazor.Chat
Assembly : DevExpress.AIIntegration.Blazor.Chat.v25.2.dll
NuGet Package : DevExpress.AIIntegration.Blazor.Chat
[Parameter]
public RenderFragment<BlazorChatMessage> FunctionCallInfoContentTemplate { get; set; }
| Type | Description |
|---|---|
| RenderFragment<BlazorChatMessage> |
The content of a message bubble.
|
Enable the IncludeFunctionCallInfo property to automatically append basic details about each invoked function to the AI chat response.
Use the FunctionCallInfoContentTemplate property to customize the appearance of the function call details section. This template does not affect how the main message content is rendered.
@using DevExpress.AIIntegration.Blazor.Chat
@using DevExpress.AIIntegration.Tools
@inject AIToolsContextContainer aiToolsContextContainer
<DxAIChat IncludeFunctionCallInfo="true">
<FunctionCallInfoContentTemplate>
<ul>
@foreach(var functionCall in context.FunctionCalls) {
<li>
Called function: <b>@functionCall.Request.Name</b>
Return value: <b>@functionCall.Result.Result.ToString()</b>
</li>
}
</ul>
</FunctionCallInfoContentTemplate>
</DxAIChat>
@code {
protected override void OnAfterRender(bool firstRender) {
if(firstRender) {
var context = new AIToolsContextBuilder()
.WithToolMethods(MyAITools.Greet, MyAITools.AddNumbers)
.Build();
aiToolsContextContainer.Add(context);
}
}
}
using DevExpress.AIIntegration;
using System.ComponentModel;
public class MyAITools
{
[AIIntegrationTool("Generic_Greeting")]
[Description("Greets a user with their name.")]
public static string Greet(
[Description("The name of the user.")] string name) {
var now = DateTime.Now;
if(now.Hour < 7)
return $"Good night, {name}!";
else if(now.Hour < 12)
return $"Good morning, {name}!";
else if(now.Hour < 18)
return $"Good afternoon, {name}!";
else
return $"Good evening, {name}!";
}
[AIIntegrationTool("Generic_Calculator")]
[Description("Adds two numbers.")]
public static int AddNumbers(
[Description("First number")] int a,
[Description("Second number")] int b) {
return a + b;
}
}
using Azure.AI.OpenAI;
using DevExpress.AIIntegration;
using Microsoft.Extensions.AI;
using System.ClientModel;
/* ... */
AzureOpenAIClient azureOpenAIClient = new(
new Uri(azureOpenAiEndpoint),
new ApiKeyCredential(azureOpenAiKey)
);
IChatClient azureOpenAIChatClient = azureOpenAIClient.GetChatClient(azureOpenAiModel).AsIChatClient();
builder.Services.AddScoped((sp) => {
return azureOpenAIChatClient.AsBuilder()
.UseDXTools()
.UseFunctionInvocation()
.Build(sp);
});
builder.Services.AddDevExpressAI();
builder.Services.AddDevExpressBlazor();
See Also