Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wrtnio/openai-function-schema",
"version": "0.2.3",
"version": "0.2.4",
"description": "OpenAI LLM function schema from OpenAPI (Swagger) document",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -37,16 +37,16 @@
"author": "",
"license": "ISC",
"dependencies": {
"@nestia/fetcher": "^3.8.0",
"@samchon/openapi": "^0.4.2",
"@nestia/fetcher": "^3.10.0",
"@samchon/openapi": "^0.4.3",
"commander": "^10.0.0",
"inquirer": "^8.2.5",
"typia": "^6.5.4"
"typia": "^6.7.2"
},
"devDependencies": {
"@nestia/core": "^3.8.0",
"@nestia/core": "^3.10.0",
"@nestia/e2e": "^0.7.0",
"@nestia/sdk": "^3.8.0",
"@nestia/sdk": "^3.10.0",
"@nestjs/common": "^10.3.10",
"@nestjs/core": "^10.3.10",
"@nestjs/platform-express": "^10.3.10",
Expand Down
7 changes: 4 additions & 3 deletions src/OpenAiComposer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export namespace OpenAiComposer {
const downgraded: IOpenAiSchema = OpenApiV3Downgrader.downgradeSchema({
original: {},
downgraded: {},
})(escaped);
})(escaped) as IOpenAiSchema;
OpenAiTypeChecker.visit(downgraded, (schema) => {
if (
OpenAiTypeChecker.isOneOf(schema) &&
Expand Down Expand Up @@ -240,6 +240,7 @@ export namespace OpenAiComposer {
method: route.method as "get",
path: route.path,
name: route.accessor.join("_"),
strict: true,
parameters,
separated: options.separate
? OpenAiSchemaSeparator.parameters({
Expand All @@ -248,10 +249,10 @@ export namespace OpenAiComposer {
})
: undefined,
output: output
? OpenApiV3Downgrader.downgradeSchema({
? (OpenApiV3Downgrader.downgradeSchema({
original: {},
downgraded: {},
})(output)
})(output) as IOpenAiSchema)
: undefined,
description: (() => {
if (operation.summary && operation.description) {
Expand Down
9 changes: 9 additions & 0 deletions src/structures/IOpenAiFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ export interface IOpenAiFunction {
*/
name: string;

/**
* Whether the function schema types are strict or not.
*
* Newly added specification at 2024-08-07.
*
* @reference https://openai.com/index/introducing-structured-outputs-in-the-api/
*/
strict: true;

/**
* List of parameter schemas.
*/
Expand Down
17 changes: 17 additions & 0 deletions test/keyword.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"method": "post",
"path": "/bbs/articles",
"name": "bbs_articles_post",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -299,6 +300,7 @@
"method": "patch",
"path": "/bbs/articles",
"name": "bbs_articles_patch",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -445,6 +447,7 @@
"method": "patch",
"path": "/bbs/articles/abridges",
"name": "bbs_articles_abridges_patch",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -728,6 +731,7 @@
"method": "get",
"path": "/bbs/articles/{id}",
"name": "bbs_articles_getById",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -878,6 +882,7 @@
"method": "put",
"path": "/bbs/articles/{id}",
"name": "bbs_articles_putById",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -1137,6 +1142,7 @@
"method": "delete",
"path": "/bbs/articles/{id}",
"name": "bbs_articles_eraseById",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -1195,6 +1201,7 @@
"method": "post",
"path": "/membership/join",
"name": "membership_join_post",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -1361,6 +1368,7 @@
"method": "patch",
"path": "/membership/login",
"name": "membership_login_patch",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -1480,6 +1488,7 @@
"method": "get",
"path": "/membership/{secret}",
"name": "membership_getBySecret",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -1554,6 +1563,7 @@
"method": "patch",
"path": "/membership/change",
"name": "membership_change_patch",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -1746,6 +1756,7 @@
"method": "patch",
"path": "/membership/{secret}/change",
"name": "membership_change_patchBySecret",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -1922,6 +1933,7 @@
"method": "post",
"path": "/multipart",
"name": "multipart_post",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -2090,6 +2102,7 @@
"method": "get",
"path": "/query/typed",
"name": "query_typed_get",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -2199,6 +2212,7 @@
"method": "get",
"path": "/query/nest",
"name": "query_nest_get",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -2316,6 +2330,7 @@
"method": "get",
"path": "/query/individual",
"name": "query_individual_get",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -2368,6 +2383,7 @@
"method": "get",
"path": "/query/composite/{id}",
"name": "query_composite_getById",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -2483,6 +2499,7 @@
"method": "post",
"path": "/query/body",
"name": "query_body_post",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down
17 changes: 17 additions & 0 deletions test/plain.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"method": "post",
"path": "/bbs/articles",
"name": "bbs_articles_post",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -204,6 +205,7 @@
"method": "patch",
"path": "/bbs/articles",
"name": "bbs_articles_patch",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -316,6 +318,7 @@
"method": "patch",
"path": "/bbs/articles/abridges",
"name": "bbs_articles_abridges_patch",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -522,6 +525,7 @@
"method": "get",
"path": "/bbs/articles/{id}",
"name": "bbs_articles_getById",
"strict": true,
"parameters": [
{
"type": "string",
Expand Down Expand Up @@ -649,6 +653,7 @@
"method": "put",
"path": "/bbs/articles/{id}",
"name": "bbs_articles_putById",
"strict": true,
"parameters": [
{
"type": "string",
Expand Down Expand Up @@ -813,6 +818,7 @@
"method": "delete",
"path": "/bbs/articles/{id}",
"name": "bbs_articles_eraseById",
"strict": true,
"parameters": [
{
"type": "string",
Expand All @@ -837,6 +843,7 @@
"method": "post",
"path": "/membership/join",
"name": "membership_join_post",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -926,6 +933,7 @@
"method": "patch",
"path": "/membership/login",
"name": "membership_login_patch",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -992,6 +1000,7 @@
"method": "get",
"path": "/membership/{secret}",
"name": "membership_getBySecret",
"strict": true,
"parameters": [
{
"type": "string",
Expand Down Expand Up @@ -1043,6 +1052,7 @@
"method": "patch",
"path": "/membership/change",
"name": "membership_change_patch",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -1145,6 +1155,7 @@
"method": "patch",
"path": "/membership/{secret}/change",
"name": "membership_change_patchBySecret",
"strict": true,
"parameters": [
{
"type": "string",
Expand Down Expand Up @@ -1239,6 +1250,7 @@
"method": "post",
"path": "/multipart",
"name": "multipart_post",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -1333,6 +1345,7 @@
"method": "get",
"path": "/query/typed",
"name": "query_typed_get",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -1396,6 +1409,7 @@
"method": "get",
"path": "/query/nest",
"name": "query_nest_get",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down Expand Up @@ -1463,6 +1477,7 @@
"method": "get",
"path": "/query/individual",
"name": "query_individual_get",
"strict": true,
"parameters": [
{
"type": "object",
Expand All @@ -1485,6 +1500,7 @@
"method": "get",
"path": "/query/composite/{id}",
"name": "query_composite_getById",
"strict": true,
"parameters": [
{
"type": "string",
Expand Down Expand Up @@ -1551,6 +1567,7 @@
"method": "post",
"path": "/query/body",
"name": "query_body_post",
"strict": true,
"parameters": [
{
"type": "object",
Expand Down
Loading