anthale 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/LICENSE +201 -0
- package/README.md +393 -0
- package/api-promise.d.mts +2 -0
- package/api-promise.d.mts.map +1 -0
- package/api-promise.d.ts +2 -0
- package/api-promise.d.ts.map +1 -0
- package/api-promise.js +6 -0
- package/api-promise.js.map +1 -0
- package/api-promise.mjs +2 -0
- package/api-promise.mjs.map +1 -0
- package/client.d.mts +180 -0
- package/client.d.mts.map +1 -0
- package/client.d.ts +180 -0
- package/client.d.ts.map +1 -0
- package/client.js +461 -0
- package/client.js.map +1 -0
- package/client.mjs +457 -0
- package/client.mjs.map +1 -0
- package/core/api-promise.d.mts +46 -0
- package/core/api-promise.d.mts.map +1 -0
- package/core/api-promise.d.ts +46 -0
- package/core/api-promise.d.ts.map +1 -0
- package/core/api-promise.js +74 -0
- package/core/api-promise.js.map +1 -0
- package/core/api-promise.mjs +70 -0
- package/core/api-promise.mjs.map +1 -0
- package/core/error.d.mts +46 -0
- package/core/error.d.mts.map +1 -0
- package/core/error.d.ts +46 -0
- package/core/error.d.ts.map +1 -0
- package/core/error.js +113 -0
- package/core/error.js.map +1 -0
- package/core/error.mjs +97 -0
- package/core/error.mjs.map +1 -0
- package/core/resource.d.mts +6 -0
- package/core/resource.d.mts.map +1 -0
- package/core/resource.d.ts +6 -0
- package/core/resource.d.ts.map +1 -0
- package/core/resource.js +11 -0
- package/core/resource.js.map +1 -0
- package/core/resource.mjs +7 -0
- package/core/resource.mjs.map +1 -0
- package/core/uploads.d.mts +3 -0
- package/core/uploads.d.mts.map +1 -0
- package/core/uploads.d.ts +3 -0
- package/core/uploads.d.ts.map +1 -0
- package/core/uploads.js +6 -0
- package/core/uploads.js.map +1 -0
- package/core/uploads.mjs +2 -0
- package/core/uploads.mjs.map +1 -0
- package/error.d.mts +2 -0
- package/error.d.mts.map +1 -0
- package/error.d.ts +2 -0
- package/error.d.ts.map +1 -0
- package/error.js +6 -0
- package/error.js.map +1 -0
- package/error.mjs +2 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +6 -0
- package/index.d.mts.map +1 -0
- package/index.d.ts +6 -0
- package/index.d.ts.map +1 -0
- package/index.js +30 -0
- package/index.js.map +1 -0
- package/index.mjs +7 -0
- package/index.mjs.map +1 -0
- package/internal/builtin-types.d.mts +73 -0
- package/internal/builtin-types.d.mts.map +1 -0
- package/internal/builtin-types.d.ts +73 -0
- package/internal/builtin-types.d.ts.map +1 -0
- package/internal/builtin-types.js +4 -0
- package/internal/builtin-types.js.map +1 -0
- package/internal/builtin-types.mjs +3 -0
- package/internal/builtin-types.mjs.map +1 -0
- package/internal/detect-platform.d.mts +15 -0
- package/internal/detect-platform.d.mts.map +1 -0
- package/internal/detect-platform.d.ts +15 -0
- package/internal/detect-platform.d.ts.map +1 -0
- package/internal/detect-platform.js +162 -0
- package/internal/detect-platform.js.map +1 -0
- package/internal/detect-platform.mjs +157 -0
- package/internal/detect-platform.mjs.map +1 -0
- package/internal/errors.d.mts +3 -0
- package/internal/errors.d.mts.map +1 -0
- package/internal/errors.d.ts +3 -0
- package/internal/errors.d.ts.map +1 -0
- package/internal/errors.js +41 -0
- package/internal/errors.js.map +1 -0
- package/internal/errors.mjs +36 -0
- package/internal/errors.mjs.map +1 -0
- package/internal/headers.d.mts +20 -0
- package/internal/headers.d.mts.map +1 -0
- package/internal/headers.d.ts +20 -0
- package/internal/headers.d.ts.map +1 -0
- package/internal/headers.js +79 -0
- package/internal/headers.js.map +1 -0
- package/internal/headers.mjs +74 -0
- package/internal/headers.mjs.map +1 -0
- package/internal/parse.d.mts +12 -0
- package/internal/parse.d.mts.map +1 -0
- package/internal/parse.d.ts +12 -0
- package/internal/parse.d.ts.map +1 -0
- package/internal/parse.js +35 -0
- package/internal/parse.js.map +1 -0
- package/internal/parse.mjs +32 -0
- package/internal/parse.mjs.map +1 -0
- package/internal/request-options.d.mts +75 -0
- package/internal/request-options.d.mts.map +1 -0
- package/internal/request-options.d.ts +75 -0
- package/internal/request-options.d.ts.map +1 -0
- package/internal/request-options.js +14 -0
- package/internal/request-options.js.map +1 -0
- package/internal/request-options.mjs +10 -0
- package/internal/request-options.mjs.map +1 -0
- package/internal/shim-types.d.mts +17 -0
- package/internal/shim-types.d.mts.map +1 -0
- package/internal/shim-types.d.ts +17 -0
- package/internal/shim-types.d.ts.map +1 -0
- package/internal/shim-types.js +4 -0
- package/internal/shim-types.js.map +1 -0
- package/internal/shim-types.mjs +3 -0
- package/internal/shim-types.mjs.map +1 -0
- package/internal/shims.d.mts +20 -0
- package/internal/shims.d.mts.map +1 -0
- package/internal/shims.d.ts +20 -0
- package/internal/shims.d.ts.map +1 -0
- package/internal/shims.js +92 -0
- package/internal/shims.js.map +1 -0
- package/internal/shims.mjs +85 -0
- package/internal/shims.mjs.map +1 -0
- package/internal/to-file.d.mts +45 -0
- package/internal/to-file.d.mts.map +1 -0
- package/internal/to-file.d.ts +45 -0
- package/internal/to-file.d.ts.map +1 -0
- package/internal/to-file.js +91 -0
- package/internal/to-file.js.map +1 -0
- package/internal/to-file.mjs +88 -0
- package/internal/to-file.mjs.map +1 -0
- package/internal/tslib.js +81 -0
- package/internal/tslib.mjs +17 -0
- package/internal/types.d.mts +69 -0
- package/internal/types.d.mts.map +1 -0
- package/internal/types.d.ts +69 -0
- package/internal/types.d.ts.map +1 -0
- package/internal/types.js +4 -0
- package/internal/types.js.map +1 -0
- package/internal/types.mjs +3 -0
- package/internal/types.mjs.map +1 -0
- package/internal/uploads.d.mts +42 -0
- package/internal/uploads.d.mts.map +1 -0
- package/internal/uploads.d.ts +42 -0
- package/internal/uploads.d.ts.map +1 -0
- package/internal/uploads.js +141 -0
- package/internal/uploads.js.map +1 -0
- package/internal/uploads.mjs +131 -0
- package/internal/uploads.mjs.map +1 -0
- package/internal/utils/base64.d.mts +3 -0
- package/internal/utils/base64.d.mts.map +1 -0
- package/internal/utils/base64.d.ts +3 -0
- package/internal/utils/base64.d.ts.map +1 -0
- package/internal/utils/base64.js +38 -0
- package/internal/utils/base64.js.map +1 -0
- package/internal/utils/base64.mjs +33 -0
- package/internal/utils/base64.mjs.map +1 -0
- package/internal/utils/bytes.d.mts +4 -0
- package/internal/utils/bytes.d.mts.map +1 -0
- package/internal/utils/bytes.d.ts +4 -0
- package/internal/utils/bytes.d.ts.map +1 -0
- package/internal/utils/bytes.js +31 -0
- package/internal/utils/bytes.js.map +1 -0
- package/internal/utils/bytes.mjs +26 -0
- package/internal/utils/bytes.mjs.map +1 -0
- package/internal/utils/env.d.mts +9 -0
- package/internal/utils/env.d.mts.map +1 -0
- package/internal/utils/env.d.ts +9 -0
- package/internal/utils/env.d.ts.map +1 -0
- package/internal/utils/env.js +22 -0
- package/internal/utils/env.js.map +1 -0
- package/internal/utils/env.mjs +18 -0
- package/internal/utils/env.mjs.map +1 -0
- package/internal/utils/log.d.mts +37 -0
- package/internal/utils/log.d.mts.map +1 -0
- package/internal/utils/log.d.ts +37 -0
- package/internal/utils/log.d.ts.map +1 -0
- package/internal/utils/log.js +85 -0
- package/internal/utils/log.js.map +1 -0
- package/internal/utils/log.mjs +79 -0
- package/internal/utils/log.mjs.map +1 -0
- package/internal/utils/path.d.mts +15 -0
- package/internal/utils/path.d.mts.map +1 -0
- package/internal/utils/path.d.ts +15 -0
- package/internal/utils/path.d.ts.map +1 -0
- package/internal/utils/path.js +79 -0
- package/internal/utils/path.js.map +1 -0
- package/internal/utils/path.mjs +74 -0
- package/internal/utils/path.mjs.map +1 -0
- package/internal/utils/sleep.d.mts +2 -0
- package/internal/utils/sleep.d.mts.map +1 -0
- package/internal/utils/sleep.d.ts +2 -0
- package/internal/utils/sleep.d.ts.map +1 -0
- package/internal/utils/sleep.js +7 -0
- package/internal/utils/sleep.js.map +1 -0
- package/internal/utils/sleep.mjs +3 -0
- package/internal/utils/sleep.mjs.map +1 -0
- package/internal/utils/uuid.d.mts +5 -0
- package/internal/utils/uuid.d.mts.map +1 -0
- package/internal/utils/uuid.d.ts +5 -0
- package/internal/utils/uuid.d.ts.map +1 -0
- package/internal/utils/uuid.js +19 -0
- package/internal/utils/uuid.js.map +1 -0
- package/internal/utils/uuid.mjs +15 -0
- package/internal/utils/uuid.mjs.map +1 -0
- package/internal/utils/values.d.mts +18 -0
- package/internal/utils/values.d.mts.map +1 -0
- package/internal/utils/values.d.ts +18 -0
- package/internal/utils/values.d.ts.map +1 -0
- package/internal/utils/values.js +112 -0
- package/internal/utils/values.js.map +1 -0
- package/internal/utils/values.mjs +94 -0
- package/internal/utils/values.mjs.map +1 -0
- package/internal/utils.d.mts +7 -0
- package/internal/utils.d.mts.map +1 -0
- package/internal/utils.d.ts +7 -0
- package/internal/utils.d.ts.map +1 -0
- package/internal/utils.js +11 -0
- package/internal/utils.js.map +1 -0
- package/internal/utils.mjs +8 -0
- package/internal/utils.mjs.map +1 -0
- package/package.json +137 -0
- package/resource.d.mts +2 -0
- package/resource.d.mts.map +1 -0
- package/resource.d.ts +2 -0
- package/resource.d.ts.map +1 -0
- package/resource.js +6 -0
- package/resource.js.map +1 -0
- package/resource.mjs +2 -0
- package/resource.mjs.map +1 -0
- package/resources/index.d.mts +2 -0
- package/resources/index.d.mts.map +1 -0
- package/resources/index.d.ts +2 -0
- package/resources/index.d.ts.map +1 -0
- package/resources/index.js +7 -0
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +3 -0
- package/resources/index.mjs.map +1 -0
- package/resources/organizations/index.d.mts +3 -0
- package/resources/organizations/index.d.mts.map +1 -0
- package/resources/organizations/index.d.ts +3 -0
- package/resources/organizations/index.d.ts.map +1 -0
- package/resources/organizations/index.js +9 -0
- package/resources/organizations/index.js.map +1 -0
- package/resources/organizations/index.mjs +4 -0
- package/resources/organizations/index.mjs.map +1 -0
- package/resources/organizations/organizations.d.mts +10 -0
- package/resources/organizations/organizations.d.mts.map +1 -0
- package/resources/organizations/organizations.d.ts +10 -0
- package/resources/organizations/organizations.d.ts.map +1 -0
- package/resources/organizations/organizations.js +17 -0
- package/resources/organizations/organizations.js.map +1 -0
- package/resources/organizations/organizations.mjs +12 -0
- package/resources/organizations/organizations.mjs.map +1 -0
- package/resources/organizations/policies.d.mts +298 -0
- package/resources/organizations/policies.d.mts.map +1 -0
- package/resources/organizations/policies.d.ts +298 -0
- package/resources/organizations/policies.d.ts.map +1 -0
- package/resources/organizations/policies.js +35 -0
- package/resources/organizations/policies.js.map +1 -0
- package/resources/organizations/policies.mjs +31 -0
- package/resources/organizations/policies.mjs.map +1 -0
- package/resources/organizations.d.mts +2 -0
- package/resources/organizations.d.mts.map +1 -0
- package/resources/organizations.d.ts +2 -0
- package/resources/organizations.d.ts.map +1 -0
- package/resources/organizations.js +6 -0
- package/resources/organizations.js.map +1 -0
- package/resources/organizations.mjs +3 -0
- package/resources/organizations.mjs.map +1 -0
- package/resources.d.mts +2 -0
- package/resources.d.mts.map +1 -0
- package/resources.d.ts +2 -0
- package/resources.d.ts.map +1 -0
- package/resources.js +5 -0
- package/resources.js.map +1 -0
- package/resources.mjs +2 -0
- package/resources.mjs.map +1 -0
- package/src/api-promise.ts +2 -0
- package/src/client.ts +726 -0
- package/src/core/README.md +3 -0
- package/src/core/api-promise.ts +92 -0
- package/src/core/error.ts +130 -0
- package/src/core/resource.ts +11 -0
- package/src/core/uploads.ts +2 -0
- package/src/error.ts +2 -0
- package/src/index.ts +22 -0
- package/src/internal/README.md +3 -0
- package/src/internal/builtin-types.ts +93 -0
- package/src/internal/detect-platform.ts +196 -0
- package/src/internal/errors.ts +33 -0
- package/src/internal/headers.ts +97 -0
- package/src/internal/parse.ts +50 -0
- package/src/internal/request-options.ts +91 -0
- package/src/internal/shim-types.ts +26 -0
- package/src/internal/shims.ts +107 -0
- package/src/internal/to-file.ts +154 -0
- package/src/internal/types.ts +95 -0
- package/src/internal/uploads.ts +187 -0
- package/src/internal/utils/base64.ts +40 -0
- package/src/internal/utils/bytes.ts +32 -0
- package/src/internal/utils/env.ts +18 -0
- package/src/internal/utils/log.ts +126 -0
- package/src/internal/utils/path.ts +88 -0
- package/src/internal/utils/sleep.ts +3 -0
- package/src/internal/utils/uuid.ts +17 -0
- package/src/internal/utils/values.ts +105 -0
- package/src/internal/utils.ts +8 -0
- package/src/lib/.keep +4 -0
- package/src/resource.ts +2 -0
- package/src/resources/index.ts +3 -0
- package/src/resources/organizations/index.ts +9 -0
- package/src/resources/organizations/organizations.ts +25 -0
- package/src/resources/organizations/policies.ts +370 -0
- package/src/resources/organizations.ts +3 -0
- package/src/resources.ts +1 -0
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +2 -0
- package/src/version.ts +1 -0
- package/uploads.d.mts +2 -0
- package/uploads.d.mts.map +1 -0
- package/uploads.d.ts +2 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +6 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +2 -0
- package/uploads.mjs.map +1 -0
- package/version.d.mts +2 -0
- package/version.d.mts.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { APIResource } from "../../core/resource.mjs";
|
|
2
|
+
import * as PoliciesAPI from "./policies.mjs";
|
|
3
|
+
import { APIPromise } from "../../core/api-promise.mjs";
|
|
4
|
+
import { RequestOptions } from "../../internal/request-options.mjs";
|
|
5
|
+
export declare class Policies extends APIResource {
|
|
6
|
+
/**
|
|
7
|
+
* Evaluates a set of messages against the specified policy and returns guardrail
|
|
8
|
+
* decisions.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const response =
|
|
13
|
+
* await client.organizations.policies.enforce(
|
|
14
|
+
* 'a90e34d6-41af-432f-a6ae-046598df4539',
|
|
15
|
+
* {
|
|
16
|
+
* direction: 'input',
|
|
17
|
+
* messages: [
|
|
18
|
+
* {
|
|
19
|
+
* content:
|
|
20
|
+
* 'Can you summarize the plot of Interstellar?',
|
|
21
|
+
* role: 'user',
|
|
22
|
+
* },
|
|
23
|
+
* ],
|
|
24
|
+
* },
|
|
25
|
+
* );
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
enforce(policyIdentifier: string, body: PolicyEnforceParams, options?: RequestOptions): APIPromise<PolicyEnforceResponse>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Enum representing possible policy enforcement result actions.
|
|
32
|
+
*/
|
|
33
|
+
export type PolicyEnforcementResultActionValue = 'block' | 'redact' | 'detect' | 'allow';
|
|
34
|
+
/**
|
|
35
|
+
* Policy enforcement response schema.
|
|
36
|
+
*/
|
|
37
|
+
export interface PolicyEnforceResponse {
|
|
38
|
+
/**
|
|
39
|
+
* Overall action decided by the policy (allow, detect, redact, block).
|
|
40
|
+
*/
|
|
41
|
+
action: PolicyEnforcementResultActionValue;
|
|
42
|
+
/**
|
|
43
|
+
* Per-guardrail evaluation results.
|
|
44
|
+
*/
|
|
45
|
+
evaluations: Array<PolicyEnforceResponse.PromptInjectionEvaluationResponseSchema | PolicyEnforceResponse.ContentSafetyEvaluationResponseSchema | PolicyEnforceResponse.DataLeakageEvaluationResponseSchema | PolicyEnforceResponse.ContextSafetyEvaluationResponseSchema>;
|
|
46
|
+
}
|
|
47
|
+
export declare namespace PolicyEnforceResponse {
|
|
48
|
+
/**
|
|
49
|
+
* Evaluation payload for prompt injection guardrail.
|
|
50
|
+
*/
|
|
51
|
+
interface PromptInjectionEvaluationResponseSchema {
|
|
52
|
+
/**
|
|
53
|
+
* Action suggested by this guardrail (allow, detect, redact, block).
|
|
54
|
+
*/
|
|
55
|
+
action: PoliciesAPI.PolicyEnforcementResultActionValue;
|
|
56
|
+
/**
|
|
57
|
+
* Guardrail key that produced this evaluation.
|
|
58
|
+
*/
|
|
59
|
+
guardrailKey: 'prompt_injection_protection';
|
|
60
|
+
/**
|
|
61
|
+
* Overall confidence score.
|
|
62
|
+
*/
|
|
63
|
+
score: number;
|
|
64
|
+
/**
|
|
65
|
+
* Evidence or reasoning threads generated by the guardrail.
|
|
66
|
+
*/
|
|
67
|
+
threads: Array<PromptInjectionEvaluationResponseSchema.Thread>;
|
|
68
|
+
/**
|
|
69
|
+
* Additional guardrail-specific metadata.
|
|
70
|
+
*/
|
|
71
|
+
metadata?: {
|
|
72
|
+
[key: string]: unknown;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
namespace PromptInjectionEvaluationResponseSchema {
|
|
76
|
+
/**
|
|
77
|
+
* Thread details for prompt injection guardrail.
|
|
78
|
+
*/
|
|
79
|
+
interface Thread {
|
|
80
|
+
/**
|
|
81
|
+
* Index of the chunk/part within the message.
|
|
82
|
+
*/
|
|
83
|
+
contentIdentifier: number;
|
|
84
|
+
/**
|
|
85
|
+
* Index of the message containing the issue.
|
|
86
|
+
*/
|
|
87
|
+
messageIdentifier: number;
|
|
88
|
+
/**
|
|
89
|
+
* Confidence score for this detection.
|
|
90
|
+
*/
|
|
91
|
+
score: number;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Evaluation payload for content safety guardrail.
|
|
96
|
+
*/
|
|
97
|
+
interface ContentSafetyEvaluationResponseSchema {
|
|
98
|
+
/**
|
|
99
|
+
* Action suggested by this guardrail (allow, detect, redact, block).
|
|
100
|
+
*/
|
|
101
|
+
action: PoliciesAPI.PolicyEnforcementResultActionValue;
|
|
102
|
+
/**
|
|
103
|
+
* Guardrail key that produced this evaluation.
|
|
104
|
+
*/
|
|
105
|
+
guardrailKey: 'content_safety_filtering';
|
|
106
|
+
/**
|
|
107
|
+
* Overall confidence score.
|
|
108
|
+
*/
|
|
109
|
+
score: number;
|
|
110
|
+
/**
|
|
111
|
+
* Evidence or reasoning threads generated by the guardrail.
|
|
112
|
+
*/
|
|
113
|
+
threads: Array<ContentSafetyEvaluationResponseSchema.Thread>;
|
|
114
|
+
/**
|
|
115
|
+
* Additional guardrail-specific metadata.
|
|
116
|
+
*/
|
|
117
|
+
metadata?: {
|
|
118
|
+
[key: string]: unknown;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
namespace ContentSafetyEvaluationResponseSchema {
|
|
122
|
+
/**
|
|
123
|
+
* Thread details for content safety guardrail.
|
|
124
|
+
*/
|
|
125
|
+
interface Thread {
|
|
126
|
+
/**
|
|
127
|
+
* Content safety category hit by the message.
|
|
128
|
+
*/
|
|
129
|
+
category: 'hate' | 'crime' | 'sexual' | 'violence';
|
|
130
|
+
/**
|
|
131
|
+
* Index of the chunk/part within the message.
|
|
132
|
+
*/
|
|
133
|
+
contentIdentifier: number;
|
|
134
|
+
/**
|
|
135
|
+
* Index of the message containing the issue.
|
|
136
|
+
*/
|
|
137
|
+
messageIdentifier: number;
|
|
138
|
+
/**
|
|
139
|
+
* Confidence score for the category.
|
|
140
|
+
*/
|
|
141
|
+
score: number;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Evaluation payload for data leakage guardrail.
|
|
146
|
+
*/
|
|
147
|
+
interface DataLeakageEvaluationResponseSchema {
|
|
148
|
+
/**
|
|
149
|
+
* Action suggested by this guardrail (allow, detect, redact, block).
|
|
150
|
+
*/
|
|
151
|
+
action: PoliciesAPI.PolicyEnforcementResultActionValue;
|
|
152
|
+
/**
|
|
153
|
+
* Guardrail key that produced this evaluation.
|
|
154
|
+
*/
|
|
155
|
+
guardrailKey: 'data_leakage_protection';
|
|
156
|
+
/**
|
|
157
|
+
* Overall confidence score.
|
|
158
|
+
*/
|
|
159
|
+
score: number;
|
|
160
|
+
/**
|
|
161
|
+
* Evidence or reasoning threads generated by the guardrail.
|
|
162
|
+
*/
|
|
163
|
+
threads: Array<DataLeakageEvaluationResponseSchema.Thread>;
|
|
164
|
+
/**
|
|
165
|
+
* Additional guardrail-specific metadata.
|
|
166
|
+
*/
|
|
167
|
+
metadata?: {
|
|
168
|
+
[key: string]: unknown;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
namespace DataLeakageEvaluationResponseSchema {
|
|
172
|
+
/**
|
|
173
|
+
* Thread details for data leakage guardrail.
|
|
174
|
+
*/
|
|
175
|
+
interface Thread {
|
|
176
|
+
/**
|
|
177
|
+
* Detected PII/secret category (email, phone, etc).
|
|
178
|
+
*/
|
|
179
|
+
category: 'name' | 'email' | 'phone' | 'address' | 'location' | 'date' | 'ssn' | 'credit_card' | 'bank_account' | 'id_number' | 'ip_address' | 'url' | 'username' | 'password' | 'api_key' | 'organization' | 'other';
|
|
180
|
+
/**
|
|
181
|
+
* Index of the chunk/part within the message.
|
|
182
|
+
*/
|
|
183
|
+
contentIdentifier: number;
|
|
184
|
+
/**
|
|
185
|
+
* Index of the message containing the leak.
|
|
186
|
+
*/
|
|
187
|
+
messageIdentifier: number;
|
|
188
|
+
/**
|
|
189
|
+
* Confidence score for the detection.
|
|
190
|
+
*/
|
|
191
|
+
score: number;
|
|
192
|
+
/**
|
|
193
|
+
* Detected span of text that triggered the guardrail.
|
|
194
|
+
*/
|
|
195
|
+
span: string;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Evaluation payload for context safety guardrail.
|
|
200
|
+
*/
|
|
201
|
+
interface ContextSafetyEvaluationResponseSchema {
|
|
202
|
+
/**
|
|
203
|
+
* Action suggested by this guardrail (allow, detect, redact, block).
|
|
204
|
+
*/
|
|
205
|
+
action: PoliciesAPI.PolicyEnforcementResultActionValue;
|
|
206
|
+
/**
|
|
207
|
+
* Guardrail key that produced this evaluation.
|
|
208
|
+
*/
|
|
209
|
+
guardrailKey: 'context_safety_filtering';
|
|
210
|
+
/**
|
|
211
|
+
* Overall confidence score.
|
|
212
|
+
*/
|
|
213
|
+
score: number;
|
|
214
|
+
/**
|
|
215
|
+
* Evidence or reasoning threads generated by the guardrail.
|
|
216
|
+
*/
|
|
217
|
+
threads: Array<ContextSafetyEvaluationResponseSchema.Thread>;
|
|
218
|
+
/**
|
|
219
|
+
* Additional guardrail-specific metadata.
|
|
220
|
+
*/
|
|
221
|
+
metadata?: {
|
|
222
|
+
[key: string]: unknown;
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
namespace ContextSafetyEvaluationResponseSchema {
|
|
226
|
+
/**
|
|
227
|
+
* Thread details for context safety guardrail.
|
|
228
|
+
*/
|
|
229
|
+
interface Thread {
|
|
230
|
+
/**
|
|
231
|
+
* Index of the chunk/part within the message.
|
|
232
|
+
*/
|
|
233
|
+
contentIdentifier: number;
|
|
234
|
+
/**
|
|
235
|
+
* Index of the message containing the issue.
|
|
236
|
+
*/
|
|
237
|
+
messageIdentifier: number;
|
|
238
|
+
/**
|
|
239
|
+
* Confidence score for the topic.
|
|
240
|
+
*/
|
|
241
|
+
score: number;
|
|
242
|
+
/**
|
|
243
|
+
* Topic label that was flagged.
|
|
244
|
+
*/
|
|
245
|
+
topic: string;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
export interface PolicyEnforceParams {
|
|
250
|
+
/**
|
|
251
|
+
* Whether to evaluate input or output messages against the policy.
|
|
252
|
+
*/
|
|
253
|
+
direction: 'input' | 'output';
|
|
254
|
+
/**
|
|
255
|
+
* Ordered list of messages that compose the conversation to evaluate.
|
|
256
|
+
*/
|
|
257
|
+
messages: Array<PolicyEnforceParams.Message>;
|
|
258
|
+
/**
|
|
259
|
+
* Optional contextual metadata forwarded to guardrails.
|
|
260
|
+
*/
|
|
261
|
+
metadata?: {
|
|
262
|
+
[key: string]: unknown;
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
export declare namespace PolicyEnforceParams {
|
|
266
|
+
/**
|
|
267
|
+
* Policy enforcer message request schema.
|
|
268
|
+
*/
|
|
269
|
+
interface Message {
|
|
270
|
+
/**
|
|
271
|
+
* Raw text or a list of typed text blocks composing the message.
|
|
272
|
+
*/
|
|
273
|
+
content: string | Array<Message.Block>;
|
|
274
|
+
/**
|
|
275
|
+
* Message role within the conversation.
|
|
276
|
+
*/
|
|
277
|
+
role: 'system' | 'user' | 'assistant';
|
|
278
|
+
}
|
|
279
|
+
namespace Message {
|
|
280
|
+
/**
|
|
281
|
+
* Policy enforcer text message request schema.
|
|
282
|
+
*/
|
|
283
|
+
interface Block {
|
|
284
|
+
/**
|
|
285
|
+
* Message text content.
|
|
286
|
+
*/
|
|
287
|
+
text: string;
|
|
288
|
+
/**
|
|
289
|
+
* Content block type.
|
|
290
|
+
*/
|
|
291
|
+
type: 'text' | 'document' | 'image' | 'audio' | 'video';
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
export declare namespace Policies {
|
|
296
|
+
export { type PolicyEnforcementResultActionValue as PolicyEnforcementResultActionValue, type PolicyEnforceResponse as PolicyEnforceResponse, type PolicyEnforceParams as PolicyEnforceParams, };
|
|
297
|
+
}
|
|
298
|
+
//# sourceMappingURL=policies.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policies.d.mts","sourceRoot":"","sources":["../../src/resources/organizations/policies.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,WAAW;OAChB,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAGzB,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,OAAO,CACL,gBAAgB,EAAE,MAAM,EACxB,IAAI,EAAE,mBAAmB,EACzB,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,qBAAqB,CAAC;CAGrC;AAED;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEzF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,MAAM,EAAE,kCAAkC,CAAC;IAE3C;;OAEG;IACH,WAAW,EAAE,KAAK,CACd,qBAAqB,CAAC,uCAAuC,GAC7D,qBAAqB,CAA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
|
|
3
|
+
import { APIPromise } from "../../core/api-promise.js";
|
|
4
|
+
import { RequestOptions } from "../../internal/request-options.js";
|
|
5
|
+
export declare class Policies extends APIResource {
|
|
6
|
+
/**
|
|
7
|
+
* Evaluates a set of messages against the specified policy and returns guardrail
|
|
8
|
+
* decisions.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const response =
|
|
13
|
+
* await client.organizations.policies.enforce(
|
|
14
|
+
* 'a90e34d6-41af-432f-a6ae-046598df4539',
|
|
15
|
+
* {
|
|
16
|
+
* direction: 'input',
|
|
17
|
+
* messages: [
|
|
18
|
+
* {
|
|
19
|
+
* content:
|
|
20
|
+
* 'Can you summarize the plot of Interstellar?',
|
|
21
|
+
* role: 'user',
|
|
22
|
+
* },
|
|
23
|
+
* ],
|
|
24
|
+
* },
|
|
25
|
+
* );
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
enforce(policyIdentifier: string, body: PolicyEnforceParams, options?: RequestOptions): APIPromise<PolicyEnforceResponse>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Enum representing possible policy enforcement result actions.
|
|
32
|
+
*/
|
|
33
|
+
export type PolicyEnforcementResultActionValue = 'block' | 'redact' | 'detect' | 'allow';
|
|
34
|
+
/**
|
|
35
|
+
* Policy enforcement response schema.
|
|
36
|
+
*/
|
|
37
|
+
export interface PolicyEnforceResponse {
|
|
38
|
+
/**
|
|
39
|
+
* Overall action decided by the policy (allow, detect, redact, block).
|
|
40
|
+
*/
|
|
41
|
+
action: PolicyEnforcementResultActionValue;
|
|
42
|
+
/**
|
|
43
|
+
* Per-guardrail evaluation results.
|
|
44
|
+
*/
|
|
45
|
+
evaluations: Array<PolicyEnforceResponse.PromptInjectionEvaluationResponseSchema | PolicyEnforceResponse.ContentSafetyEvaluationResponseSchema | PolicyEnforceResponse.DataLeakageEvaluationResponseSchema | PolicyEnforceResponse.ContextSafetyEvaluationResponseSchema>;
|
|
46
|
+
}
|
|
47
|
+
export declare namespace PolicyEnforceResponse {
|
|
48
|
+
/**
|
|
49
|
+
* Evaluation payload for prompt injection guardrail.
|
|
50
|
+
*/
|
|
51
|
+
interface PromptInjectionEvaluationResponseSchema {
|
|
52
|
+
/**
|
|
53
|
+
* Action suggested by this guardrail (allow, detect, redact, block).
|
|
54
|
+
*/
|
|
55
|
+
action: PoliciesAPI.PolicyEnforcementResultActionValue;
|
|
56
|
+
/**
|
|
57
|
+
* Guardrail key that produced this evaluation.
|
|
58
|
+
*/
|
|
59
|
+
guardrailKey: 'prompt_injection_protection';
|
|
60
|
+
/**
|
|
61
|
+
* Overall confidence score.
|
|
62
|
+
*/
|
|
63
|
+
score: number;
|
|
64
|
+
/**
|
|
65
|
+
* Evidence or reasoning threads generated by the guardrail.
|
|
66
|
+
*/
|
|
67
|
+
threads: Array<PromptInjectionEvaluationResponseSchema.Thread>;
|
|
68
|
+
/**
|
|
69
|
+
* Additional guardrail-specific metadata.
|
|
70
|
+
*/
|
|
71
|
+
metadata?: {
|
|
72
|
+
[key: string]: unknown;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
namespace PromptInjectionEvaluationResponseSchema {
|
|
76
|
+
/**
|
|
77
|
+
* Thread details for prompt injection guardrail.
|
|
78
|
+
*/
|
|
79
|
+
interface Thread {
|
|
80
|
+
/**
|
|
81
|
+
* Index of the chunk/part within the message.
|
|
82
|
+
*/
|
|
83
|
+
contentIdentifier: number;
|
|
84
|
+
/**
|
|
85
|
+
* Index of the message containing the issue.
|
|
86
|
+
*/
|
|
87
|
+
messageIdentifier: number;
|
|
88
|
+
/**
|
|
89
|
+
* Confidence score for this detection.
|
|
90
|
+
*/
|
|
91
|
+
score: number;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Evaluation payload for content safety guardrail.
|
|
96
|
+
*/
|
|
97
|
+
interface ContentSafetyEvaluationResponseSchema {
|
|
98
|
+
/**
|
|
99
|
+
* Action suggested by this guardrail (allow, detect, redact, block).
|
|
100
|
+
*/
|
|
101
|
+
action: PoliciesAPI.PolicyEnforcementResultActionValue;
|
|
102
|
+
/**
|
|
103
|
+
* Guardrail key that produced this evaluation.
|
|
104
|
+
*/
|
|
105
|
+
guardrailKey: 'content_safety_filtering';
|
|
106
|
+
/**
|
|
107
|
+
* Overall confidence score.
|
|
108
|
+
*/
|
|
109
|
+
score: number;
|
|
110
|
+
/**
|
|
111
|
+
* Evidence or reasoning threads generated by the guardrail.
|
|
112
|
+
*/
|
|
113
|
+
threads: Array<ContentSafetyEvaluationResponseSchema.Thread>;
|
|
114
|
+
/**
|
|
115
|
+
* Additional guardrail-specific metadata.
|
|
116
|
+
*/
|
|
117
|
+
metadata?: {
|
|
118
|
+
[key: string]: unknown;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
namespace ContentSafetyEvaluationResponseSchema {
|
|
122
|
+
/**
|
|
123
|
+
* Thread details for content safety guardrail.
|
|
124
|
+
*/
|
|
125
|
+
interface Thread {
|
|
126
|
+
/**
|
|
127
|
+
* Content safety category hit by the message.
|
|
128
|
+
*/
|
|
129
|
+
category: 'hate' | 'crime' | 'sexual' | 'violence';
|
|
130
|
+
/**
|
|
131
|
+
* Index of the chunk/part within the message.
|
|
132
|
+
*/
|
|
133
|
+
contentIdentifier: number;
|
|
134
|
+
/**
|
|
135
|
+
* Index of the message containing the issue.
|
|
136
|
+
*/
|
|
137
|
+
messageIdentifier: number;
|
|
138
|
+
/**
|
|
139
|
+
* Confidence score for the category.
|
|
140
|
+
*/
|
|
141
|
+
score: number;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Evaluation payload for data leakage guardrail.
|
|
146
|
+
*/
|
|
147
|
+
interface DataLeakageEvaluationResponseSchema {
|
|
148
|
+
/**
|
|
149
|
+
* Action suggested by this guardrail (allow, detect, redact, block).
|
|
150
|
+
*/
|
|
151
|
+
action: PoliciesAPI.PolicyEnforcementResultActionValue;
|
|
152
|
+
/**
|
|
153
|
+
* Guardrail key that produced this evaluation.
|
|
154
|
+
*/
|
|
155
|
+
guardrailKey: 'data_leakage_protection';
|
|
156
|
+
/**
|
|
157
|
+
* Overall confidence score.
|
|
158
|
+
*/
|
|
159
|
+
score: number;
|
|
160
|
+
/**
|
|
161
|
+
* Evidence or reasoning threads generated by the guardrail.
|
|
162
|
+
*/
|
|
163
|
+
threads: Array<DataLeakageEvaluationResponseSchema.Thread>;
|
|
164
|
+
/**
|
|
165
|
+
* Additional guardrail-specific metadata.
|
|
166
|
+
*/
|
|
167
|
+
metadata?: {
|
|
168
|
+
[key: string]: unknown;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
namespace DataLeakageEvaluationResponseSchema {
|
|
172
|
+
/**
|
|
173
|
+
* Thread details for data leakage guardrail.
|
|
174
|
+
*/
|
|
175
|
+
interface Thread {
|
|
176
|
+
/**
|
|
177
|
+
* Detected PII/secret category (email, phone, etc).
|
|
178
|
+
*/
|
|
179
|
+
category: 'name' | 'email' | 'phone' | 'address' | 'location' | 'date' | 'ssn' | 'credit_card' | 'bank_account' | 'id_number' | 'ip_address' | 'url' | 'username' | 'password' | 'api_key' | 'organization' | 'other';
|
|
180
|
+
/**
|
|
181
|
+
* Index of the chunk/part within the message.
|
|
182
|
+
*/
|
|
183
|
+
contentIdentifier: number;
|
|
184
|
+
/**
|
|
185
|
+
* Index of the message containing the leak.
|
|
186
|
+
*/
|
|
187
|
+
messageIdentifier: number;
|
|
188
|
+
/**
|
|
189
|
+
* Confidence score for the detection.
|
|
190
|
+
*/
|
|
191
|
+
score: number;
|
|
192
|
+
/**
|
|
193
|
+
* Detected span of text that triggered the guardrail.
|
|
194
|
+
*/
|
|
195
|
+
span: string;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Evaluation payload for context safety guardrail.
|
|
200
|
+
*/
|
|
201
|
+
interface ContextSafetyEvaluationResponseSchema {
|
|
202
|
+
/**
|
|
203
|
+
* Action suggested by this guardrail (allow, detect, redact, block).
|
|
204
|
+
*/
|
|
205
|
+
action: PoliciesAPI.PolicyEnforcementResultActionValue;
|
|
206
|
+
/**
|
|
207
|
+
* Guardrail key that produced this evaluation.
|
|
208
|
+
*/
|
|
209
|
+
guardrailKey: 'context_safety_filtering';
|
|
210
|
+
/**
|
|
211
|
+
* Overall confidence score.
|
|
212
|
+
*/
|
|
213
|
+
score: number;
|
|
214
|
+
/**
|
|
215
|
+
* Evidence or reasoning threads generated by the guardrail.
|
|
216
|
+
*/
|
|
217
|
+
threads: Array<ContextSafetyEvaluationResponseSchema.Thread>;
|
|
218
|
+
/**
|
|
219
|
+
* Additional guardrail-specific metadata.
|
|
220
|
+
*/
|
|
221
|
+
metadata?: {
|
|
222
|
+
[key: string]: unknown;
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
namespace ContextSafetyEvaluationResponseSchema {
|
|
226
|
+
/**
|
|
227
|
+
* Thread details for context safety guardrail.
|
|
228
|
+
*/
|
|
229
|
+
interface Thread {
|
|
230
|
+
/**
|
|
231
|
+
* Index of the chunk/part within the message.
|
|
232
|
+
*/
|
|
233
|
+
contentIdentifier: number;
|
|
234
|
+
/**
|
|
235
|
+
* Index of the message containing the issue.
|
|
236
|
+
*/
|
|
237
|
+
messageIdentifier: number;
|
|
238
|
+
/**
|
|
239
|
+
* Confidence score for the topic.
|
|
240
|
+
*/
|
|
241
|
+
score: number;
|
|
242
|
+
/**
|
|
243
|
+
* Topic label that was flagged.
|
|
244
|
+
*/
|
|
245
|
+
topic: string;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
export interface PolicyEnforceParams {
|
|
250
|
+
/**
|
|
251
|
+
* Whether to evaluate input or output messages against the policy.
|
|
252
|
+
*/
|
|
253
|
+
direction: 'input' | 'output';
|
|
254
|
+
/**
|
|
255
|
+
* Ordered list of messages that compose the conversation to evaluate.
|
|
256
|
+
*/
|
|
257
|
+
messages: Array<PolicyEnforceParams.Message>;
|
|
258
|
+
/**
|
|
259
|
+
* Optional contextual metadata forwarded to guardrails.
|
|
260
|
+
*/
|
|
261
|
+
metadata?: {
|
|
262
|
+
[key: string]: unknown;
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
export declare namespace PolicyEnforceParams {
|
|
266
|
+
/**
|
|
267
|
+
* Policy enforcer message request schema.
|
|
268
|
+
*/
|
|
269
|
+
interface Message {
|
|
270
|
+
/**
|
|
271
|
+
* Raw text or a list of typed text blocks composing the message.
|
|
272
|
+
*/
|
|
273
|
+
content: string | Array<Message.Block>;
|
|
274
|
+
/**
|
|
275
|
+
* Message role within the conversation.
|
|
276
|
+
*/
|
|
277
|
+
role: 'system' | 'user' | 'assistant';
|
|
278
|
+
}
|
|
279
|
+
namespace Message {
|
|
280
|
+
/**
|
|
281
|
+
* Policy enforcer text message request schema.
|
|
282
|
+
*/
|
|
283
|
+
interface Block {
|
|
284
|
+
/**
|
|
285
|
+
* Message text content.
|
|
286
|
+
*/
|
|
287
|
+
text: string;
|
|
288
|
+
/**
|
|
289
|
+
* Content block type.
|
|
290
|
+
*/
|
|
291
|
+
type: 'text' | 'document' | 'image' | 'audio' | 'video';
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
export declare namespace Policies {
|
|
296
|
+
export { type PolicyEnforcementResultActionValue as PolicyEnforcementResultActionValue, type PolicyEnforceResponse as PolicyEnforceResponse, type PolicyEnforceParams as PolicyEnforceParams, };
|
|
297
|
+
}
|
|
298
|
+
//# sourceMappingURL=policies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policies.d.ts","sourceRoot":"","sources":["../../src/resources/organizations/policies.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,WAAW;OAChB,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAGzB,qBAAa,QAAS,SAAQ,WAAW;IACvC;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AK;YACpB;;eAEG;YACH,IAAI,EAAE,MAAM,CAAC;YAEb;;eAEG;YACH,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;SACzD;KACF;CACF;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,OAAO,EACL,KAAK,kCAAkC,IAAI,kCAAkC,EAC7E,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,mBAAmB,IAAI,mBAAmB,GAChD,CAAC;CACH"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Policies = void 0;
|
|
5
|
+
const resource_1 = require("../../core/resource.js");
|
|
6
|
+
const path_1 = require("../../internal/utils/path.js");
|
|
7
|
+
class Policies extends resource_1.APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* Evaluates a set of messages against the specified policy and returns guardrail
|
|
10
|
+
* decisions.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const response =
|
|
15
|
+
* await client.organizations.policies.enforce(
|
|
16
|
+
* 'a90e34d6-41af-432f-a6ae-046598df4539',
|
|
17
|
+
* {
|
|
18
|
+
* direction: 'input',
|
|
19
|
+
* messages: [
|
|
20
|
+
* {
|
|
21
|
+
* content:
|
|
22
|
+
* 'Can you summarize the plot of Interstellar?',
|
|
23
|
+
* role: 'user',
|
|
24
|
+
* },
|
|
25
|
+
* ],
|
|
26
|
+
* },
|
|
27
|
+
* );
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
enforce(policyIdentifier, body, options) {
|
|
31
|
+
return this._client.post((0, path_1.path) `/organizations/policies/${policyIdentifier}/enforce`, { body, ...options });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.Policies = Policies;
|
|
35
|
+
//# sourceMappingURL=policies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policies.js","sourceRoot":"","sources":["../../src/resources/organizations/policies.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,qDAAkD;AAIlD,uDAAiD;AAEjD,MAAa,QAAS,SAAQ,sBAAW;IACvC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,OAAO,CACL,gBAAwB,EACxB,IAAyB,EACzB,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,2BAA2B,gBAAgB,UAAU,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC5G,CAAC;CACF;AA9BD,4BA8BC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { APIResource } from "../../core/resource.mjs";
|
|
3
|
+
import { path } from "../../internal/utils/path.mjs";
|
|
4
|
+
export class Policies extends APIResource {
|
|
5
|
+
/**
|
|
6
|
+
* Evaluates a set of messages against the specified policy and returns guardrail
|
|
7
|
+
* decisions.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const response =
|
|
12
|
+
* await client.organizations.policies.enforce(
|
|
13
|
+
* 'a90e34d6-41af-432f-a6ae-046598df4539',
|
|
14
|
+
* {
|
|
15
|
+
* direction: 'input',
|
|
16
|
+
* messages: [
|
|
17
|
+
* {
|
|
18
|
+
* content:
|
|
19
|
+
* 'Can you summarize the plot of Interstellar?',
|
|
20
|
+
* role: 'user',
|
|
21
|
+
* },
|
|
22
|
+
* ],
|
|
23
|
+
* },
|
|
24
|
+
* );
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
enforce(policyIdentifier, body, options) {
|
|
28
|
+
return this._client.post(path `/organizations/policies/${policyIdentifier}/enforce`, { body, ...options });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=policies.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policies.mjs","sourceRoot":"","sources":["../../src/resources/organizations/policies.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAIf,EAAE,IAAI,EAAE;AAEf,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,OAAO,CACL,gBAAwB,EACxB,IAAyB,EACzB,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,2BAA2B,gBAAgB,UAAU,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC5G,CAAC;CACF"}
|