update method name to run_moderation

This commit is contained in:
Swapna Lekkala 2025-08-04 14:15:42 -07:00
parent 70ebc4b448
commit 2d608ddd3b
6 changed files with 295 additions and 295 deletions

View file

@ -114,7 +114,7 @@ class Safety(Protocol):
...
@webmethod(route="/openai/v1/moderations", method="POST")
async def create(self, input: str | list[str], model: str) -> ModerationObject:
async def run_moderation(self, input: str | list[str], model: str) -> ModerationObject:
"""Classifies if text and/or image inputs are potentially harmful.
:param input: Input (or inputs) to classify.
Can be a single string, an array of strings, or an array of multi-modal input objects similar to other models.

View file

@ -62,7 +62,7 @@ class SafetyRouter(Safety):
params=params,
)
async def create(self, input: str | list[str], model: str) -> ModerationObject:
async def run_moderation(self, input: str | list[str], model: str) -> ModerationObject:
async def get_shield_id(self, model: str) -> str:
"""Get Shield id from model (provider_resource_id) of shield."""
list_shields_response = await self.routing_table.list_shields()
@ -78,7 +78,7 @@ class SafetyRouter(Safety):
logger.debug(f"SafetyRouter.create: {shield_id}")
provider = await self.routing_table.get_provider_impl(shield_id)
return await provider.create(
return await provider.run_moderation(
input=input,
model=model,
)

View file

@ -221,7 +221,7 @@ class LlamaGuardSafetyImpl(Safety, ShieldsProtocolPrivate):
return await impl.run(messages)
async def create(
async def run_moderation(
self,
input: str | list[str],
model: str | None = None, # To replace with default model for llama-guard