From ecc474888243450dd749137466190a3c85dad830 Mon Sep 17 00:00:00 2001 From: H Lohaus Date: Sat, 6 Apr 2024 21:05:04 +0200 Subject: Update helper.py --- g4f/client/helper.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'g4f/client/helper.py') diff --git a/g4f/client/helper.py b/g4f/client/helper.py index 2cdaa058..32aa9183 100644 --- a/g4f/client/helper.py +++ b/g4f/client/helper.py @@ -13,4 +13,21 @@ def read_json(text: str) -> dict: match = re.search(r"```(json|)\n(?P[\S\s]+?)\n```", text) if match: return match.group("code") - return text \ No newline at end of file + return text + +def find_stop(stop, content: str, chunk: str): + first = -1 + word = None + if stop is not None: + for word in list(stop): + first = content.find(word) + if first != -1: + content = content[:first] + break + if stream and first != -1: + first = chunk.find(word) + if first != -1: + chunk = chunk[:first] + else: + first = 0 + return first, content, chunk -- cgit v1.2.3