removing unused code

This commit is contained in:
Chantal D Gama Rose 2025-02-21 07:34:52 +00:00
parent 830ecb4b28
commit 0f1a9d06db
2 changed files with 1 additions and 18 deletions

View file

@ -4,18 +4,13 @@
# This source code is licensed under the terms described in the LICENSE file in # This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree. # the root directory of this source tree.
import os import os
from enum import Enum
from typing import Any, Dict, Optional from typing import Any, Dict, Optional
from pydantic import BaseModel, Field, field_validator from pydantic import BaseModel, Field
from llama_stack.schema_utils import json_schema_type from llama_stack.schema_utils import json_schema_type
class ShieldType(Enum):
self_check = "self_check"
@json_schema_type @json_schema_type
class NVIDIASafetyConfig(BaseModel): class NVIDIASafetyConfig(BaseModel):
""" """
@ -41,14 +36,6 @@ class NVIDIASafetyConfig(BaseModel):
description="The url for accessing the guardrails service", description="The url for accessing the guardrails service",
) )
config_id: Optional[str] = Field(default="self-check", description="Config ID to use from the config store") config_id: Optional[str] = Field(default="self-check", description="Config ID to use from the config store")
config_store_path: Optional[str] = Field(default="/config-store", description="Path to config store")
@classmethod
@field_validator("guard_type")
def validate_guard_type(cls, v):
if v not in [t.value for t in ShieldType]:
raise ValueError(f"Unknown shield type: {v}")
return v
@classmethod @classmethod
def sample_run_config(cls, **kwargs) -> Dict[str, Any]: def sample_run_config(cls, **kwargs) -> Dict[str, Any]:

View file

@ -24,7 +24,6 @@ class NVIDIASafetyAdapter(Safety, ShieldsProtocolPrivate):
def __init__(self, config: NVIDIASafetyConfig) -> None: def __init__(self, config: NVIDIASafetyConfig) -> None:
print(f"Initializing NVIDIASafetyAdapter({config.guardrails_service_url})...") print(f"Initializing NVIDIASafetyAdapter({config.guardrails_service_url})...")
self.config = config self.config = config
self.registered_shields = []
async def initialize(self) -> None: async def initialize(self) -> None:
pass pass
@ -56,7 +55,6 @@ class NeMoGuardrails:
temperature: float = 1.0, temperature: float = 1.0,
): ):
self.config_id = config.config_id self.config_id = config.config_id
self.config_store_path = config.config_store_path
self.model = model self.model = model
assert self.config_id is not None or self.config_store_path is not None, ( assert self.config_id is not None or self.config_store_path is not None, (
"Must provide one of config id or config store path" "Must provide one of config id or config store path"
@ -64,7 +62,6 @@ class NeMoGuardrails:
if temperature <= 0: if temperature <= 0:
raise ValueError("Temperature must be greater than 0") raise ValueError("Temperature must be greater than 0")
self.config = config
self.temperature = temperature self.temperature = temperature
self.threshold = threshold self.threshold = threshold
self.guardrails_service_url = config.guardrails_service_url self.guardrails_service_url = config.guardrails_service_url
@ -89,7 +86,6 @@ class NeMoGuardrails:
response = requests.post( response = requests.post(
url=f"{self.guardrails_service_url}/v1/guardrail/checks", headers=headers, json=request_data url=f"{self.guardrails_service_url}/v1/guardrail/checks", headers=headers, json=request_data
) )
print(response)
response.raise_for_status() response.raise_for_status()
if "Content-Type" in response.headers and response.headers["Content-Type"].startswith("application/json"): if "Content-Type" in response.headers and response.headers["Content-Type"].startswith("application/json"):
response_json = response.json() response_json = response.json()