-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Add responses and safety impl extra_body #3781
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
Conversation
llama_stack/providers/inline/agents/meta_reference/responses/openai_responses.py
Outdated
Show resolved
Hide resolved
76f0478
to
76b991c
Compare
:param type: The type/identifier of the guardrail. | ||
""" | ||
|
||
type: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just for my learning: what types are available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about this part @ashwinb, I usually only know identifier
for a shield, as such only supporting that for now. May be this is to allow more fields in future.
if isinstance(guardrail, str): | ||
guardrail_ids.append(guardrail) | ||
elif isinstance(guardrail, ResponseGuardrailSpec): | ||
guardrail_ids.append(guardrail.type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems confusing: type
being used as id
. Is there a better way to name this?
llama_stack/providers/inline/agents/meta_reference/responses/utils.py
Outdated
Show resolved
Hide resolved
llama_stack/providers/inline/agents/meta_reference/responses/streaming.py
Outdated
Show resolved
Hide resolved
|
||
# Input safety validation - check messages before processing | ||
if self.guardrail_ids: | ||
combined_text = interleaved_content_as_str([msg.content for msg in self.ctx.messages]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we document somewhere that guardrails only apply to text input?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes the shield + moderation apis dont support the image, this is known tech debt, I filed an issue for that before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it in our user-facing documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah may be not, need to do that
llama_stack/providers/inline/agents/meta_reference/responses/streaming.py
Outdated
Show resolved
Hide resolved
llama_stack/providers/inline/agents/meta_reference/responses/streaming.py
Outdated
Show resolved
Hide resolved
llama_stack/providers/inline/agents/meta_reference/responses/streaming.py
Show resolved
Hide resolved
a9ebdfe
to
1f7d52f
Compare
|
||
# Input safety validation - check messages before processing | ||
if self.guardrail_ids: | ||
combined_text = interleaved_content_as_str([msg.content for msg in self.ctx.messages]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it in our user-facing documentation?
llama_stack/providers/inline/agents/meta_reference/responses/streaming.py
Outdated
Show resolved
Hide resolved
) | ||
|
||
# Collect content for final response | ||
chat_response_content.append(chunk_choice.delta.content or "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes added gating for reasoning content too
sequence_number=self.sequence_number, | ||
) | ||
# Skip Emitting text content delta event if guardrails are configured, only emits chunks after guardrails are applied | ||
if not self.guardrail_ids: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it acceptable to drop these chunks entirely? or should we queue and yield after guardrails pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Queuing and streaming the deltas when chunk is safe.
llama_stack/providers/inline/agents/meta_reference/responses/utils.py
Outdated
Show resolved
Hide resolved
llama_stack/providers/inline/agents/meta_reference/responses/utils.py
Outdated
Show resolved
Hide resolved
6bd5b4d
to
8d10642
Compare
8c900d7
to
94b5df7
Compare
What does this PR do?
Have closed the previous PR due to merge conflicts with multiple PRs
Addressed all comments from #3768 (sorry for carrying over to this one)
Test Plan
Added UTs and integration tests