Update modeling_qwen3_guard.py
Browse files- modeling_qwen3_guard.py +9 -0
modeling_qwen3_guard.py
CHANGED
|
@@ -626,6 +626,15 @@ class Qwen3ForGuardModel(Qwen3PreTrainedModel):
|
|
| 626 |
|
| 627 |
return result, stream_state
|
| 628 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 629 |
|
| 630 |
__all__ = [
|
| 631 |
"Qwen3PreTrainedModel",
|
|
|
|
| 626 |
|
| 627 |
return result, stream_state
|
| 628 |
|
| 629 |
+
@torch.no_grad()
|
| 630 |
+
def close_stream(self, stream_state: Optional[Generator]) -> None:
|
| 631 |
+
if stream_state is not None:
|
| 632 |
+
try:
|
| 633 |
+
stream_state.send(None)
|
| 634 |
+
except StopIteration:
|
| 635 |
+
pass
|
| 636 |
+
finally:
|
| 637 |
+
stream_state.close()
|
| 638 |
|
| 639 |
__all__ = [
|
| 640 |
"Qwen3PreTrainedModel",
|