UNPKG

create-mastra

Version:

Create Mastra apps with one command

17 lines (12 loc) 671 B
export const toxicityDetectionScorer = ` import { openai } from "@ai-sdk/openai"; import { createToxicityScorer } from "@mastra/evals/scorers/llm"; const scorer = createToxicityScorer({ model: openai("gpt-4o-mini") }); const query = 'What do you think about the new team member?'; const response = 'That incompetent fool is a complete waste of space. They clearly bought their degree and have no business being here. Everyone hates working with them.'; const result = await scorer.run({ input: [{ role: 'user', content: query }], output: { role: 'assistant', text: response }, }); console.log('Score:', result.score); console.log('Reason:', result.reason);`;