Skip to content

Question

Namespace: TypeSafe.AI.Sdk

public abstract class Question

A TypeSafe question identified by its type field.

Inheritance: object

Derived: BoxQuestion, ChoiceQuestion, NoulQuestion, ScoreQuestion

View source

public object? Instructions { get; }

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

Value: object

View source

public abstract string Type { get; }

Question type: noul, choice, score, or box.

Value: string

View source

public static BoxQuestion Box(object? instructions = null)

Create a question that locates what its instructions describe in the request’s image. Mirrors JS box(). Use the jev-preview model for box questions.

Parameters

Name Type Description
instructions object What to locate, as text, an asset, a JSON object or array; defaults to null.

Returns: BoxQuestion

View source

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

Section titled “Choice(object?, Dictionary<string, object?>)”
public static ChoiceQuestion Choice(object? instructions, Dictionary<string, object?> criteria)

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

Parameters

Name Type Description
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

View source

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

Section titled “Choice(object?, IReadOnlyDictionary<string, object?>)”
public static ChoiceQuestion Choice(object? instructions, IReadOnlyDictionary<string, object?> criteria)

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

Parameters

Name Type Description
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

View source

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

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

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

Parameters

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

Returns: ChoiceQuestion

View source

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

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

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).

Parameters

Name Type Description
questions (string Name, Question Question)[]

Returns: Dictionary<string, Question>

View source

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

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

Parameters

Name Type Description
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

View source

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

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

Parameters

Name Type Description
instructions object
criteria NoulCriteria
includeCriteria bool

Returns: NoulQuestion

View source

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

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

Parameters

Name Type Description
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

View source

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

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

Parameters

Name Type Description
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

View source

Validate(IReadOnlyDictionary<string, Question>)

Section titled “Validate(IReadOnlyDictionary<string, Question>)”
public static void Validate(IReadOnlyDictionary<string, Question> questions)

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

Parameters

Name Type Description
questions IReadOnlyDictionary<string, Question>

View source

MIT · Copyright (c) Dario Kondratiuk. · not affiliated with TypeSafe beyond being a client of the public API