forked from phoenix-oss/llama-stack-mirror
[bugfix] fix llama guard parsing ContentDelta (#772)
# What does this PR do? Fix this error <img width="1183" alt="image" src="https://github.com/user-attachments/assets/a4d48832-a9b9-4fc9-b8b6-79326a13c03e" /> ## Test Plan ``` LLAMA_STACK_BASE_URL="http://localhost:5000" pytest -v tests/client-sdk/inference/test_inference.py ``` ## Sources Please link relevant resources if necessary. ## Before submitting - [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case). - [ ] Ran pre-commit to handle lint / formatting issues. - [ ] Read the [contributor guideline](https://github.com/meta-llama/llama-stack/blob/main/CONTRIBUTING.md), Pull Request section? - [ ] Updated relevant documentation. - [ ] Wrote necessary unit or integration tests.
This commit is contained in:
parent
32d3abe964
commit
d0a25dd453
1 changed files with 5 additions and 3 deletions
|
@ -263,9 +263,11 @@ class LlamaGuardShield:
|
||||||
stream=True,
|
stream=True,
|
||||||
):
|
):
|
||||||
event = chunk.event
|
event = chunk.event
|
||||||
if event.event_type == ChatCompletionResponseEventType.progress:
|
if (
|
||||||
assert isinstance(event.delta, str)
|
event.event_type == ChatCompletionResponseEventType.progress
|
||||||
content += event.delta
|
and event.delta.type == "text"
|
||||||
|
):
|
||||||
|
content += event.delta.text
|
||||||
|
|
||||||
content = content.strip()
|
content = content.strip()
|
||||||
return self.get_shield_response(content)
|
return self.get_shield_response(content)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue