Table of Contents

Method WithOutputSchema

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

WithOutputSchema(string)

Constrains every answer of the agent to a JSON Schema, enforced while decoding: the model may still call tools, and its final answer is a JSON document that conforms to the schema.

public AgentBuilder WithOutputSchema(string jsonSchema)

Parameters

jsonSchema string

The JSON Schema text (an object schema); null or empty for free text.

Returns

AgentBuilder

This builder instance for method chaining.

Examples

var agent = Agent.CreateBuilder(model)
    .WithInstruction("Triage the support ticket.")
    .WithOutputSchema(@"{""type"":""object"",""properties"":{""reply"":{""type"":""string""},""needs_human"":{""type"":""boolean""}},""required"":[""reply"",""needs_human""]}")
    .Build();

Exceptions

ArgumentException

Thrown when the schema cannot constrain an answer.

Share