mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-04 12:07:34 +00:00
feat(api): add extra_body parameter support with shields example (#3670)
## Summary Introduce `ExtraBodyField` annotation to enable parameters that arrive via extra_body in client SDKs but are accessible server-side with full typing. These parameters are documented in OpenAPI specs under **`x-llama-stack-extra-body-params`** but excluded from generated SDK signatures. Add `shields` parameter to `create_openai_response` as the first implementation using this pattern. ## Test Plan - added an integration test which checks that shields parameter passed via extra_body reaches server implementation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
188a56af5c
commit
61b4238912
16 changed files with 367 additions and 12 deletions
33
tests/integration/responses/test_extra_body_shields.py
Normal file
33
tests/integration/responses/test_extra_body_shields.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the terms described in the LICENSE file in
|
||||
# the root directory of this source tree.
|
||||
|
||||
"""
|
||||
Test for extra_body parameter support with shields example.
|
||||
|
||||
This test demonstrates that parameters marked with ExtraBodyField annotation
|
||||
can be passed via extra_body in the client SDK and are received by the
|
||||
server-side implementation.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from llama_stack_client import APIStatusError
|
||||
|
||||
|
||||
def test_shields_via_extra_body(compat_client, text_model_id):
|
||||
"""Test that shields parameter is received by the server and raises NotImplementedError."""
|
||||
|
||||
# Test with shields as list of strings (shield IDs)
|
||||
with pytest.raises((APIStatusError, NotImplementedError)) as exc_info:
|
||||
compat_client.responses.create(
|
||||
model=text_model_id,
|
||||
input="What is the capital of France?",
|
||||
stream=False,
|
||||
extra_body={"shields": ["test-shield-1", "test-shield-2"]},
|
||||
)
|
||||
|
||||
# Verify the error message indicates shields are not implemented
|
||||
error_message = str(exc_info.value)
|
||||
assert "not yet implemented" in error_message.lower() or "not implemented" in error_message.lower()
|
Loading…
Add table
Add a link
Reference in a new issue