(self, prompt)
| 35 | |
| 36 | @backoff.on_exception(backoff.expo, openai.error.RateLimitError) |
| 37 | def count_tokens(self, prompt): |
| 38 | try: |
| 39 | encoding = tiktoken.encoding_for_model(self.model) |
| 40 | except KeyError: |
| 41 | encoding = tiktoken.get_encoding('cl100k_base') |
| 42 | num_tokens = len(encoding.encode(prompt)) |
| 43 | |
| 44 | return num_tokens |
nothing calls this directly
no outgoing calls
no test coverage detected