Add integration test for token counting in log_step_metadata

- Implemented test_token_counting_integration to verify the correct total token count when using a mocked tokenizer, ensuring that prompt and response token counts are accurately aggregated.
pull/615/head
Sambhav Dixit 2 months ago committed by GitHub
parent e80d182092
commit 8900d645c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -41,3 +41,9 @@ class TestAgentLogging(unittest.TestCase):
def test_log_step_metadata_timestamp(self):
log_result = self.agent.log_step_metadata(1, "prompt", "response")
self.assertIn('timestamp', log_result)
def test_token_counting_integration(self):
self.mock_tokenizer.count_tokens.side_effect = [150, 250]
log_result = self.agent.log_step_metadata(1, "prompt", "response")
self.assertEqual(log_result['tokens']['total'], 400)

Loading…
Cancel
Save