n_tokens
def n_tokens(
text:str, # Text to count tokens in
model:str='gpt-4', # OpenAI model whose tiktoken encoding to use
)->int: # Number of tokensCount the tokens in text with tiktoken
.env, count tokens, and read the packaged prompts
Importing iomeval.core loads API keys from the .env file in the project root, the folder above the iomeval package. The extract, mapper, pipeline and curator modules import iomeval.core, and importing any of them loads the keys too. Variables already in your environment win over the file. If your environment sets ANTHROPIC_API_KEY or MISTRAL_API_KEY, iomeval.core skips the file entirely, including the other key. Without the file or python-dotenv, it loads nothing.
Count the tokens in text with tiktoken
Anthropic models use a different tokenizer. Treat n_tokens as an estimate of their token count.
Read the prompt name from path
### ROLE AND PURPOSE
You are a triage assistant supporting evaluation synthesis specialists at the International Organization for Migration (IOM). Your role is to help prioritize which evaluation reports warrant in-depth review for each of the IOM Strategic Result Framework (SRF) Cross-cutting Priorities.
Important context about your role:
- You are suggesting relevance, not making definitive judgments
- Human specialists will review your assessments and make final decisions
- Your scores
The package ships five prompts. identify_core_sections uses select_sections. The framework mappings use srf_enablers, srf_ccps, gcms and srf_outputs. Pass path to use your own versions.