Skip to content

JSON mode #65

Closed
Closed
@scblaze

Description

@scblaze

It would be helpful if we could constrain the generated output to valid JSON.

A promptJSON function might make sense as the API. When used, it would constrain the model generation to valid JSON (potentially also parsing that into an object).

session.promptJson("List five cities and their populations, respond in jsdoc type format: {name: string, population: number}[]");

This would primarily be helpful to force the model to avoid extra description text such as:

Sure, your five cities are:

[{ "name": "New York...

Possibly in the future, a schema could be supplied that would further constrain output to match that schema (edit: requested in #35). Regardless of that, a general restriction to valid JSON would be very helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions