UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

64 lines • 2.76 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseCustomTopics = /* @__PURE__ */ (() => { class BaseCustomTopics extends APIResource { /** * Update the custom topic list of the zone, overwriting it entirely with the * topics in the request, so include every topic you want to keep. Changes can take * up to a minute to propagate. * * Each entry has a `label`, used to reference the topic in rule expressions and * analytics, and a `topic` description, which the classifier scores prompts * against while AI Security for Apps is enabled. The following rules apply: * * - A zone can hold at most 20 topics. * - `label` must be 2–20 characters, using only lowercase letters (a–z), digits * (0–9), and hyphens. * - `topic` must be 2–50 printable ASCII characters. * - Labels must be unique within the zone, and so must topic descriptions. * * @example * ```ts * const customTopic = * await client.aiSecurity.customTopics.update({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ update(params, options) { const { zone_id, ...body } = params; return this._client.put(path `/zones/${zone_id}/ai-security/custom-topics`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Get the custom topic categories defined for the zone. While AI Security for Apps * is enabled, it scores every incoming prompt against these topics and writes the * scores to the `cf.llm.prompt.custom_topic_categories` field, keyed by topic * label. Topics can be configured while the detection is disabled, but no prompt * is scored until you enable it. * * @example * ```ts * const customTopic = * await client.aiSecurity.customTopics.get({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ get(params, options) { const { zone_id } = params; return this._client.get(path `/zones/${zone_id}/ai-security/custom-topics`, options)._thenUnwrap((obj) => obj.result); } } BaseCustomTopics._key = Object.freeze([ 'aiSecurity', 'customTopics', ]); return BaseCustomTopics; })(); export class CustomTopics extends BaseCustomTopics { } //# sourceMappingURL=custom-topics.mjs.map