Skip to content

Commit 4099129

Browse files
yyyu-googlecopybara-github
authored andcommitted
fix: replace any type with explicit types in post fetch processing functions
PiperOrigin-RevId: 615517662
1 parent add084c commit 4099129

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/functions/count_tokens.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export async function countTokens(
4141
apiEndpoint?: string,
4242
requestOptions?: RequestOptions
4343
): Promise<CountTokensResponse> {
44-
const response = await postRequest({
44+
const response: Response | undefined = await postRequest({
4545
region: location,
4646
project: project,
4747
resourcePath: publisherModelEndpoint,

src/functions/post_fetch_processing.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ function addCandidateFunctionCalls(
267267
* @ignore
268268
*/
269269
export async function processNonStream(
270-
response: any
270+
response: Response | undefined
271271
): Promise<GenerateContentResult> {
272272
if (response !== undefined) {
273273
// ts-ignore
@@ -287,8 +287,12 @@ export async function processNonStream(
287287
* @ignore
288288
*/
289289
export async function processCountTokenResponse(
290-
response: any
290+
response: Response | undefined
291291
): Promise<CountTokensResponse> {
292-
// ts-ignore
293-
return response.json();
292+
if (response) {
293+
// ts-ignore
294+
return response.json();
295+
}
296+
297+
return Promise.resolve({} as CountTokensResponse);
294298
}

0 commit comments

Comments
 (0)