Spaces:
Running
Running
File size: 1,037 Bytes
67dbb33 b207b4c 67dbb33 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
from abc import abstractmethod
import weave
class Guardrail(weave.Model):
"""
The Guardrail class is an abstract base class that extends the weave.Model.
This class is designed to provide a framework for implementing guardrails
in the form of the `guard` method. The `guard` method is an abstract method
that must be implemented by any subclass. It takes a prompt string and
additional keyword arguments, and returns a list of strings. The specific
implementation of the `guard` method will define the behavior of the guardrail.
Attributes:
None
Methods:
guard(prompt: str, **kwargs) -> list[str]:
Abstract method that must be implemented by subclasses. It takes a
prompt string and additional keyword arguments, and returns a list
of strings.
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@abstractmethod
@weave.op()
def guard(self, prompt: str, **kwargs) -> list[str]:
pass
|