@daocloud-proto/hydra 0.17.0-rc1-dev-7 → 0.17.0-rc1-dev-9

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.
@@ -9,6 +9,15 @@ import * as fm from "../../../fetch.pb"
9
9
  import * as GoogleApiHttpbody from "../../../google/api/httpbody.pb"
10
10
  import * as GoogleProtobufTimestamp from "../../../google/protobuf/timestamp.pb"
11
11
 
12
+ type Absent<T, K extends keyof T> = { [k in Exclude<keyof T, K>]?: undefined };
13
+ type OneOf<T> =
14
+ | { [k in keyof T]?: undefined }
15
+ | (
16
+ keyof T extends infer K ?
17
+ (K extends string & keyof T ? { [k in K]: T[K] } & Absent<T, K>
18
+ : never)
19
+ : never);
20
+
12
21
  export enum BlockStrategy {
13
22
  BLOCK_STRATEGY_UNSPECIFIED = "BLOCK_STRATEGY_UNSPECIFIED",
14
23
  BLOCK_STRATEGY_ANY = "BLOCK_STRATEGY_ANY",
@@ -29,6 +38,32 @@ export enum PluginAction {
29
38
  PLUGIN_ACTION_REPLACE_MASK = "PLUGIN_ACTION_REPLACE_MASK",
30
39
  }
31
40
 
41
+ export enum CheckPhase {
42
+ CHECK_PHASE_UNSPECIFIED = "CHECK_PHASE_UNSPECIFIED",
43
+ CHECK_PHASE_INPUT = "CHECK_PHASE_INPUT",
44
+ CHECK_PHASE_OUTPUT = "CHECK_PHASE_OUTPUT",
45
+ CHECK_PHASE_BOTH = "CHECK_PHASE_BOTH",
46
+ }
47
+
48
+ export enum ExternalDetectProvider {
49
+ EXTERNAL_DETECT_PROVIDER_UNSPECIFIED = "EXTERNAL_DETECT_PROVIDER_UNSPECIFIED",
50
+ EXTERNAL_DETECT_PROVIDER_NSFOCUS = "EXTERNAL_DETECT_PROVIDER_NSFOCUS",
51
+ EXTERNAL_DETECT_PROVIDER_CUSTOM = "EXTERNAL_DETECT_PROVIDER_CUSTOM",
52
+ }
53
+
54
+ export enum SafetyCategory {
55
+ SAFETY_CATEGORY_UNSPECIFIED = "SAFETY_CATEGORY_UNSPECIFIED",
56
+ SAFETY_CATEGORY_VIOLENT = "SAFETY_CATEGORY_VIOLENT",
57
+ SAFETY_CATEGORY_ILLEGAL = "SAFETY_CATEGORY_ILLEGAL",
58
+ SAFETY_CATEGORY_SEXUAL = "SAFETY_CATEGORY_SEXUAL",
59
+ SAFETY_CATEGORY_PII = "SAFETY_CATEGORY_PII",
60
+ SAFETY_CATEGORY_SELF_HARM = "SAFETY_CATEGORY_SELF_HARM",
61
+ SAFETY_CATEGORY_UNETHICAL = "SAFETY_CATEGORY_UNETHICAL",
62
+ SAFETY_CATEGORY_POLITICAL = "SAFETY_CATEGORY_POLITICAL",
63
+ SAFETY_CATEGORY_COPYRIGHT = "SAFETY_CATEGORY_COPYRIGHT",
64
+ SAFETY_CATEGORY_JAILBREAK = "SAFETY_CATEGORY_JAILBREAK",
65
+ }
66
+
32
67
  export enum GuardrailsPlugin {
33
68
  GUARDRAILS_PLUGIN_UNSPECIFIED = "GUARDRAILS_PLUGIN_UNSPECIFIED",
34
69
  GUARDRAILS_PLUGIN_CONTAINS = "GUARDRAILS_PLUGIN_CONTAINS",
@@ -36,6 +71,7 @@ export enum GuardrailsPlugin {
36
71
  GUARDRAILS_PLUGIN_JSON_SCHEMA = "GUARDRAILS_PLUGIN_JSON_SCHEMA",
37
72
  GUARDRAILS_PLUGIN_JWT = "GUARDRAILS_PLUGIN_JWT",
38
73
  GUARDRAILS_PLUGIN_MODEL_WHITELIST = "GUARDRAILS_PLUGIN_MODEL_WHITELIST",
74
+ GUARDRAILS_PLUGIN_EXTERNAL_DETECT = "GUARDRAILS_PLUGIN_EXTERNAL_DETECT",
39
75
  }
40
76
 
41
77
  export enum GuardrailsLevel {
@@ -62,6 +98,7 @@ export type AIGuardrailsConfig = {
62
98
  cluster?: string
63
99
  creationTime?: GoogleProtobufTimestamp.Timestamp
64
100
  updateTime?: GoogleProtobufTimestamp.Timestamp
101
+ externalDetect?: ExternalDetectPlugin
65
102
  }
66
103
 
67
104
  export type RegexMatchPlugin = {
@@ -70,6 +107,7 @@ export type RegexMatchPlugin = {
70
107
  matchStrategy?: MatchStrategy
71
108
  action?: PluginAction
72
109
  responses?: string[]
110
+ checkPhase?: CheckPhase
73
111
  }
74
112
 
75
113
  export type ContainsPlugin = {
@@ -78,6 +116,7 @@ export type ContainsPlugin = {
78
116
  matchStrategy?: MatchStrategy
79
117
  action?: PluginAction
80
118
  responses?: string[]
119
+ checkPhase?: CheckPhase
81
120
  }
82
121
 
83
122
  export type JsonSchemaPlugin = {
@@ -99,6 +138,44 @@ export type ModelWhitelistPlugin = {
99
138
  action?: PluginAction
100
139
  }
101
140
 
141
+ export type CategoryThreshold = {
142
+ category?: SafetyCategory
143
+ threshold?: number
144
+ }
145
+
146
+ export type CustomProviderConfig = {
147
+ model?: string
148
+ categories?: CategoryThreshold[]
149
+ }
150
+
151
+ export type NsfocusProviderConfig = {
152
+ accessKey?: string
153
+ secretKey?: string
154
+ appId?: string
155
+ vAppId?: string
156
+ vAppName?: string
157
+ policyId?: string
158
+ enableImage?: boolean
159
+ enableAudio?: boolean
160
+ enableVideo?: boolean
161
+ enableDoc?: boolean
162
+ }
163
+
164
+
165
+ type BaseExternalDetectPlugin = {
166
+ enabled?: boolean
167
+ endpoint?: string
168
+ header?: {[key: string]: string}
169
+ action?: PluginAction
170
+ timeoutMs?: number
171
+ provider?: ExternalDetectProvider
172
+ checkInput?: boolean
173
+ checkOutput?: boolean
174
+ }
175
+
176
+ export type ExternalDetectPlugin = BaseExternalDetectPlugin
177
+ & OneOf<{ custom: CustomProviderConfig; nsfocus: NsfocusProviderConfig }>
178
+
102
179
  export type GetAIGuardrailsConfigRequest = {
103
180
  cluster?: string
104
181
  }
@@ -127,6 +204,7 @@ export type QueryAIAuditLogRequest = {
127
204
  pluginId?: GuardrailsPlugin
128
205
  level?: GuardrailsLevel
129
206
  routeName?: string
207
+ detectionPhase?: string
130
208
  }
131
209
 
132
210
  export type AIAuditLog = {
@@ -143,6 +221,7 @@ export type AIAuditLog = {
143
221
  functionName?: string
144
222
  functionArgs?: string
145
223
  matchRule?: string
224
+ detectionPhase?: string
146
225
  }
147
226
 
148
227
  export type QueryAIAuditLogResponse = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daocloud-proto/hydra",
3
- "version": "v0.17.0-rc1-dev-7",
3
+ "version": "v0.17.0-rc1-dev-9",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "ISC"