guardrails-ai / competitor_check

Guardrails AI: Competitor Check - Validates that LLM-generated text is not naming any competitors from a given list
Apache License 2.0
1 stars 3 forks source link

CompetitorCheck drops whitespace between sentences #23

Open CalebCourier opened 1 day ago

CalebCourier commented 1 day ago

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.