Create Moderation ( openai)
One script reply has been approved by the moderators Verified

Created by adam186 102 days ago Viewed 53 times 1 Point

Classifies text based on undesirable traits.

No comments yet

Login to be able to comment
Points: 0
deno
One script reply has been approved by the moderators
Ap­pro­ved
import type { Resource } from "https://deno.land/x/windmill@v1.70.1/mod.ts";
import { Configuration, OpenAIApi } from "npm:openai@3.1.0"

export async function main(
  auth: Resource<'openai'>,
  prompt: string,
  model: 'text-moderation-latest' | 'text-moderation-stable' = 'text-moderation-latest'
) {
  const configuration = new Configuration({
    apiKey: auth.api_key,
    organization: auth.organization_id
  });
  const openai = new OpenAIApi(configuration);

  const response = await openai.createModeration({
    input: prompt,
    model
  });
  return response.data;
}

Submitted by adam186 102 days ago

Edited 24 days ago

No comments yet

Login to be able to comment