mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-28 19:04:19 +00:00
Resource oriented design for shields (#399)
* init * working bedrock tests * bedrock test for inference fixes * use env vars for bedrock guardrail vars * add register in meta reference * use correct shield impl in meta ref * dont add together fixture * right naming * minor updates * improved registration flow * address feedback --------- Co-authored-by: Dinesh Yeduguru <dineshyv@fb.com>
This commit is contained in:
parent
7ee9f8d8ac
commit
d800a16acd
20 changed files with 262 additions and 124 deletions
|
@ -41,13 +41,13 @@ class SafetyClient(Safety):
|
|||
pass
|
||||
|
||||
async def run_shield(
|
||||
self, shield_type: str, messages: List[Message]
|
||||
self, shield_id: str, messages: List[Message]
|
||||
) -> RunShieldResponse:
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.post(
|
||||
f"{self.base_url}/safety/run_shield",
|
||||
json=dict(
|
||||
shield_type=shield_type,
|
||||
shield_id=shield_id,
|
||||
messages=[encodable_dict(m) for m in messages],
|
||||
),
|
||||
headers={
|
||||
|
@ -80,7 +80,7 @@ async def run_main(host: str, port: int, image_path: str = None):
|
|||
)
|
||||
cprint(f"User>{message.content}", "green")
|
||||
response = await client.run_shield(
|
||||
shield_type="llama_guard",
|
||||
shield_id="llama_guard",
|
||||
messages=[message],
|
||||
)
|
||||
print(response)
|
||||
|
@ -91,7 +91,7 @@ async def run_main(host: str, port: int, image_path: str = None):
|
|||
]:
|
||||
cprint(f"User>{message.content}", "green")
|
||||
response = await client.run_shield(
|
||||
shield_type="llama_guard",
|
||||
shield_id="llama_guard",
|
||||
messages=[message],
|
||||
)
|
||||
print(response)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue