"""Utilities function"""

# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.

# %% auto 0
__all__ = ['n_tokens', 'load_prompt']

# %% ../nbs/00_core.ipynb 2
import tiktoken
from pathlib import Path

# %% ../nbs/00_core.ipynb 3
def n_tokens(
    text:str, # Text to count tokens in
    model:str='gpt-4' # Model name for tokenizer
    ) -> int:
    "Count the number of tokens in a string"
    enc = tiktoken.encoding_for_model(model)
    return len(enc.encode(text))

# %% ../nbs/00_core.ipynb 5
def load_prompt(name, path='files/prompts'): return (Path(path)/f'{name}.md').read_text()
