cloudflare
Version:
The official TypeScript library for the Cloudflare API
69 lines • 3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomTopics = exports.BaseCustomTopics = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../core/resource.js");
const path_1 = require("../../internal/utils/path.js");
var BaseCustomTopics = /* @__PURE__ */ (() => {
class BaseCustomTopics extends resource_1.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((0, path_1.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((0, path_1.path) `/zones/${zone_id}/ai-security/custom-topics`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseCustomTopics._key = Object.freeze([
'aiSecurity',
'customTopics',
]);
return BaseCustomTopics;
})();
exports.BaseCustomTopics = BaseCustomTopics;
class CustomTopics extends BaseCustomTopics {
}
exports.CustomTopics = CustomTopics;
//# sourceMappingURL=custom-topics.js.map