Skip to content

json_schema_rule

JsonSchemaRule

Bases: BaseRule

Source code in griptape/rules/json_schema_rule.py
@define(frozen=True)
class JsonSchemaRule(BaseRule):
    value: dict = field()
    template_generator: J2 = field(default=J2("rules/json_schema.j2"))

    def to_text(self) -> str:
        return self.template_generator.render(json_schema=json.dumps(self.value))

template_generator: J2 = field(default=J2('rules/json_schema.j2')) class-attribute instance-attribute

value: dict = field() class-attribute instance-attribute

to_text()

Source code in griptape/rules/json_schema_rule.py
def to_text(self) -> str:
    return self.template_generator.render(json_schema=json.dumps(self.value))