Skip to content

Allow detecting no input constraints support ahead of time? #151

@domenic

Description

@domenic

As we work on implementing support for the prompt API on Android, there is a chance that at least our initial version won't support RegExp or JSON schema constraints.

We are hopeful that this can be quickly fixed, and if so, there is no action for this issue. However, if there are platforms that cannot support input constraints, then we might want to consider an API for detecting this. (For example, if someone wanted to create a version of the prompt API wrapping the Anthropic HTTP API, I believe it would not be able to support RegExp constraints.)

That is, instead of the developer creating a session, and then realizing via repeated "NotSupportedError" DOMExceptions that regexp or JSON schema constraints are not supported, they could do something like

const availability = await LanguageModel.availability({ expectedInputConstraints: ["regexp", "json-schema"] });

// or, just create the session, but fail fast at creation time if it's not supported:
const session = await LanguageModel.create({ expectedInputConstraints: ["regexp", "json-schema"] });

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