File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -28,12 +28,17 @@ export async function countTokens(
28
28
requestOptions ?: RequestOptions ,
29
29
) : Promise < CountTokensResponse > {
30
30
let body : string = '' ;
31
- if ( apiSettings . backend . backendType === BackendType . GOOGLE_AI ) {
32
- const mappedParams = GoogleAIMapper . mapCountTokensRequest ( params , model ) ;
33
- body = JSON . stringify ( mappedParams ) ;
34
- } else {
35
- body = JSON . stringify ( params ) ;
31
+ switch ( apiSettings . backend . backendType ) {
32
+ case BackendType . GOOGLE_AI :
33
+ const mappedParams = GoogleAIMapper . mapCountTokensRequest ( params , model ) ;
34
+ body = JSON . stringify ( mappedParams ) ;
35
+ break ;
36
+ case BackendType . VERTEX_AI :
37
+ default :
38
+ body = JSON . stringify ( params ) ;
39
+ break ;
36
40
}
41
+
37
42
const response = await makeRequest (
38
43
model ,
39
44
Task . COUNT_TOKENS ,
You can’t perform that action at this time.
0 commit comments