File size: 259 Bytes
58d33f0
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
"""Common utility functions for working with LLM APIs."""
import re
from typing import List


def enforce_stop_tokens(text: str, stop: List[str]) -> str:
    """Cut off the text as soon as any stop words occur."""
    return re.split("|".join(stop), text)[0]