File tree Expand file tree Collapse file tree 5 files changed +731
-48
lines changed Expand file tree Collapse file tree 5 files changed +731
-48
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ import type {
49
49
import {
50
50
getMimeType ,
51
51
recursivelyDeleteUnsupportedParameters ,
52
+ transformGeminiToolParameters ,
52
53
transformVertexLogprobs ,
53
54
} from './utils' ;
54
55
@@ -301,6 +302,11 @@ export const VertexGoogleChatCompleteConfig: ProviderConfig = {
301
302
) {
302
303
tools . push ( buildGoogleSearchRetrievalTool ( tool ) ) ;
303
304
} else {
305
+ if ( tool . function ?. parameters ) {
306
+ tool . function . parameters = transformGeminiToolParameters (
307
+ tool . function . parameters
308
+ ) ;
309
+ }
304
310
functionDeclarations . push ( tool . function ) ;
305
311
}
306
312
}
Original file line number Diff line number Diff line change 1
1
import { Params } from '../../types/requestBody' ;
2
- import { derefer , recursivelyDeleteUnsupportedParameters } from './utils' ;
2
+ import {
3
+ recursivelyDeleteUnsupportedParameters ,
4
+ transformGeminiToolParameters ,
5
+ } from './utils' ;
3
6
import { GoogleEmbedParams } from './embed' ;
4
7
import { EmbedInstancesData } from './types' ;
5
8
/**
@@ -39,20 +42,11 @@ export function transformGenerationConfig(params: Params) {
39
42
}
40
43
if ( params ?. response_format ?. type === 'json_schema' ) {
41
44
generationConfig [ 'responseMimeType' ] = 'application/json' ;
42
- recursivelyDeleteUnsupportedParameters (
43
- params ?. response_format ?. json_schema ?. schema
44
- ) ;
45
45
let schema =
46
46
params ?. response_format ?. json_schema ?. schema ??
47
47
params ?. response_format ?. json_schema ;
48
- if ( Object . keys ( schema ) . includes ( '$defs' ) ) {
49
- schema = derefer ( schema ) ;
50
- delete schema [ '$defs' ] ;
51
- }
52
- if ( Object . hasOwn ( schema , '$schema' ) ) {
53
- delete schema [ '$schema' ] ;
54
- }
55
- generationConfig [ 'responseSchema' ] = schema ;
48
+ recursivelyDeleteUnsupportedParameters ( schema ) ;
49
+ generationConfig [ 'responseSchema' ] = transformGeminiToolParameters ( schema ) ;
56
50
}
57
51
58
52
if ( params ?. thinking ) {
You can’t perform that action at this time.
0 commit comments