Property InferenceCount
InferenceCount
Gets the number of LLM inference calls made during execution.
public int InferenceCount { get; }
Property Value
Examples
Monitoring inference usage:
using LMKit.Model;
using LMKit.Agents;
using var model = new LM("path/to/model.gguf");
var agent = new Agent(model);
agent.EnsureTools().Register(new SearchTool());
agent.Planning = PlanningStrategy.ReAct;
var result = await agent.RunAsync("Research the latest trends in renewable energy.");
Console.WriteLine($"Task completed with {result.InferenceCount} inference calls.");
Console.WriteLine($"Tool calls: {result.ToolCalls.Count}");
// Estimate cost (example calculation)
double estimatedTokens = result.InferenceCount * 1000; // rough estimate
Console.WriteLine($"Estimated tokens: ~{estimatedTokens}");
Remarks
This count is useful for monitoring costs and understanding agent behavior. It includes both response generation and any tool-call resolution steps. A higher count typically indicates more complex reasoning or multiple tool interactions.