@@ -24,7 +24,7 @@ import {
2424 SafetySetting ,
2525 getGenerativeModel
2626} from '../src' ;
27- import { testConfigs , TOKEN_COUNT_DELTA } from './constants' ;
27+ import { testConfigs } from './constants' ;
2828
2929describe ( 'Chat Session' , ( ) => {
3030 testConfigs . forEach ( testConfig => {
@@ -98,31 +98,19 @@ describe('Chat Session', () => {
9898
9999 if ( model . model . includes ( 'gemini-2.5-flash' ) ) {
100100 // Token counts can vary slightly in chat context
101- expect ( response1 . usageMetadata ! . promptTokenCount ) . to . be . closeTo (
102- 17 , // "What is the capital of France?" + system instruction
103- TOKEN_COUNT_DELTA + 2 // More variance for chat context
104- ) ;
101+ expect ( response1 . usageMetadata ! . promptTokenCount ) . to . not . equal ( 0 ) ;
105102 expect ( response1 . usageMetadata ! . candidatesTokenCount ) . to . not . equal ( 0 ) ;
106103 expect ( response1 . usageMetadata ! . totalTokenCount ) . to . not . equal ( 0 ) ;
107- expect ( response2 . usageMetadata ! . promptTokenCount ) . to . be . closeTo (
108- 32 , // History + "And what about Italy?" + system instruction
109- TOKEN_COUNT_DELTA + 5 // More variance for chat context with history
110- ) ;
104+ expect ( response2 . usageMetadata ! . promptTokenCount ) . to . not . equal ( 0 ) ;
111105 expect ( response2 . usageMetadata ! . candidatesTokenCount ) . to . not . equal ( 0 ) ;
112106 expect ( response2 . usageMetadata ! . totalTokenCount ) . to . not . equal ( 0 ) ;
113107 } else if ( model . model . includes ( 'gemini-2.0-flash' ) ) {
114108 expect ( response1 . usageMetadata ) . to . not . be . null ;
115109 // Token counts can vary slightly in chat context
116- expect ( response1 . usageMetadata ! . promptTokenCount ) . to . be . closeTo (
117- 15 , // "What is the capital of France?" + system instruction
118- TOKEN_COUNT_DELTA + 2 // More variance for chat context
119- ) ;
110+ expect ( response1 . usageMetadata ! . promptTokenCount ) . to . not . equal ( 0 ) ;
120111 expect ( response1 . usageMetadata ! . candidatesTokenCount ) . to . not . equal ( 0 ) ;
121112 expect ( response1 . usageMetadata ! . totalTokenCount ) . to . not . equal ( 0 ) ;
122- expect ( response2 . usageMetadata ! . promptTokenCount ) . to . be . closeTo (
123- 28 , // History + "And what about Italy?" + system instruction
124- TOKEN_COUNT_DELTA + 5 // More variance for chat context with history
125- ) ;
113+ expect ( response2 . usageMetadata ! . promptTokenCount ) . to . not . equal ( 0 ) ;
126114 expect ( response2 . usageMetadata ! . candidatesTokenCount ) . to . not . equal ( 0 ) ;
127115 expect ( response2 . usageMetadata ! . totalTokenCount ) . to . not . equal ( 0 ) ;
128116 }
0 commit comments