Update helper.py

pull/1794/head
H Lohaus 3 months ago committed by GitHub
parent 6e3f350f52
commit ecc4748882
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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
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

Loading…
Cancel
Save