File tree 2 files changed +9
-5
lines changed
2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ export async function countTokens(
41
41
apiEndpoint ?: string ,
42
42
requestOptions ?: RequestOptions
43
43
) : Promise < CountTokensResponse > {
44
- const response = await postRequest ( {
44
+ const response : Response | undefined = await postRequest ( {
45
45
region : location ,
46
46
project : project ,
47
47
resourcePath : publisherModelEndpoint ,
Original file line number Diff line number Diff line change @@ -267,7 +267,7 @@ function addCandidateFunctionCalls(
267
267
* @ignore
268
268
*/
269
269
export async function processNonStream (
270
- response : any
270
+ response : Response | undefined
271
271
) : Promise < GenerateContentResult > {
272
272
if ( response !== undefined ) {
273
273
// ts-ignore
@@ -287,8 +287,12 @@ export async function processNonStream(
287
287
* @ignore
288
288
*/
289
289
export async function processCountTokenResponse (
290
- response : any
290
+ response : Response | undefined
291
291
) : 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 ) ;
294
298
}
You can’t perform that action at this time.
0 commit comments