File size: 426 Bytes
b077b7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import weave
from weave.flow.obj import Object as WeaveObject

from .base import Guardrail


class GuardrailManager(WeaveObject):
    guardrails: list[Guardrail]

    @weave.op()
    def guard(self, prompt: str, **kwargs) -> dict:
        alerts = []
        for guardrail in self.guardrails:
            response = guardrail.guard(prompt, **kwargs)
            alerts.append({guardrail.name: response})
        return alerts