mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
9 lines
258 B
Python
9 lines
258 B
Python
|
"""Common utility functions for 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, maxsplit=1)[0]
|