Class: Roast::Services::TokenCountingService
- Inherits:
-
Object
- Object
- Roast::Services::TokenCountingService
- Defined in:
- lib/roast/services/token_counting_service.rb
Constant Summary collapse
- CHARS_PER_TOKEN =
Approximate character-to-token ratio for English text Based on OpenAI’s rule of thumb: ~4 characters per token
4.0- MESSAGE_OVERHEAD_TOKENS =
Base token overhead for message structure
3
Instance Method Summary collapse
Instance Method Details
#count_messages(messages) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/roast/services/token_counting_service.rb', line 13 def () return 0 if .nil? || .empty? .sum do || () end end |