| 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | # All rights reserved. |
| 3 | # |
| 4 | # This source code is licensed under the terms described in the LICENSE file in |
| 5 | # the root directory of this source tree. |
| 6 | |
| 7 | from typing import List, Optional, Protocol |
| 8 | |
| 9 | from llama_models.schema_utils import json_schema_type, webmethod |
| 10 | from pydantic import BaseModel, Field |
| 11 | |
| 12 | from llama_stack.distribution.datatypes import GenericProviderConfig |
| 13 | |
| 14 | |
| 15 | @json_schema_type |
| 16 | class ShieldSpec(BaseModel): |
| 17 | shield_type: str |
| 18 | provider_config: GenericProviderConfig = Field( |
| 19 | description="Provider config for the model, including provider_id, and corresponding config. ", |
| 20 | ) |
| 21 | |
| 22 | |
| 23 | class Shields(Protocol): |
| 24 | @webmethod(route="/shields/list", method="GET") |
| 25 | async def list_shields(self) -> List[ShieldSpec]: ... |
| 26 | |
| 27 | @webmethod(route="/shields/get", method="GET") |
| 28 | async def get_shield(self, shield_type: str) -> Optional[ShieldSpec]: ... |