Table of Contents

Class Question

Namespace
TypeSafe.AI.Sdk
Assembly
TypeSafe.AI.Sdk.dll

A TypeSafe question identified by its type field.

public abstract class Question
Inheritance
Question
Derived
Inherited Members

Properties

Instructions

The question as text, a JSON object, or an array. Omitted when the builder was not given instructions (except Noul(object?, NoulCriteria?), which defaults to null).

public object? Instructions { get; }

Property Value

object

Type

Question type: noul, choice, or score.

public abstract string Type { get; }

Property Value

string

Methods

Choice(object?, Dictionary<string, object?>)

Create a question that selects between named alternatives. Mirrors JS choice().

public static ChoiceQuestion Choice(object? instructions, Dictionary<string, object?> criteria)

Parameters

instructions object

The question as text, a JSON object or array, or null.

criteria Dictionary<string, object>

Labels mapped to descriptions, or null for undescribed labels.

Returns

ChoiceQuestion

Choice(object?, IReadOnlyDictionary<string, object?>)

Create a question that selects between named alternatives. Mirrors JS choice().

public static ChoiceQuestion Choice(object? instructions, IReadOnlyDictionary<string, object?> criteria)

Parameters

instructions object

The question as text, a JSON object or array, or null.

criteria IReadOnlyDictionary<string, object>

Labels mapped to descriptions, or null for undescribed labels.

Returns

ChoiceQuestion

Choice(object?, params (string Label, object? Description)[])

Create a question that selects between named alternatives, from label/description pairs. Duplicate labels throw. Pass a dictionary when you already have a map.

public static ChoiceQuestion Choice(object? instructions, params (string Label, object? Description)[] criteria)

Parameters

instructions object
criteria (string Label, object Description)[]

Returns

ChoiceQuestion

Map(params (string Name, Question Question)[])

Build a name → question map from labeled pairs. Duplicate names throw. Use this when you need a dictionary (for example Questions, or a model / cancellation token on the dictionary SystemOneAsync overload).

public static Dictionary<string, Question> Map(params (string Name, Question Question)[] questions)

Parameters

questions (string Name, Question Question)[]

Returns

Dictionary<string, Question>

Noul(object?, NoulCriteria?)

Create a yes/no question with optional descriptions for either outcome. Mirrors JS noul().

public static NoulQuestion Noul(object? instructions = null, NoulCriteria? criteria = null)

Parameters

instructions object

The question as text, a JSON object or array; defaults to null.

criteria NoulCriteria

Optional descriptions of the yes and no outcomes.

Returns

NoulQuestion

Noul(object?, NoulCriteria?, bool)

Create a yes/no question, including an explicit null criteria value on the wire.

public static NoulQuestion Noul(object? instructions, NoulCriteria? criteria, bool includeCriteria)

Parameters

instructions object
criteria NoulCriteria
includeCriteria bool

Returns

NoulQuestion

Score(object?, IReadOnlyList<object?>)

Create a score question using an ordered rubric. Mirrors JS score().

public static ScoreQuestion Score(object? instructions, IReadOnlyList<object?> criteria)

Parameters

instructions object

The question as text, a JSON object or array, or null.

criteria IReadOnlyList<object>

At least two descriptions indexed by score from zero; entries may be null.

Returns

ScoreQuestion

Score(object?, params object?[])

Create a score question using an ordered rubric. Mirrors JS score().

public static ScoreQuestion Score(object? instructions, params object?[] criteria)

Parameters

instructions object

The question as text, a JSON object or array, or null.

criteria object[]

At least two descriptions indexed by score from zero; entries may be null.

Returns

ScoreQuestion

Validate(IReadOnlyDictionary<string, Question>)

Reject empty question sets and score questions without a list of at least two criteria.

public static void Validate(IReadOnlyDictionary<string, Question> questions)

Parameters

questions IReadOnlyDictionary<string, Question>