Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

From Discord: make json schema output more compatible with Open AI structured output #3432

Closed
effect-bot opened this issue Aug 8, 2024 · 0 comments · Fixed by #3433 or #3447
Closed

Comments

@effect-bot
Copy link

Summary

Summary of the Conversation:

  1. Initial Issue:

    • 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".
  2. Reference:

    • User (jotclem): Provided a link to the JSON Schema documentation on null types.
  3. Compatibility Issue:

    • User (jotclem): Mentioned that the current schema definitions don"t work with OpenAI"s new structured output.
  4. Support for const:

    • User (timsmart): Questioned whether OpenAI supports const and suggested that the schema seemed valid.
  5. Annotations as a Solution:

    • User (timsmart): Provided a workaround using annotations to override the output schema.
  6. Acknowledgment:

    • User (jotclem): Acknowledged the usefulness of annotations and noted that OpenAI does not support const.
  7. 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.
  8. 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:

  1. JSON Schema Validity:

    • const: null is valid JSON Schema, but it might not be supported by all systems, such as OpenAI"s structured output.
  2. 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.
  3. Switching to enum:

    • Since const is equivalent to an enum with a single value, switching to enum might be a more universally compatible solution.
  4. 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.

Discord thread

https://discord.com/channels/795981131316985866/1270605840730165289

@gcanti gcanti self-assigned this Aug 8, 2024
@gcanti 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
gcanti added a commit that referenced this issue Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants