diff --git a/client-sdks/stainless/config.yml b/client-sdks/stainless/config.yml index 70cfbeb1c8..4395756dd4 100644 --- a/client-sdks/stainless/config.yml +++ b/client-sdks/stainless/config.yml @@ -363,8 +363,6 @@ resources: list: paginated: false endpoint: get /v1/shields - register: post /v1/shields - delete: delete /v1/shields/{identifier} scoring: methods: score: post /v1/scoring/score diff --git a/client-sdks/stainless/openapi.yml b/client-sdks/stainless/openapi.yml index 06e361debc..fa08fa6b8b 100644 --- a/client-sdks/stainless/openapi.yml +++ b/client-sdks/stainless/openapi.yml @@ -2158,38 +2158,6 @@ paths: summary: List all shields. description: List all shields. operationId: list_shields_v1_shields_get - post: - responses: - '200': - description: A Shield. - content: - application/json: - schema: - $ref: '#/components/schemas/Shield' - '400': - description: Bad Request - $ref: '#/components/responses/BadRequest400' - '429': - description: Too Many Requests - $ref: '#/components/responses/TooManyRequests429' - '500': - description: Internal Server Error - $ref: '#/components/responses/InternalServerError500' - default: - description: Default Response - $ref: '#/components/responses/DefaultError' - tags: - - Shields - summary: Register a shield. - description: Register a shield. - operationId: register_shield_v1_shields_post - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/RegisterShieldRequest' - required: true - deprecated: true /v1/shields/{identifier}: get: responses: @@ -2225,37 +2193,6 @@ paths: description: The identifier of the shield to get. title: Identifier description: The identifier of the shield to get. - delete: - responses: - '400': - $ref: '#/components/responses/BadRequest400' - description: Bad Request - '429': - $ref: '#/components/responses/TooManyRequests429' - description: Too Many Requests - '500': - $ref: '#/components/responses/InternalServerError500' - description: Internal Server Error - default: - $ref: '#/components/responses/DefaultError' - description: Default Response - '204': - description: The shield was successfully unregistered. - tags: - - Shields - summary: Unregister a shield. - description: Unregister a shield. - operationId: unregister_shield_v1_shields__identifier__delete - parameters: - - name: identifier - in: path - required: true - schema: - type: string - description: The identifier of the shield to unregister. - title: Identifier - description: The identifier of the shield to unregister. - deprecated: true /v1/tools: get: responses: @@ -7846,16 +7783,6 @@ components: - output_tokens_details title: OpenAIResponseUsage description: Usage information for OpenAI response. - ResponseGuardrailSpec: - properties: - type: - type: string - title: Type - additionalProperties: false - required: - - type - title: ResponseGuardrailSpec - description: Specification for a guardrail to apply during response generation. OpenAIResponseInputTool: discriminator: mapping: @@ -11588,31 +11515,34 @@ components: title: RegisterScoringFunctionRequest description: Request model for registering a scoring function. RegisterShieldRequest: + description: Request model for registering a shield. properties: shield_id: - type: string - title: Shield Id description: The identifier of the shield to register. + title: Shield Id + type: string provider_shield_id: anyOf: - type: string - type: 'null' description: The identifier of the shield in the provider. + nullable: true provider_id: anyOf: - type: string - type: 'null' description: The identifier of the provider. + nullable: true params: anyOf: - additionalProperties: true type: object - type: 'null' description: The parameters of the shield. + nullable: true required: - shield_id title: RegisterShieldRequest - description: Request model for registering a shield. DataSource: discriminator: mapping: @@ -12085,17 +12015,6 @@ components: - type: 'null' description: Maximum number of inference iterations. default: 10 - guardrails: - anyOf: - - items: - anyOf: - - type: string - - $ref: '#/components/schemas/ResponseGuardrailSpec' - title: ResponseGuardrailSpec - title: string | ResponseGuardrailSpec - type: array - - type: 'null' - description: List of guardrails to apply during response generation. max_tool_calls: anyOf: - type: integer diff --git a/docs/static/deprecated-llama-stack-spec.yaml b/docs/static/deprecated-llama-stack-spec.yaml index 12914642cd..f1522c9319 100644 --- a/docs/static/deprecated-llama-stack-spec.yaml +++ b/docs/static/deprecated-llama-stack-spec.yaml @@ -74,71 +74,6 @@ paths: title: Scoring Fn Id description: The ID of the scoring function to unregister. deprecated: true - /v1/shields: - post: - responses: - '200': - description: A Shield. - content: - application/json: - schema: - $ref: '#/components/schemas/Shield' - '400': - description: Bad Request - $ref: '#/components/responses/BadRequest400' - '429': - description: Too Many Requests - $ref: '#/components/responses/TooManyRequests429' - '500': - description: Internal Server Error - $ref: '#/components/responses/InternalServerError500' - default: - description: Default Response - $ref: '#/components/responses/DefaultError' - tags: - - Shields - summary: Register a shield. - description: Register a shield. - operationId: register_shield_v1_shields_post - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/RegisterShieldRequest' - required: true - deprecated: true - /v1/shields/{identifier}: - delete: - responses: - '400': - $ref: '#/components/responses/BadRequest400' - description: Bad Request - '429': - $ref: '#/components/responses/TooManyRequests429' - description: Too Many Requests - '500': - $ref: '#/components/responses/InternalServerError500' - description: Internal Server Error - default: - $ref: '#/components/responses/DefaultError' - description: Default Response - '204': - description: The shield was successfully unregistered. - tags: - - Shields - summary: Unregister a shield. - description: Unregister a shield. - operationId: unregister_shield_v1_shields__identifier__delete - parameters: - - name: identifier - in: path - required: true - schema: - type: string - description: The identifier of the shield to unregister. - title: Identifier - description: The identifier of the shield to unregister. - deprecated: true /v1beta/datasets: post: responses: @@ -3757,16 +3692,6 @@ components: - output_tokens_details title: OpenAIResponseUsage description: Usage information for OpenAI response. - ResponseGuardrailSpec: - properties: - type: - type: string - title: Type - additionalProperties: false - required: - - type - title: ResponseGuardrailSpec - description: Specification for a guardrail to apply during response generation. OpenAIResponseInputTool: discriminator: mapping: @@ -7499,31 +7424,34 @@ components: title: RegisterScoringFunctionRequest description: Request model for registering a scoring function. RegisterShieldRequest: + description: Request model for registering a shield. properties: shield_id: - type: string - title: Shield Id description: The identifier of the shield to register. + title: Shield Id + type: string provider_shield_id: anyOf: - type: string - type: 'null' description: The identifier of the shield in the provider. + nullable: true provider_id: anyOf: - type: string - type: 'null' description: The identifier of the provider. + nullable: true params: anyOf: - additionalProperties: true type: object - type: 'null' description: The parameters of the shield. + nullable: true required: - shield_id title: RegisterShieldRequest - description: Request model for registering a shield. DataSource: discriminator: mapping: @@ -7998,17 +7926,6 @@ components: - type: 'null' description: Maximum number of inference iterations. default: 10 - guardrails: - anyOf: - - items: - anyOf: - - type: string - - $ref: '#/components/schemas/ResponseGuardrailSpec' - title: ResponseGuardrailSpec - title: string | ResponseGuardrailSpec - type: array - - type: 'null' - description: List of guardrails to apply during response generation. max_tool_calls: anyOf: - type: integer diff --git a/docs/static/experimental-llama-stack-spec.yaml b/docs/static/experimental-llama-stack-spec.yaml index 5e834f4308..676322ff2d 100644 --- a/docs/static/experimental-llama-stack-spec.yaml +++ b/docs/static/experimental-llama-stack-spec.yaml @@ -8040,31 +8040,34 @@ components: title: RegisterScoringFunctionRequest description: Request model for registering a scoring function. RegisterShieldRequest: + description: Request model for registering a shield. properties: shield_id: - type: string - title: Shield Id description: The identifier of the shield to register. + title: Shield Id + type: string provider_shield_id: anyOf: - type: string - type: 'null' description: The identifier of the shield in the provider. + nullable: true provider_id: anyOf: - type: string - type: 'null' description: The identifier of the provider. + nullable: true params: anyOf: - additionalProperties: true type: object - type: 'null' description: The parameters of the shield. + nullable: true required: - shield_id title: RegisterShieldRequest - description: Request model for registering a shield. DataSource: discriminator: mapping: diff --git a/docs/static/llama-stack-spec.yaml b/docs/static/llama-stack-spec.yaml index 033219262a..3d536f3574 100644 --- a/docs/static/llama-stack-spec.yaml +++ b/docs/static/llama-stack-spec.yaml @@ -6794,16 +6794,6 @@ components: - output_tokens_details title: OpenAIResponseUsage description: Usage information for OpenAI response. - ResponseGuardrailSpec: - properties: - type: - type: string - title: Type - additionalProperties: false - required: - - type - title: ResponseGuardrailSpec - description: Specification for a guardrail to apply during response generation. OpenAIResponseInputTool: discriminator: mapping: @@ -10536,31 +10526,34 @@ components: title: RegisterScoringFunctionRequest description: Request model for registering a scoring function. RegisterShieldRequest: + description: Request model for registering a shield. properties: shield_id: - type: string - title: Shield Id description: The identifier of the shield to register. + title: Shield Id + type: string provider_shield_id: anyOf: - type: string - type: 'null' description: The identifier of the shield in the provider. + nullable: true provider_id: anyOf: - type: string - type: 'null' description: The identifier of the provider. + nullable: true params: anyOf: - additionalProperties: true type: object - type: 'null' description: The parameters of the shield. + nullable: true required: - shield_id title: RegisterShieldRequest - description: Request model for registering a shield. DataSource: discriminator: mapping: @@ -11010,17 +11003,6 @@ components: - type: 'null' description: Maximum number of inference iterations. default: 10 - guardrails: - anyOf: - - items: - anyOf: - - type: string - - $ref: '#/components/schemas/ResponseGuardrailSpec' - title: ResponseGuardrailSpec - title: string | ResponseGuardrailSpec - type: array - - type: 'null' - description: List of guardrails to apply during response generation. max_tool_calls: anyOf: - type: integer diff --git a/docs/static/stainless-llama-stack-spec.yaml b/docs/static/stainless-llama-stack-spec.yaml index 06e361debc..fa08fa6b8b 100644 --- a/docs/static/stainless-llama-stack-spec.yaml +++ b/docs/static/stainless-llama-stack-spec.yaml @@ -2158,38 +2158,6 @@ paths: summary: List all shields. description: List all shields. operationId: list_shields_v1_shields_get - post: - responses: - '200': - description: A Shield. - content: - application/json: - schema: - $ref: '#/components/schemas/Shield' - '400': - description: Bad Request - $ref: '#/components/responses/BadRequest400' - '429': - description: Too Many Requests - $ref: '#/components/responses/TooManyRequests429' - '500': - description: Internal Server Error - $ref: '#/components/responses/InternalServerError500' - default: - description: Default Response - $ref: '#/components/responses/DefaultError' - tags: - - Shields - summary: Register a shield. - description: Register a shield. - operationId: register_shield_v1_shields_post - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/RegisterShieldRequest' - required: true - deprecated: true /v1/shields/{identifier}: get: responses: @@ -2225,37 +2193,6 @@ paths: description: The identifier of the shield to get. title: Identifier description: The identifier of the shield to get. - delete: - responses: - '400': - $ref: '#/components/responses/BadRequest400' - description: Bad Request - '429': - $ref: '#/components/responses/TooManyRequests429' - description: Too Many Requests - '500': - $ref: '#/components/responses/InternalServerError500' - description: Internal Server Error - default: - $ref: '#/components/responses/DefaultError' - description: Default Response - '204': - description: The shield was successfully unregistered. - tags: - - Shields - summary: Unregister a shield. - description: Unregister a shield. - operationId: unregister_shield_v1_shields__identifier__delete - parameters: - - name: identifier - in: path - required: true - schema: - type: string - description: The identifier of the shield to unregister. - title: Identifier - description: The identifier of the shield to unregister. - deprecated: true /v1/tools: get: responses: @@ -7846,16 +7783,6 @@ components: - output_tokens_details title: OpenAIResponseUsage description: Usage information for OpenAI response. - ResponseGuardrailSpec: - properties: - type: - type: string - title: Type - additionalProperties: false - required: - - type - title: ResponseGuardrailSpec - description: Specification for a guardrail to apply during response generation. OpenAIResponseInputTool: discriminator: mapping: @@ -11588,31 +11515,34 @@ components: title: RegisterScoringFunctionRequest description: Request model for registering a scoring function. RegisterShieldRequest: + description: Request model for registering a shield. properties: shield_id: - type: string - title: Shield Id description: The identifier of the shield to register. + title: Shield Id + type: string provider_shield_id: anyOf: - type: string - type: 'null' description: The identifier of the shield in the provider. + nullable: true provider_id: anyOf: - type: string - type: 'null' description: The identifier of the provider. + nullable: true params: anyOf: - additionalProperties: true type: object - type: 'null' description: The parameters of the shield. + nullable: true required: - shield_id title: RegisterShieldRequest - description: Request model for registering a shield. DataSource: discriminator: mapping: @@ -12085,17 +12015,6 @@ components: - type: 'null' description: Maximum number of inference iterations. default: 10 - guardrails: - anyOf: - - items: - anyOf: - - type: string - - $ref: '#/components/schemas/ResponseGuardrailSpec' - title: ResponseGuardrailSpec - title: string | ResponseGuardrailSpec - type: array - - type: 'null' - description: List of guardrails to apply during response generation. max_tool_calls: anyOf: - type: integer diff --git a/scripts/openapi_generator/stainless_config/generate_config.py b/scripts/openapi_generator/stainless_config/generate_config.py index 32e774c174..1462d76f4f 100644 --- a/scripts/openapi_generator/stainless_config/generate_config.py +++ b/scripts/openapi_generator/stainless_config/generate_config.py @@ -435,8 +435,6 @@ "methods": { "retrieve": "get /v1/shields/{identifier}", "list": {"paginated": False, "endpoint": "get /v1/shields"}, - "register": "post /v1/shields", - "delete": "delete /v1/shields/{identifier}", }, }, "scoring": { diff --git a/src/llama_stack/providers/inline/responses/builtin/impl.py b/src/llama_stack/providers/inline/responses/builtin/impl.py index b218ec9fec..a7871ab532 100644 --- a/src/llama_stack/providers/inline/responses/builtin/impl.py +++ b/src/llama_stack/providers/inline/responses/builtin/impl.py @@ -153,7 +153,7 @@ async def create_openai_response( tools=request.tools, include=request.include, max_infer_iters=request.max_infer_iters, - guardrails=request.guardrails, + guardrails=getattr(request, "guardrails", None) or (request.model_extra or {}).get("guardrails"), parallel_tool_calls=request.parallel_tool_calls, max_tool_calls=request.max_tool_calls, max_output_tokens=request.max_output_tokens, diff --git a/src/llama_stack_api/responses/models.py b/src/llama_stack_api/responses/models.py index 17350b55ae..17a731a27b 100644 --- a/src/llama_stack_api/responses/models.py +++ b/src/llama_stack_api/responses/models.py @@ -150,10 +150,6 @@ class CreateResponseRequest(BaseModel): ge=1, description="Maximum number of inference iterations.", ) - guardrails: list[ResponseGuardrail] | None = Field( - default=None, - description="List of guardrails to apply during response generation.", - ) max_tool_calls: int | None = Field( default=None, ge=1, diff --git a/src/llama_stack_api/shields/fastapi_routes.py b/src/llama_stack_api/shields/fastapi_routes.py index 3bb04efed6..70f5f254ac 100644 --- a/src/llama_stack_api/shields/fastapi_routes.py +++ b/src/llama_stack_api/shields/fastapi_routes.py @@ -12,7 +12,7 @@ from typing import Annotated -from fastapi import APIRouter, Body, Depends +from fastapi import APIRouter, Depends from llama_stack_api.router_utils import create_path_dependency, standard_responses from llama_stack_api.version import LLAMA_STACK_API_V1 @@ -21,14 +21,11 @@ from .models import ( GetShieldRequest, ListShieldsResponse, - RegisterShieldRequest, Shield, - UnregisterShieldRequest, ) # Automatically generate dependency functions from Pydantic models get_get_shield_request = create_path_dependency(GetShieldRequest) -get_unregister_shield_request = create_path_dependency(UnregisterShieldRequest) def create_router(impl: Shields) -> APIRouter: @@ -72,33 +69,4 @@ async def get_shield( ) -> Shield: return await impl.get_shield(request) - @router.post( - "/shields", - response_model=Shield, - summary="Register a shield.", - description="Register a shield.", - responses={ - 200: {"description": "A Shield."}, - }, - deprecated=True, - ) - async def register_shield( - request: Annotated[RegisterShieldRequest, Body(...)], - ) -> Shield: - return await impl.register_shield(request) - - @router.delete( - "/shields/{identifier:path}", - summary="Unregister a shield.", - description="Unregister a shield.", - responses={ - 200: {"description": "The shield was successfully unregistered."}, - }, - deprecated=True, - ) - async def unregister_shield( - request: Annotated[UnregisterShieldRequest, Depends(get_unregister_shield_request)], - ) -> None: - return await impl.unregister_shield(request) - return router