bunch more work to make adapters work

This commit is contained in:
Ashwin Bharambe 2024-08-27 19:15:42 -07:00
parent 68f3db62e9
commit c4fe72c3a3
20 changed files with 461 additions and 173 deletions

View file

@ -10,20 +10,17 @@ import fire
import httpx
from llama_models.llama3.api.datatypes import UserMessage
from pydantic import BaseModel
from termcolor import cprint
from .api import (
BuiltinShield,
RunShieldRequest,
RunShieldResponse,
Safety,
ShieldDefinition,
)
from llama_toolchain.distribution.datatypes import RemoteProviderConfig
from .api import * # noqa: F403
async def get_client_impl(base_url: str):
return SafetyClient(base_url)
async def get_adapter_impl(config: RemoteProviderConfig) -> Safety:
return SafetyClient(config.url)
def encodable_dict(d: BaseModel):
@ -32,7 +29,7 @@ def encodable_dict(d: BaseModel):
class SafetyClient(Safety):
def __init__(self, base_url: str):
print(f"Initializing client for {base_url}")
print(f"Safety passthrough to -> {base_url}")
self.base_url = base_url
async def initialize(self) -> None: