UNPKG

@genkit-ai/checks

Version:

Google Checks AI Safety plugins for classifying the safety of text against Checks AI safety policies.

63 lines (59 loc) 1.91 kB
import { z } from 'genkit'; import { GoogleAuth } from 'google-auth-library'; import { ChecksEvaluationMetric } from './metrics.mjs'; /** * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Response type returned by the classifyContent endpoint. */ declare const ResponseSchema: z.ZodObject<{ policyResults: z.ZodArray<z.ZodObject<{ policyType: z.ZodString; score: z.ZodOptional<z.ZodNumber>; violationResult: z.ZodString; }, "strip", z.ZodTypeAny, { policyType: string; violationResult: string; score?: number | undefined; }, { policyType: string; violationResult: string; score?: number | undefined; }>, "many">; }, "strip", z.ZodTypeAny, { policyResults: { policyType: string; violationResult: string; score?: number | undefined; }[]; }, { policyResults: { policyType: string; violationResult: string; score?: number | undefined; }[]; }>; type ResponseType = z.infer<typeof ResponseSchema>; /** * API implementation for making requests to the guardrails api. */ declare class Guardrails { private auth; private projectId; constructor(auth: GoogleAuth, projectId?: string); classifyContent(content: string, policies: ChecksEvaluationMetric[]): Promise<ResponseType>; } export { Guardrails };