summaryrefslogtreecommitdiffstats
path: root/g4f/client/helper.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--g4f/client/helper.py19
1 files changed, 18 insertions, 1 deletions
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<code>[\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