How to interrupt streaming output? #1414
-
Hi, I have a question about interruption of streaming. How can I safely interrupt streaming? I want to define stopping criteria to check if an output matches some regex. output = ''
for token in model(prompt, stream=True):
output += token
match = re.search(pattern, output)
if match:
yield output
break
else:
yield output However, current llama_cpp implementation doesn't accept the usage. So I wanna know how to safely force the model to complete the generation. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
There is a pull request for this, unfortunately not merged: |
Beta Was this translation helpful? Give feedback.
-
Ah, it looks old PR, and I cannot get why it's abandoned for long time. |
Beta Was this translation helpful? Give feedback.
There is a pull request for this, unfortunately not merged:
#733