Skip to content

thrzl/perspective

Repository files navigation

💖 perspective

a strongly typed wrapper for google's perspective api

📦 installation

pip install perspectiveapi

🪴 example

async

from perspective import Perspective, Attribute

p = Perspective(key="...")

async def main():
    s = await p.score(
        "your message here", attributes=(Attribute.FLIRTATION, Attribute.SEVERE_TOXICITY)
    )
    print(s.flirtation) 
    print(s.severe_toxicity)

blocking

from perspective.blocking import Perspective, Attribute

p = Perspective(key="...")

def main():
    s = p.score(
        "your message here", attributes=(Attribute.FLIRTATION, Attribute.SEVERE_TOXICITY)
    )
    print(s.flirtation) 
    print(s.severe_toxicity)