@@ -34,6 +34,13 @@ function toCamelCase(str: string, joiner = "") {
3434 . join ( joiner ) ;
3535}
3636
37+ const OVERRIDES_TYPES_RENAME_PROPERTIES : Record < string , Record < string , string > > = {
38+ ChatCompletionInputFunctionDefinition : { arguments : "parameters" } ,
39+ } ;
40+ const OVERRIDES_TYPES_OVERRIDE_PROPERTY_TYPE : Record < string , Record < string , unknown > > = {
41+ ChatCompletionOutputFunctionDefinition : { arguments : { type : "string" } } ,
42+ } ;
43+
3744async function _extractAndAdapt ( task : string , mainComponentName : string , type : "input" | "output" | "stream_output" ) {
3845 console . debug ( `✨ Importing` , task , type ) ;
3946
@@ -57,6 +64,17 @@ async function _extractAndAdapt(task: string, mainComponentName: string, type: "
5764 _scan ( item ) ;
5865 }
5966 } else if ( data && typeof data === "object" ) {
67+ /// This next section can be removed when we don't use TGI as source of types.
68+ if ( typeof data . title === "string" && data . title in OVERRIDES_TYPES_RENAME_PROPERTIES ) {
69+ const [ [ oldName , newName ] ] = Object . entries ( OVERRIDES_TYPES_RENAME_PROPERTIES [ data . title ] ) ;
70+ data . required = JSON . parse ( JSON . stringify ( data . required ) . replaceAll ( oldName , newName ) ) ;
71+ data . properties = JSON . parse ( JSON . stringify ( data . properties ) . replaceAll ( oldName , newName ) ) ;
72+ }
73+ if ( typeof data . title === "string" && data . title in OVERRIDES_TYPES_OVERRIDE_PROPERTY_TYPE ) {
74+ const [ [ prop , newType ] ] = Object . entries ( OVERRIDES_TYPES_OVERRIDE_PROPERTY_TYPE [ data . title ] ) ;
75+ ( data . properties as Record < string , unknown > ) [ prop ] = newType ;
76+ }
77+ /// End of overrides section
6078 for ( const key of Object . keys ( data ) ) {
6179 if ( key === "$ref" && typeof data [ key ] === "string" ) {
6280 // Verify reference exists
0 commit comments