summaryrefslogtreecommitdiffstats
path: root/g4f/client
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-04-06 21:05:04 +0200
committerGitHub <noreply@github.com>2024-04-06 21:05:04 +0200
commitecc474888243450dd749137466190a3c85dad830 (patch)
tree73c3901907b6cd86312e6925fc9ad87cb01ff160 /g4f/client
parentUpdate async.py (diff)
downloadgpt4free-ecc474888243450dd749137466190a3c85dad830.tar
gpt4free-ecc474888243450dd749137466190a3c85dad830.tar.gz
gpt4free-ecc474888243450dd749137466190a3c85dad830.tar.bz2
gpt4free-ecc474888243450dd749137466190a3c85dad830.tar.lz
gpt4free-ecc474888243450dd749137466190a3c85dad830.tar.xz
gpt4free-ecc474888243450dd749137466190a3c85dad830.tar.zst
gpt4free-ecc474888243450dd749137466190a3c85dad830.zip
Diffstat (limited to 'g4f/client')
-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