From 6cec64c2e42b3943065dde940c1d1ef188ef9124 Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Wed, 15 Jan 2025 11:11:31 -0800 Subject: [PATCH] fix llama guard --- .../providers/inline/safety/llama_guard/llama_guard.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/llama_stack/providers/inline/safety/llama_guard/llama_guard.py b/llama_stack/providers/inline/safety/llama_guard/llama_guard.py index 00213ac83..1496074a9 100644 --- a/llama_stack/providers/inline/safety/llama_guard/llama_guard.py +++ b/llama_stack/providers/inline/safety/llama_guard/llama_guard.py @@ -263,9 +263,12 @@ class LlamaGuardShield: stream=True, ): event = chunk.event - if event.event_type == ChatCompletionResponseEventType.progress: - assert isinstance(event.delta, str) - content += event.delta + if ( + event.event_type == ChatCompletionResponseEventType.progress + and event.delta.type == "text" + ): + assert isinstance(event.delta.text, str) + content += event.delta.text content = content.strip() return self.get_shield_response(content)