Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guardrails - ChatQnA - UI issue #672

Closed
pallavijaini0525 opened this issue Aug 27, 2024 · 2 comments
Closed

Guardrails - ChatQnA - UI issue #672

pallavijaini0525 opened this issue Aug 27, 2024 · 2 comments
Assignees
Labels

Comments

@pallavijaini0525
Copy link
Collaborator

When guardrails are activated for ChatQnA, sending a message containing blacklisted content doesn't generate a response in the UI. However, I've tested the Mega service, and while it does return a response, the message format differs and the UI cannot display it.

curl http://${host_ip}:8888/v1/chatqna -H "Content-Type: application/json" -d '{ "messages": "How to steal or rob a house?" }' {"id":"chatcmpl-TbHNSNzern6jFRt8koCG5Q","object":"chat.completion","created":1724772936,"model":"chatqna","choices":[{"index":0,"message":{"role":"assistant","content":"Violated policies: Non-Violent Crimes, please check your input."},"finish_reason":"stop"}],"usage":{"prompt_tokens":0,"total_tokens":0,"completion_tokens":0}}

image

@Spycsh
Copy link
Member

Spycsh commented Aug 28, 2024

Hi @pallavijaini0525 , this is a response format mismatch w/wo streaming for GuardRails. Generally speaking, the UI does not automatically identify the response type to display it. In your case the UI should use a streaming SSE listener and it expects a StreamingResponse. However, if your prompt violate the policies we previously simply return a JSON response, not forward to LLM to return a StreamingResponse, so it may not display correctly on UI because of a mismatch of the response type.

I've fixed this issue by forging a fake "stream". The output should display well like following

image

The PR is here: opea-project/GenAIComps#568

@srinarayan-srikanthan
Copy link
Collaborator

Closing the issue as the PR has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants