-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
OpenAI structured outputs support #1307
Comments
By the way, OpenAI understands only understands the |
Also, about the The Therefore, if you want to contribute to Here is the code filling the typia/src/programmers/internal/llm_schema_object.ts Lines 98 to 121 in 8edeef5
|
I haven't found any info about if OpenAI supporting |
For example, the OpenAPI SDK has the following unit tests: https://github.com/openai/openai-python/blob/aeaed488352274a9ca86c834eeb618d732989518/tests/lib/test_pydantic.py#L65 no references to oneOf unfortunately. |
How about the other models? In the Google Gemini case, it is using the OpenAPI v3.0.3 specified JSON schema, but not supporting
OpenAI, it sometimes looks like using OpenAPI v3.1, and sometimes v3.0. It supports mixed-in types embodied by |
To support LLM function calling feature exactly, I should separate the providers like below.
|
@antoniomdk If you send an PR about Also, about the manipulating specific LLM provider's schema, I'll prepare the major update. It would be |
@samchon That sounds great! I think the LLM-specific separation makes a lot of sense. I'll send a PR for |
Related to LLM structured outputs, I find that when prompting I often want to use the jsdoc comment for a type in the prompt. Can typia add a misc method for returning the jsdoc string of a particular type. Using |
@antoniomdk, @bradleat https://github.com/samchon/openapi/blob/v2.0/src/structures/IChatGptSchema.ts I'm preparing the OpenAI dedicated schema type as Here is the type, and I'll test it by using the ChatGPT API, and considering below things.
If you want to experience it earlier, install npm install typia@next |
Feature Request
I've been working with
typia.llm.schema
for a while and it has been extremely helpful in generating JSON schemas to call LLMs from TS types. However, the new structured outputs API of OpenAI has some limitations in the type of schemas it can take.In particular
nullable
is not been taken into account. So it'd be great if we could map typesX | null
toanyOf
. Maybe introducing a new flag to thetypia.llm.schema
function.Also, for types that don't extend from Record, we should mark
[additionalProperties to false](https://platform.openai.com/docs/guides/structured-outputs/additionalproperties-false-must-always-be-set-in-objects)
.I can contribute to this feature, but I may need some pointers for code references to start.
The text was updated successfully, but these errors were encountered: