Method WithIdentity
WithIdentity(string, string)
Sets both persona and instruction for the agent.
public AgentBuilder WithIdentity(string persona, string instruction)
Parameters
Returns
- AgentBuilder
This builder instance for method chaining.
Examples
Setting identity in one call:
using LMKit.Model;
using LMKit.Agents;
using var model = new LM("path/to/model.gguf");
var agent = new AgentBuilder()
.WithModel(model)
.WithIdentity(
persona: "Financial Advisor",
instruction: "Provide general financial education and guidance. " +
"Always recommend consulting a licensed professional " +
"for specific financial decisions."
)
.Build();
Remarks
This is a convenience method combining WithPersona(string) and WithInstruction(string) in a single call.
WithIdentity(AgentIdentity)
Sets the agent's identity from an existing AgentIdentity instance.
public AgentBuilder WithIdentity(AgentIdentity identity)
Parameters
identityAgentIdentityThe identity to use.
Returns
- AgentBuilder
This builder instance for method chaining.
Examples
Using a shared identity:
using LMKit.Model;
using LMKit.Agents;
// Define a reusable identity
var supportIdentity = new AgentIdentity(
persona: "Customer Support Agent",
instruction: "Help customers resolve issues. Be patient and thorough."
);
using var model = new LM("path/to/model.gguf");
// Create multiple agents with the same identity
var agent1 = new AgentBuilder()
.WithModel(model)
.WithIdentity(supportIdentity)
.Build();
var agent2 = new AgentBuilder()
.WithModel(model)
.WithIdentity(supportIdentity)
.WithPlanning(PlanningStrategy.ChainOfThought)
.Build();
Remarks
Use this overload when you have a pre-configured identity or want to share identity definitions across multiple agents.