UNPKG

@genkit-ai/checks

Version:

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

1 lines 2.84 kB
{"version":3,"sources":["../src/metrics.ts"],"sourcesContent":["/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Currently supported Checks AI Safety policies.\n */\nexport enum ChecksEvaluationMetricType {\n // The model facilitates, promotes or enables access to harmful goods,\n // services, and activities.\n DANGEROUS_CONTENT = 'DANGEROUS_CONTENT',\n // The model reveals an individual’s personal information and data.\n PII_SOLICITING_RECITING = 'PII_SOLICITING_RECITING',\n // The model generates content that is malicious, intimidating, bullying, or\n // abusive towards another individual.\n HARASSMENT = 'HARASSMENT',\n // The model generates content that is sexually explicit in nature.\n SEXUALLY_EXPLICIT = 'SEXUALLY_EXPLICIT',\n // The model promotes violence, hatred, discrimination on the basis of race,\n // religion, etc.\n HATE_SPEECH = 'HATE_SPEECH',\n // The model facilitates harm by providing health advice or guidance.\n MEDICAL_INFO = 'MEDICAL_INFO',\n // The model generates content that contains gratuitous, realistic\n // descriptions of violence or gore.\n VIOLENCE_AND_GORE = 'VIOLENCE_AND_GORE',\n // The model generates content that contains vulgar, profane, or offensive\n // language.\n OBSCENITY_AND_PROFANITY = 'OBSCENITY_AND_PROFANITY',\n}\n\n/**\n * Checks evaluation metric config. Use `threshold` to override the default violation threshold.\n * The value of `metricSpec` will be included in the request to the API. See the API documentation\n */\nexport type ChecksEvaluationMetricConfig = {\n type: ChecksEvaluationMetricType;\n threshold?: number;\n};\n\nexport type ChecksEvaluationMetric =\n | ChecksEvaluationMetricType\n | ChecksEvaluationMetricConfig;\n\nexport function isConfig(\n config: ChecksEvaluationMetric\n): config is ChecksEvaluationMetricConfig {\n return (config as ChecksEvaluationMetricConfig).type !== undefined;\n}\n"],"mappings":"AAmBO,IAAK,6BAAL,kBAAKA,gCAAL;AAGL,EAAAA,4BAAA,uBAAoB;AAEpB,EAAAA,4BAAA,6BAA0B;AAG1B,EAAAA,4BAAA,gBAAa;AAEb,EAAAA,4BAAA,uBAAoB;AAGpB,EAAAA,4BAAA,iBAAc;AAEd,EAAAA,4BAAA,kBAAe;AAGf,EAAAA,4BAAA,uBAAoB;AAGpB,EAAAA,4BAAA,6BAA0B;AArBhB,SAAAA;AAAA,GAAA;AAqCL,SAAS,SACd,QACwC;AACxC,SAAQ,OAAwC,SAAS;AAC3D;","names":["ChecksEvaluationMetricType"]}