AgentBlazor Docs

Getting Started

From package source to one working workflow.

Manual setup is the default path. Use the CLI only when you want scaffold help for an existing app.

Install the package

dotnet add ./src/MyBlazorApp/MyBlazorApp.csproj package AgentBlazor --version 0.1.0-preview.11

Default install path

dotnet add ./src/MyBlazorApp/MyBlazorApp.csproj package AgentBlazor --version 0.1.0-preview.11

builder.Services.AddMudServices();
builder.Services.AddAgentBlazor(options => { ... });
app.MapAgentBlazorEndpoints();

// You must also register one workflow agent.
options.ConfigureBuilder(agentBuilder =>
{
    agentBuilder.AddWorkflow<HelloWorkflow>("hello-workflow");
});

@using AgentBlazor.Components
<AgentChatWidget @rendermode="InteractiveServer" Title="Hello workflow" />

Manual runtime path

builder.Services.AddMudServices();

builder.Services.AddAgentBlazor(options =>
{
    options.UseOpenAI(
        apiKey: builder.Configuration["OpenAI:ApiKey"]!,
        model: builder.Configuration["OpenAI:Model"]!);

    options.ConfigureBuilder(agentBuilder =>
    {
        agentBuilder.AddWorkflow<SupportInboxCapabilities>("support-inbox", agent =>
        {
            agent.WithRoutePrefixes("/support");
        });
    });
});

var app = builder.Build();
app.MapAgentBlazorEndpoints();

Advanced CLI path

dotnet tool install --global AgentBlazor.Cli --version 0.1.0-preview.11
agentblazor init ./MySolution.slnx --host MyBlazorApp
agentblazor scaffold ./MySolution.slnx --host MyBlazorApp --provider openai --diff
agentblazor scaffold ./MySolution.slnx --host MyBlazorApp --provider openai --approve
dotnet restore ./MySolution.slnx --force-evaluate
dotnet build ./MySolution.slnx --no-restore -nologo

Hosted WebAssembly client path

dotnet add ./src/MyBlazorApp.Client/MyBlazorApp.Client.csproj package AgentBlazor.Client --version 0.1.0-preview.11

// Server
app.MapAgentBlazorEndpoints();
app.MapAgentBlazorRemoteChat();

// Client
builder.Services.AddScoped(_ => new HttpClient
{
    BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
});

@using AgentBlazor.Client.Chat
<AgentRemoteChatWidget Endpoint="/agentblazor/chat/run" Title="Assistant" />

Next step

An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.