Table of Contents

Method CreateBuilder

Namespace
LMKit.Agents
Assembly
LM-Kit.NET.dll

CreateBuilder()

Creates a builder for constructing an agent with fluent configuration.

public static AgentBuilder CreateBuilder()

Returns

AgentBuilder

A new AgentBuilder instance.

Examples

Using the builder for complex agent configuration:

using LMKit.Model;
using LMKit.Agents;

using var model = new LM("path/to/model.gguf");

var agent = Agent.CreateBuilder() .WithModel(model) .WithPersona("Research Analyst") .WithInstruction("Conduct thorough research and provide citations.") .WithPlanning(PlanningStrategy.PlanAndExecute) .WithMaxIterations(20) .Build();

var result = await agent.RunAsync("Research the history of neural networks."); Console.WriteLine(result.Content);

CreateBuilder(LM)

Creates a builder initialized with the specified model.

public static AgentBuilder CreateBuilder(LM model)

Parameters

model LM

The language model to use.

Returns

AgentBuilder

A new AgentBuilder instance configured with the model.

Examples

Creating a tool-using agent with the builder:

using LMKit.Model;
using LMKit.Agents;
using LMKit.Agents.Tools;

using var model = new LM("path/to/model.gguf");

var agent = Agent.CreateBuilder(model) .WithIdentity("Smart Assistant", "Help users with various tasks using available tools.") .WithPlanning(PlanningStrategy.ReAct) .WithTools(tools => { tools.Register(new CalculatorTool()); tools.Register(new WeatherTool()); tools.Register(new WebSearchTool()); }) .WithToolPolicy(policy => { policy.Choice = ToolChoice.Auto; }) .Build();

var result = await agent.RunAsync("What is the weather in Paris, and what is 20% of the temperature in Fahrenheit?"); Console.WriteLine(result.Content);

Share