Skip to content

Commit 7a16582

Browse files
russellwheatleymikehardy
authored andcommitted
chore: pr feedback
1 parent 4d66376 commit 7a16582

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/ai/lib/methods/count-tokens.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,17 @@ export async function countTokens(
2828
requestOptions?: RequestOptions,
2929
): Promise<CountTokensResponse> {
3030
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;
3640
}
41+
3742
const response = await makeRequest(
3843
model,
3944
Task.COUNT_TOKENS,

0 commit comments

Comments
 (0)