@@ -43,10 +43,16 @@ export namespace ChatGptSchemaComposer {
43
43
44
44
// returns with transformation
45
45
for ( const key of Object . keys ( result . value . $defs ) )
46
- result . value . $defs [ key ] = transform ( result . value . $defs [ key ] ) ;
46
+ result . value . $defs [ key ] = transform ( {
47
+ config : props . config ,
48
+ schema : result . value . $defs [ key ] ,
49
+ } ) ;
47
50
return {
48
51
success : true ,
49
- value : transform ( result . value ) as IChatGptSchema . IParameters ,
52
+ value : transform ( {
53
+ config : props . config ,
54
+ schema : result . value ,
55
+ } ) as IChatGptSchema . IParameters ,
50
56
} ;
51
57
} ;
52
58
@@ -77,10 +83,16 @@ export namespace ChatGptSchemaComposer {
77
83
// returns with transformation
78
84
for ( const key of Object . keys ( props . $defs ) )
79
85
if ( oldbie . has ( key ) === false )
80
- props . $defs [ key ] = transform ( props . $defs [ key ] ) ;
86
+ props . $defs [ key ] = transform ( {
87
+ config : props . config ,
88
+ schema : props . $defs [ key ] ,
89
+ } ) ;
81
90
return {
82
91
success : true ,
83
- value : transform ( result . value ) ,
92
+ value : transform ( {
93
+ config : props . config ,
94
+ schema : result . value ,
95
+ } ) ,
84
96
} ;
85
97
} ;
86
98
@@ -109,13 +121,16 @@ export namespace ChatGptSchemaComposer {
109
121
return reasons ;
110
122
} ;
111
123
112
- const transform = ( schema : ILlmSchemaV3_1 ) : IChatGptSchema => {
124
+ const transform = ( props : {
125
+ config : IChatGptSchema . IConfig ;
126
+ schema : ILlmSchemaV3_1 ;
127
+ } ) : IChatGptSchema => {
113
128
const union : Array < IChatGptSchema > = [ ] ;
114
129
const attribute : IChatGptSchema . __IAttribute = {
115
- title : schema . title ,
116
- description : schema . description ,
117
- example : schema . example ,
118
- examples : schema . examples ,
130
+ title : props . schema . title ,
131
+ description : props . schema . description ,
132
+ example : props . schema . example ,
133
+ examples : props . schema . examples ,
119
134
...Object . fromEntries (
120
135
Object . entries ( schema ) . filter (
121
136
( [ key , value ] ) => key . startsWith ( "x-" ) && value !== undefined ,
@@ -127,22 +142,33 @@ export namespace ChatGptSchemaComposer {
127
142
else if ( LlmTypeCheckerV3_1 . isArray ( input ) )
128
143
union . push ( {
129
144
...input ,
130
- items : transform ( input . items ) ,
145
+ items : transform ( {
146
+ config : props . config ,
147
+ schema : input . items ,
148
+ } ) ,
131
149
} ) ;
132
150
else if ( LlmTypeCheckerV3_1 . isObject ( input ) )
133
151
union . push ( {
134
152
...input ,
135
153
properties : Object . fromEntries (
136
154
Object . entries ( input . properties ) . map ( ( [ key , value ] ) => [
137
155
key ,
138
- transform ( value ) ,
156
+ transform ( {
157
+ config : props . config ,
158
+ schema : value ,
159
+ } ) ,
139
160
] ) ,
140
161
) ,
141
162
additionalProperties :
142
- typeof input . additionalProperties === "object" &&
143
- input . additionalProperties !== null
144
- ? transform ( input . additionalProperties )
145
- : input . additionalProperties ,
163
+ props . config . strict === true
164
+ ? false
165
+ : typeof input . additionalProperties === "object" &&
166
+ input . additionalProperties !== null
167
+ ? transform ( {
168
+ config : props . config ,
169
+ schema : input . additionalProperties ,
170
+ } )
171
+ : input . additionalProperties ,
146
172
} ) ;
147
173
else if ( LlmTypeCheckerV3_1 . isConstant ( input ) === false )
148
174
union . push ( input ) ;
@@ -167,8 +193,8 @@ export namespace ChatGptSchemaComposer {
167
193
else if ( OpenApiTypeChecker . isOneOf ( input ) )
168
194
input . oneOf . forEach ( visitConstant ) ;
169
195
} ;
170
- visit ( schema ) ;
171
- visitConstant ( schema ) ;
196
+ visit ( props . schema ) ;
197
+ visitConstant ( props . schema ) ;
172
198
if ( union . length === 0 )
173
199
return {
174
200
...attribute ,
0 commit comments