Description
The single most complex part of the current SDK type hinting is attempting to map from prediction API inputs to indicate whether or not the parsed
field on the prediction result is expected to contain a plain string (unstructured) or a parsed string-keyed dictionary (structured).
This mapping is already inaccurate, since it only works off the response_format
parameter input. If the response format is passed in via the config's structured
field, the parsed
field may still end up containing a string-keyed dictionary, but will type hint as containing a string (since response_format
will be None
).
Adding GBNF grammar response format support (#60) makes this problem worse, since passing in a GBNF grammar via the "response_format" field will type hint as producing a structured result, but it probably won't be a JSON result, and hence parsed
will probably contain a plain string, not a string-keyed dictionary.
All of the type hinting complexity related to this can be eliminated by hinting parsed
as a union type, rather than as a generic type variable.