(self)
| 20 | DEBUG_STYLE = Style(color="purple") |
| 21 | |
| 22 | def __init__(self): |
| 23 | super().__init__() |
| 24 | try: |
| 25 | import tiktoken |
| 26 | |
| 27 | self.llm_encoding = tiktoken.get_encoding("cl100k_base") |
| 28 | except Exception as e: |
| 29 | logger.warning( |
| 30 | "Failed to import optional library tiktoken. Using approximate instead of exact token count." |
| 31 | ) |
| 32 | logger.debug(f"Exception: {e}") |
| 33 | self.llm_encoding = None |
| 34 | |
| 35 | def info(self, *args, **kwargs): |
| 36 | logger.info(" ".join(map(str, args))) |