Skip to content

Provide more visibility into lower-level schema representations from python #242

@HansBrende

Description

@HansBrende

There are two things that I would love to be able to do from the python bindings:

  1. Given a jsonschema, normalize it (e.g., remove the allOf etc.) and give me back the normalized Schema (even a simple debug-stringified version of the final internal Schema instance would be better than nothing, but preferably, allow me to access the actual Schema object itself so I can recurse over it in any way I want.)

Why: Given that OpenAI is also using this library for structured outputs, this would allow me to quickly sanity-check all my relevant schemas before I send them off to OpenAI to make sure they are how I want them to look before they get turned into a grammar.

  1. Given a jsonschema (or Schema, if (1) allows me to access it), give me back the final low-level grammar representation of that schema (again, even a simple debug output would be totally great)

Why: this would allow me even more visibility into the schemas I write to make sure the grammar makes sense, and if not, to tweak the schemas as necessary.

I spent some time digging into the existing python bindings and I can't figure out any way to do either of these things (I thought for sure LLMatcher.grammar_from_json_schema() would work but that just gives me back the same schema I put in, except wrapped in a "grammars" array). But if there is a way that I've missed, please let me know.

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