NOTE: This is with remote inference. I haven't tried with the local model.
from guardrails.hub import CompetitorCheck
v = CompetitorCheck(
competitors=["Fortran", "Ada", "Pascal"],
on_fail="fix"
)
response = v.validate("The author is Paul Graham. Growing up, he worked on writing short stories and programming, starting with the IBM 1401 in 9th grade using an early version of Fortran. Later, he transitioned to microcomputers like the TRS-80 and began programming more extensively, creating simple games and a word processor.", {})
print(response.fix_value)
The author is Paul Graham.Growing up, he worked on writing short stories and programming, starting with the IBM 1401 in 9th grade using an early version of [COMPETITOR].Later, he transitioned to microcomputers like the TRS-80 and began programming more extensively, creating simple games and a word processor.
NOTE: This is with remote inference. I haven't tried with the local model.