You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
User (jotclem): Raised a concern about the JSON Schema definition used by the library, specifically Schema.NullOr(Foo) using #/defs/null defined as type: { const null }. The user pointed out that this might be invalid JSON Schema and suggested it should just be "null".
Reference:
User (jotclem): Provided a link to the JSON Schema documentation on null types.
Compatibility Issue:
User (jotclem): Mentioned that the current schema definitions don"t work with OpenAI"s new structured output.
Support for const:
User (timsmart): Questioned whether OpenAI supports const and suggested that the schema seemed valid.
Annotations as a Solution:
User (timsmart): Provided a workaround using annotations to override the output schema.
Acknowledgment:
User (jotclem): Acknowledged the usefulness of annotations and noted that OpenAI does not support const.
Validity of const: null:
User (jotclem): Expressed uncertainty about the validity of const: null in JSON Schema but later confirmed its validity by referencing the actual spec.
Final Suggestion:
User (gcanti): Suggested that since const is functionally equivalent to an enum with a single value, the library could switch from const to enum.
Key Takeaways:
JSON Schema Validity:
const: null is valid JSON Schema, but it might not be supported by all systems, such as OpenAI"s structured output.
Annotations:
Annotations can be used as a workaround to customize JSON Schema outputs, which can help in making schemas compatible with systems that do not support certain keywords like const.
Switching to enum:
Since const is equivalent to an enum with a single value, switching to enum might be a more universally compatible solution.
Library Flexibility:
The library"s current behavior is considered acceptable, but providing escape hatches like annotations is crucial for flexibility and compatibility with different systems.
gcanti
changed the title
From Discord: JSONSchema Null Type Definition Error: Use "null" Instead of #/defs/null
From Discord: make json schema output more compatible with Open AI structured output
Aug 8, 2024
Summary
Summary of the Conversation:
Initial Issue:
Schema.NullOr(Foo)
using#/defs/null
defined astype: { const null }
. The user pointed out that this might be invalid JSON Schema and suggested it should just be"null"
.Reference:
Compatibility Issue:
Support for
const
:const
and suggested that the schema seemed valid.Annotations as a Solution:
Acknowledgment:
const
.Validity of
const: null
:const: null
in JSON Schema but later confirmed its validity by referencing the actual spec.Final Suggestion:
const
is functionally equivalent to anenum
with a single value, the library could switch fromconst
toenum
.Key Takeaways:
JSON Schema Validity:
const: null
is valid JSON Schema, but it might not be supported by all systems, such as OpenAI"s structured output.Annotations:
const
.Switching to
enum
:const
is equivalent to anenum
with a single value, switching toenum
might be a more universally compatible solution.Library Flexibility:
Discord thread
https://discord.com/channels/795981131316985866/1270605840730165289
The text was updated successfully, but these errors were encountered: