langchain/langchain/llms/utils.py

9 lines
259 B
Python
Raw Normal View History

"""Common utility functions for working with LLM APIs."""
import re
2022-11-15 06:05:41 +00:00
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]