@sap-ai-sdk/orchestration 1.17.1-20250825032219.0 → 1.17.1-20250920013049.0
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/dist/client/api/schema/azure-content-safety-input.d.ts +5 -5
- package/dist/client/api/schema/azure-content-safety-input.d.ts.map +1 -1
- package/dist/client/api/schema/azure-content-safety-output.d.ts +4 -4
- package/dist/client/api/schema/azure-content-safety-output.d.ts.map +1 -1
- package/dist/client/api/schema/completion-post-request.d.ts +2 -2
- package/dist/client/api/schema/completion-post-request.d.ts.map +1 -1
- package/dist/client/api/schema/completion-post-response-streaming.d.ts +2 -2
- package/dist/client/api/schema/completion-post-response-streaming.d.ts.map +1 -1
- package/dist/client/api/schema/completion-post-response.d.ts +2 -2
- package/dist/client/api/schema/completion-post-response.d.ts.map +1 -1
- package/dist/client/api/schema/error-response-streaming.d.ts +2 -19
- package/dist/client/api/schema/error-response-streaming.d.ts.map +1 -1
- package/dist/client/api/schema/error-response.d.ts +2 -19
- package/dist/client/api/schema/error-response.d.ts.map +1 -1
- package/dist/client/api/schema/error-streaming.d.ts +25 -0
- package/dist/client/api/schema/error-streaming.d.ts.map +1 -0
- package/dist/client/api/schema/error-streaming.js +2 -0
- package/dist/client/api/schema/error-streaming.js.map +1 -0
- package/dist/client/api/schema/error.d.ts +25 -0
- package/dist/client/api/schema/error.d.ts.map +1 -0
- package/dist/client/api/schema/error.js +2 -0
- package/dist/client/api/schema/error.js.map +1 -0
- package/dist/client/api/schema/global-stream-options.d.ts +5 -1
- package/dist/client/api/schema/global-stream-options.d.ts.map +1 -1
- package/dist/client/api/schema/grounding-module-config.d.ts +13 -8
- package/dist/client/api/schema/grounding-module-config.d.ts.map +1 -1
- package/dist/client/api/schema/index.d.ts +5 -4
- package/dist/client/api/schema/index.d.ts.map +1 -1
- package/dist/client/api/schema/index.js +5 -4
- package/dist/client/api/schema/index.js.map +1 -1
- package/dist/client/api/schema/llm-model-details.d.ts +30 -0
- package/dist/client/api/schema/llm-model-details.d.ts.map +1 -0
- package/dist/client/api/schema/{llm-module-config.js → llm-model-details.js} +1 -1
- package/dist/client/api/schema/llm-model-details.js.map +1 -0
- package/dist/client/api/schema/llm-module-result.d.ts +1 -1
- package/dist/client/api/schema/module-configs.d.ts +7 -11
- package/dist/client/api/schema/module-configs.d.ts.map +1 -1
- package/dist/client/api/schema/orchestration-config.d.ts +2 -6
- package/dist/client/api/schema/orchestration-config.d.ts.map +1 -1
- package/dist/client/api/schema/prompt-templating-module-config.d.ts +15 -0
- package/dist/client/api/schema/prompt-templating-module-config.d.ts.map +1 -0
- package/dist/client/api/schema/prompt-templating-module-config.js +2 -0
- package/dist/client/api/schema/prompt-templating-module-config.js.map +1 -0
- package/dist/client/api/schema/template.d.ts +1 -1
- package/dist/client/api/schema/translation-module-config.d.ts +15 -0
- package/dist/client/api/schema/translation-module-config.d.ts.map +1 -0
- package/dist/client/api/schema/translation-module-config.js +2 -0
- package/dist/client/api/schema/translation-module-config.js.map +1 -0
- package/dist/deployment-resolver.d.ts +11 -0
- package/dist/deployment-resolver.d.ts.map +1 -0
- package/dist/deployment-resolver.js +20 -0
- package/dist/deployment-resolver.js.map +1 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +2 -3
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -3
- package/dist/internal.js.map +1 -1
- package/dist/orchestration-client.d.ts +5 -5
- package/dist/orchestration-client.d.ts.map +1 -1
- package/dist/orchestration-client.js +31 -22
- package/dist/orchestration-client.js.map +1 -1
- package/dist/orchestration-response.d.ts +7 -2
- package/dist/orchestration-response.d.ts.map +1 -1
- package/dist/orchestration-response.js +12 -5
- package/dist/orchestration-response.js.map +1 -1
- package/dist/orchestration-stream-chunk-response.d.ts +8 -3
- package/dist/orchestration-stream-chunk-response.d.ts.map +1 -1
- package/dist/orchestration-stream-chunk-response.js +13 -6
- package/dist/orchestration-stream-chunk-response.js.map +1 -1
- package/dist/orchestration-stream-response.d.ts +12 -3
- package/dist/orchestration-stream-response.d.ts.map +1 -1
- package/dist/orchestration-stream-response.js +20 -8
- package/dist/orchestration-stream-response.js.map +1 -1
- package/dist/orchestration-stream.js +1 -1
- package/dist/orchestration-stream.js.map +1 -1
- package/dist/orchestration-types.d.ts +216 -82
- package/dist/orchestration-types.d.ts.map +1 -1
- package/dist/orchestration-types.js.map +1 -1
- package/dist/util/filtering.d.ts +10 -16
- package/dist/util/filtering.d.ts.map +1 -1
- package/dist/util/filtering.js +33 -34
- package/dist/util/filtering.js.map +1 -1
- package/dist/util/grounding.d.ts +2 -3
- package/dist/util/grounding.d.ts.map +1 -1
- package/dist/util/grounding.js +4 -2
- package/dist/util/grounding.js.map +1 -1
- package/dist/util/masking.d.ts +2 -3
- package/dist/util/masking.d.ts.map +1 -1
- package/dist/util/masking.js.map +1 -1
- package/dist/util/module-config.d.ts +5 -5
- package/dist/util/module-config.d.ts.map +1 -1
- package/dist/util/module-config.js +69 -80
- package/dist/util/module-config.js.map +1 -1
- package/dist/util/stream.d.ts +3 -1
- package/dist/util/stream.d.ts.map +1 -1
- package/dist/util/stream.js +2 -2
- package/dist/util/stream.js.map +1 -1
- package/dist/util/translation.d.ts +5 -5
- package/dist/util/translation.d.ts.map +1 -1
- package/dist/util/translation.js +4 -3
- package/dist/util/translation.js.map +1 -1
- package/package.json +7 -7
- package/dist/client/api/schema/input-translation-module-config.d.ts +0 -6
- package/dist/client/api/schema/input-translation-module-config.d.ts.map +0 -1
- package/dist/client/api/schema/input-translation-module-config.js +0 -2
- package/dist/client/api/schema/input-translation-module-config.js.map +0 -1
- package/dist/client/api/schema/llm-module-config.d.ts +0 -31
- package/dist/client/api/schema/llm-module-config.d.ts.map +0 -1
- package/dist/client/api/schema/llm-module-config.js.map +0 -1
- package/dist/client/api/schema/output-translation-module-config.d.ts +0 -6
- package/dist/client/api/schema/output-translation-module-config.d.ts.map +0 -1
- package/dist/client/api/schema/output-translation-module-config.js +0 -2
- package/dist/client/api/schema/output-translation-module-config.js.map +0 -1
- package/dist/client/api/schema/templating-module-config.d.ts +0 -7
- package/dist/client/api/schema/templating-module-config.d.ts.map +0 -1
- package/dist/client/api/schema/templating-module-config.js +0 -2
- package/dist/client/api/schema/templating-module-config.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Xor } from '@sap-cloud-sdk/util';
|
|
2
2
|
import type { CustomRequestConfig } from '@sap-cloud-sdk/http-client';
|
|
3
3
|
import type { ChatModel } from './model-types.js';
|
|
4
|
-
import type { ChatMessages, DataRepositoryType, DocumentGroundingFilter, DpiConfig, DpiEntities,
|
|
4
|
+
import type { ChatMessages, DataRepositoryType, DocumentGroundingFilter, DpiConfig, DpiEntities, FilteringStreamOptions, LlamaGuard38B, LLMModelDetails as OriginalLLMModelDetails, Template, TemplateRef, TemplatingChatMessage, DPIStandardEntity, DPICustomEntity, InputFilteringConfig, OutputFilteringConfig, MaskingProviderConfig, SAPDocumentTranslation, GlobalStreamOptions, ErrorResponse, AzureContentSafetyInputFilterConfig, AzureContentSafetyOutputFilterConfig, LlamaGuard38BFilterConfig } from './client/api/schema/index.js';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Chat completion request configuration.
|
|
7
7
|
*/
|
|
8
|
-
export interface
|
|
8
|
+
export interface ChatCompletionRequest {
|
|
9
9
|
/**
|
|
10
10
|
* Chat History.
|
|
11
11
|
*/
|
|
@@ -28,20 +28,89 @@ export interface Prompt {
|
|
|
28
28
|
/**
|
|
29
29
|
* Template parameters.
|
|
30
30
|
* @example
|
|
31
|
-
*
|
|
31
|
+
* placeholderValues: {
|
|
32
32
|
* product: 'SAP Cloud SDK'
|
|
33
33
|
* }
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
placeholderValues?: Record<string, string>;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* LLM
|
|
38
|
+
* LLM model details.
|
|
39
39
|
*/
|
|
40
|
-
export type
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
model_params?: LlmModelParams;
|
|
40
|
+
export type LlmModelDetails = Omit<OriginalLLMModelDetails, 'name' | 'params'> & {
|
|
41
|
+
name: ChatModel;
|
|
42
|
+
params?: LlmModelParams;
|
|
44
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Prompt templating module configuration.
|
|
46
|
+
*/
|
|
47
|
+
export interface PromptTemplatingModule {
|
|
48
|
+
/**
|
|
49
|
+
* The prompt template to be used. Can be either a user defined template or a reference to a template in the prompt registry.
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Static prompts. Can be:
|
|
53
|
+
* - A `template`: an array of templated chat messages (with {{?placeholders}}).
|
|
54
|
+
* - An `id` or `scenario`, `name` and `version`: reference to a remote prompt template.
|
|
55
|
+
*
|
|
56
|
+
* This is meant for static instructions included with every call.
|
|
57
|
+
* For per-request templating, use `messages` in `.chatCompletion()` instead.
|
|
58
|
+
* @example
|
|
59
|
+
* prompt: {
|
|
60
|
+
* template: [
|
|
61
|
+
* {
|
|
62
|
+
* role: 'system',
|
|
63
|
+
* content: 'You are an assistant for {{?product}}.'
|
|
64
|
+
* }
|
|
65
|
+
* ]
|
|
66
|
+
* }
|
|
67
|
+
*/
|
|
68
|
+
prompt?: Xor<PromptTemplate, TemplateRef> | string;
|
|
69
|
+
/**
|
|
70
|
+
* LLM model details.
|
|
71
|
+
*/
|
|
72
|
+
model: LlmModelDetails;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Representation of the `FilteringModuleConfig` schema.
|
|
76
|
+
*/
|
|
77
|
+
export interface FilteringModule {
|
|
78
|
+
/**
|
|
79
|
+
* List of provider type and filters.
|
|
80
|
+
*/
|
|
81
|
+
input?: InputFilteringConfig;
|
|
82
|
+
/**
|
|
83
|
+
* List of provider type and filters.
|
|
84
|
+
*/
|
|
85
|
+
output?: OutputFilteringConfig;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Representation of the `MaskingModuleConfig` schema.
|
|
89
|
+
*/
|
|
90
|
+
export interface MaskingModule {
|
|
91
|
+
/**
|
|
92
|
+
* List of masking service providers
|
|
93
|
+
* Min Items: 1.
|
|
94
|
+
*/
|
|
95
|
+
masking_providers: MaskingProviderConfig[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Configuration for translation module.
|
|
99
|
+
*/
|
|
100
|
+
export interface TranslationModule {
|
|
101
|
+
/**
|
|
102
|
+
* Configuration for input translation.
|
|
103
|
+
*/
|
|
104
|
+
input?: TranslationInputConfig;
|
|
105
|
+
/**
|
|
106
|
+
* Configuration for output translation.
|
|
107
|
+
*/
|
|
108
|
+
output?: TranslationOutputConfig;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Orchestration error response.
|
|
112
|
+
*/
|
|
113
|
+
export type OrchestrationErrorResponse = ErrorResponse;
|
|
45
114
|
/**
|
|
46
115
|
* Model Parameters for LLM module configuration.
|
|
47
116
|
*/
|
|
@@ -56,9 +125,9 @@ export type LlmModelParams = {
|
|
|
56
125
|
/**
|
|
57
126
|
* Representation of the 'Template' schema.
|
|
58
127
|
*/
|
|
59
|
-
export type
|
|
128
|
+
export type PromptTemplate = Omit<Template, 'template'> & {
|
|
60
129
|
/**
|
|
61
|
-
* A chat message array to be formatted with values from `
|
|
130
|
+
* A chat message array to be formatted with values from `placeholderValues`.
|
|
62
131
|
* Both `role` and `content` can use {{?variable}} placeholders.
|
|
63
132
|
*
|
|
64
133
|
* For dynamic templating (changing per request), pass templated messages directly in `.chatCompletion({ messages })`.
|
|
@@ -75,70 +144,39 @@ export type Template = Omit<OriginalTemplate, 'template'> & {
|
|
|
75
144
|
*/
|
|
76
145
|
template?: TemplatingChatMessage;
|
|
77
146
|
};
|
|
78
|
-
/**
|
|
79
|
-
* Representation of the 'TemplatingModuleConfig' schema.
|
|
80
|
-
* The type can be either a `Template` or a `TemplateRef`.
|
|
81
|
-
*/
|
|
82
|
-
export type TemplatingModuleConfig = Xor<Template, TemplateRef>;
|
|
83
147
|
/**
|
|
84
148
|
* Orchestration module configuration.
|
|
85
149
|
*/
|
|
86
150
|
export interface OrchestrationModuleConfig {
|
|
87
151
|
/**
|
|
88
|
-
*
|
|
89
|
-
* - A `template`: an array of templated chat messages (with {{?placeholders}}).
|
|
90
|
-
* - An `id` or `scenario`, `name` and `version`: reference to a remote prompt template.
|
|
91
|
-
*
|
|
92
|
-
* This is meant for static instructions included with every call.
|
|
93
|
-
* For per-request templating, use `messages` in `.chatCompletion()` instead.
|
|
94
|
-
* @example
|
|
95
|
-
* templating: {
|
|
96
|
-
* template: [
|
|
97
|
-
* {
|
|
98
|
-
* role: 'system',
|
|
99
|
-
* content: 'You are an assistant for {{?product}}.'
|
|
100
|
-
* }
|
|
101
|
-
* ]
|
|
102
|
-
* }
|
|
103
|
-
*/
|
|
104
|
-
templating?: TemplatingModuleConfig | string;
|
|
105
|
-
/**
|
|
106
|
-
* LLM module configuration.
|
|
152
|
+
* Prompt templating configuration.
|
|
107
153
|
*/
|
|
108
|
-
|
|
154
|
+
promptTemplating: PromptTemplatingModule;
|
|
109
155
|
/**
|
|
110
156
|
* Filtering module configuration for both input and output filters.
|
|
111
|
-
* To configure a filter, use convenience functions like `buildAzureContentSafetyFilter`, `
|
|
157
|
+
* To configure a filter, use convenience functions like `buildAzureContentSafetyFilter`, `buildLlamaGuard38BFilter`, etc..
|
|
112
158
|
* @example
|
|
113
159
|
* filtering: {
|
|
114
160
|
* input: {
|
|
115
161
|
* filters: [
|
|
116
|
-
* buildAzureContentSafetyFilter({
|
|
162
|
+
* buildAzureContentSafetyFilter('input', { hate: 'ALLOW_SAFE', violence: 'ALLOW_SAFE_LOW_MEDIUM' })
|
|
117
163
|
* ]
|
|
118
164
|
* }
|
|
119
165
|
* }
|
|
120
166
|
*/
|
|
121
|
-
filtering?:
|
|
167
|
+
filtering?: FilteringModule;
|
|
122
168
|
/**
|
|
123
169
|
* Masking module configuration.
|
|
124
170
|
*/
|
|
125
|
-
masking?:
|
|
171
|
+
masking?: MaskingModule;
|
|
126
172
|
/**
|
|
127
173
|
* Grounding module configuraton.
|
|
128
174
|
*/
|
|
129
|
-
grounding?:
|
|
130
|
-
/**
|
|
131
|
-
* Global streaming options.
|
|
132
|
-
*/
|
|
133
|
-
streaming?: GlobalStreamOptions;
|
|
134
|
-
/**
|
|
135
|
-
* Input translation module configuration.
|
|
136
|
-
*/
|
|
137
|
-
inputTranslation?: InputTranslationModuleConfig;
|
|
175
|
+
grounding?: GroundingModule;
|
|
138
176
|
/**
|
|
139
|
-
*
|
|
177
|
+
* Translation module configuration.
|
|
140
178
|
*/
|
|
141
|
-
|
|
179
|
+
translation?: TranslationModule;
|
|
142
180
|
}
|
|
143
181
|
/**
|
|
144
182
|
* Request options for orchestration.
|
|
@@ -147,7 +185,7 @@ export interface RequestOptions {
|
|
|
147
185
|
/**
|
|
148
186
|
* Prompt configuration.
|
|
149
187
|
*/
|
|
150
|
-
|
|
188
|
+
request?: ChatCompletionRequest;
|
|
151
189
|
/**
|
|
152
190
|
* Custom request configuration.
|
|
153
191
|
*/
|
|
@@ -168,7 +206,7 @@ export interface StreamOptions {
|
|
|
168
206
|
/**
|
|
169
207
|
* LLM specific stream options.
|
|
170
208
|
*/
|
|
171
|
-
|
|
209
|
+
promptTemplating?: {
|
|
172
210
|
include_usage?: boolean;
|
|
173
211
|
[key: string]: any;
|
|
174
212
|
} | null;
|
|
@@ -181,6 +219,43 @@ export interface StreamOptions {
|
|
|
181
219
|
*/
|
|
182
220
|
global?: GlobalStreamOptions;
|
|
183
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Representation of the `GroundingModuleConfig` schema.
|
|
224
|
+
*/
|
|
225
|
+
export interface GroundingModule {
|
|
226
|
+
/**
|
|
227
|
+
* @example 'document_grounding_service'
|
|
228
|
+
*/
|
|
229
|
+
type: 'document_grounding_service' | any;
|
|
230
|
+
/**
|
|
231
|
+
* Grounding service configuration.
|
|
232
|
+
*/
|
|
233
|
+
config: {
|
|
234
|
+
/**
|
|
235
|
+
* Document grounding service filters to be used.
|
|
236
|
+
*/
|
|
237
|
+
filters?: DocumentGroundingFilter[];
|
|
238
|
+
/**
|
|
239
|
+
* Placeholders to be used for grounding input questions and output.
|
|
240
|
+
*/
|
|
241
|
+
placeholders: {
|
|
242
|
+
/**
|
|
243
|
+
* Contains the input parameters used for grounding input questions
|
|
244
|
+
* Min Items: 1.
|
|
245
|
+
*/
|
|
246
|
+
input: string[];
|
|
247
|
+
/**
|
|
248
|
+
* Placeholder name for grounding output.
|
|
249
|
+
* @example 'groundingOutput'
|
|
250
|
+
*/
|
|
251
|
+
output: string;
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Parameter name used for specifying metadata parameters.
|
|
255
|
+
*/
|
|
256
|
+
metadata_params?: string[];
|
|
257
|
+
};
|
|
258
|
+
}
|
|
184
259
|
/**
|
|
185
260
|
* Represents a filter configuration for the Document Grounding Service.
|
|
186
261
|
*/
|
|
@@ -196,18 +271,24 @@ export type DocumentGroundingServiceFilter = Omit<DocumentGroundingFilter, 'data
|
|
|
196
271
|
*/
|
|
197
272
|
export interface DocumentGroundingServiceConfig {
|
|
198
273
|
/**
|
|
199
|
-
*
|
|
274
|
+
* Document grounding service filters to be used.
|
|
200
275
|
*/
|
|
201
276
|
filters?: DocumentGroundingServiceFilter[];
|
|
202
277
|
/**
|
|
203
|
-
*
|
|
278
|
+
* Placeholders to be used for grounding input questions and output.
|
|
204
279
|
*/
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
280
|
+
placeholders: {
|
|
281
|
+
/**
|
|
282
|
+
* Contains the input parameters used for grounding input questions
|
|
283
|
+
* Min Items: 1.
|
|
284
|
+
*/
|
|
285
|
+
input: string[];
|
|
286
|
+
/**
|
|
287
|
+
* Placeholder name for grounding output.
|
|
288
|
+
* @example "groundingOutput"
|
|
289
|
+
*/
|
|
290
|
+
output: string;
|
|
291
|
+
};
|
|
211
292
|
/**
|
|
212
293
|
* Parameter name used for specifying metadata parameters.
|
|
213
294
|
*/
|
|
@@ -215,9 +296,8 @@ export interface DocumentGroundingServiceConfig {
|
|
|
215
296
|
}
|
|
216
297
|
/**
|
|
217
298
|
* Defines the type of the DPI masking entity.
|
|
218
|
-
* @internal
|
|
219
299
|
*/
|
|
220
|
-
|
|
300
|
+
type DpiEntity = DpiEntities | DPIStandardEntity | (DPICustomEntity & {
|
|
221
301
|
type: 'custom';
|
|
222
302
|
});
|
|
223
303
|
/**
|
|
@@ -228,26 +308,35 @@ export type DpiMaskingConfig = Omit<DpiConfig, 'type' | 'entities' | 'mask_groun
|
|
|
228
308
|
mask_grounding_input?: boolean;
|
|
229
309
|
};
|
|
230
310
|
/**
|
|
231
|
-
*
|
|
311
|
+
* Output Parameters for Azure content safety output filter.
|
|
232
312
|
*/
|
|
233
|
-
export interface
|
|
313
|
+
export interface AzureContentSafetyFilterOutputParameters {
|
|
234
314
|
/**
|
|
235
315
|
* The filter category for hate content.
|
|
236
316
|
*/
|
|
237
|
-
|
|
317
|
+
hate?: AzureFilterThreshold;
|
|
238
318
|
/**
|
|
239
319
|
* The filter category for self-harm content.
|
|
240
320
|
*/
|
|
241
|
-
|
|
321
|
+
self_harm?: AzureFilterThreshold;
|
|
242
322
|
/**
|
|
243
323
|
* The filter category for sexual content.
|
|
244
324
|
*/
|
|
245
|
-
|
|
325
|
+
sexual?: AzureFilterThreshold;
|
|
246
326
|
/**
|
|
247
327
|
* The filter category for violence content.
|
|
248
328
|
*/
|
|
249
|
-
|
|
329
|
+
violence?: AzureFilterThreshold;
|
|
250
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Input parameters for Azure content safety input filter.
|
|
333
|
+
*/
|
|
334
|
+
export type AzureContentSafetyFilterInputParameters = AzureContentSafetyFilterOutputParameters & {
|
|
335
|
+
/**
|
|
336
|
+
* A flag to use prompt shield.
|
|
337
|
+
*/
|
|
338
|
+
prompt_shield?: boolean;
|
|
339
|
+
};
|
|
251
340
|
/**
|
|
252
341
|
* A descriptive constant for Azure content safety filter threshold.
|
|
253
342
|
* @internal
|
|
@@ -260,35 +349,80 @@ export declare const supportedAzureFilterThresholds: {
|
|
|
260
349
|
};
|
|
261
350
|
/**
|
|
262
351
|
* The Azure threshold level supported for each azure content filter category.
|
|
263
|
-
*
|
|
264
352
|
*/
|
|
265
353
|
export type AzureFilterThreshold = keyof typeof supportedAzureFilterThresholds;
|
|
266
354
|
/**
|
|
267
|
-
* The filter categories supported for Llama
|
|
355
|
+
* The filter categories supported for Llama Guard 3 8B filter.
|
|
268
356
|
*/
|
|
269
|
-
export type
|
|
357
|
+
export type LlamaGuard38BCategory = keyof LlamaGuard38B;
|
|
270
358
|
/**
|
|
271
|
-
*
|
|
272
|
-
*
|
|
359
|
+
* Type for module configurations (input or output).
|
|
360
|
+
* @internal
|
|
273
361
|
*/
|
|
274
|
-
export
|
|
362
|
+
export type ConfigType = 'input' | 'output';
|
|
363
|
+
/**
|
|
364
|
+
* Parameters for translation configuration.
|
|
365
|
+
* @internal
|
|
366
|
+
*/
|
|
367
|
+
interface TranslationConfigParameters {
|
|
275
368
|
/**
|
|
276
369
|
* Language of the text to be translated.
|
|
277
|
-
* @example sourceLanguage:
|
|
370
|
+
* @example sourceLanguage: 'de-DE'
|
|
278
371
|
*/
|
|
279
372
|
sourceLanguage?: string;
|
|
280
373
|
/**
|
|
281
374
|
* Language to which the text should be translated.
|
|
282
|
-
* @example targetLanguage:
|
|
375
|
+
* @example targetLanguage: 'en-US'
|
|
283
376
|
*/
|
|
284
377
|
targetLanguage: string;
|
|
285
378
|
}
|
|
286
379
|
/**
|
|
287
|
-
*
|
|
380
|
+
* Output parameters for translation output configuration.
|
|
381
|
+
*/
|
|
382
|
+
export type TranslationOutputParameters = TranslationConfigParameters;
|
|
383
|
+
/**
|
|
384
|
+
* Input parameters for translation input configuration.
|
|
385
|
+
*/
|
|
386
|
+
export type TranslationInputParameters = TranslationConfigParameters;
|
|
387
|
+
/**
|
|
388
|
+
* Parameters for translation configurations.
|
|
389
|
+
*/
|
|
390
|
+
export type TranslationConfigParams<T extends ConfigType> = T extends 'input' ? TranslationInputParameters : TranslationOutputParameters;
|
|
391
|
+
/**
|
|
392
|
+
* Input configuration for translation module.
|
|
393
|
+
*/
|
|
394
|
+
export type TranslationInputConfig = SAPDocumentTranslation;
|
|
395
|
+
/**
|
|
396
|
+
* Output configuration for translation module.
|
|
397
|
+
*/
|
|
398
|
+
export type TranslationOutputConfig = SAPDocumentTranslation;
|
|
399
|
+
/**
|
|
400
|
+
* Return type for translation configurations.
|
|
401
|
+
*/
|
|
402
|
+
export type TranslationReturnType<T extends ConfigType> = T extends 'input' ? TranslationInputConfig : TranslationOutputConfig;
|
|
403
|
+
/**
|
|
404
|
+
* Parameters for Azure content safety filters.
|
|
405
|
+
*/
|
|
406
|
+
export type AzureContentSafetyFilterParameters<T extends ConfigType> = T extends 'input' ? AzureContentSafetyFilterInputParameters : AzureContentSafetyFilterOutputParameters;
|
|
407
|
+
/**
|
|
408
|
+
* Filter return type for Azure Content Safety.
|
|
409
|
+
*/
|
|
410
|
+
export type AzureContentSafetyFilterReturnType<T extends ConfigType> = T extends 'input' ? AzureContentSafetyInputFilterConfig : AzureContentSafetyOutputFilterConfig;
|
|
411
|
+
/**
|
|
412
|
+
* Input filter configuration for Llama Guard 3 8B.
|
|
413
|
+
*/
|
|
414
|
+
export type LlamaGuard38BInputFilterConfig = LlamaGuard38BFilterConfig;
|
|
415
|
+
/**
|
|
416
|
+
* Output filter configuration for Llama Guard 3 8B.
|
|
417
|
+
*/
|
|
418
|
+
export type LlamaGuard38BOutputFilterConfig = LlamaGuard38BFilterConfig;
|
|
419
|
+
/**
|
|
420
|
+
* Filter return type for Llama Guard 3 8B.
|
|
288
421
|
*/
|
|
289
|
-
export type
|
|
422
|
+
export type LlamaGuard38BFilterReturnType<T extends ConfigType> = T extends 'input' ? LlamaGuard38BInputFilterConfig : LlamaGuard38BOutputFilterConfig;
|
|
290
423
|
/**
|
|
291
|
-
* Representation of the
|
|
424
|
+
* Representation of the 'DpiConfig' schema.
|
|
292
425
|
*/
|
|
293
|
-
export type
|
|
426
|
+
export type DpiMaskingProviderConfig = DpiConfig;
|
|
427
|
+
export {};
|
|
294
428
|
//# sourceMappingURL=orchestration-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestration-types.d.ts","sourceRoot":"","sources":["../src/orchestration-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,SAAS,EACT,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"orchestration-types.d.ts","sourceRoot":"","sources":["../src/orchestration-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,SAAS,EACT,WAAW,EACX,sBAAsB,EACtB,aAAa,EACb,eAAe,IAAI,uBAAuB,EAC1C,QAAQ,EACR,WAAW,EACX,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,aAAa,EACb,mCAAmC,EACnC,oCAAoC,EACpC,yBAAyB,EAC1B,MAA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O,GACb,uCAAuC,GACvC,wCAAwC,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,kCAAkC,CAAC,CAAC,SAAS,UAAU,IACjE,CAAC,SAAS,OAAO,GACb,mCAAmC,GACnC,oCAAoC,CAAC;AAE3C;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,yBAAyB,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG,yBAAyB,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,6BAA6B,CAAC,CAAC,SAAS,UAAU,IAC5D,CAAC,SAAS,OAAO,GACb,8BAA8B,GAC9B,+BAA+B,CAAC;AAEtC;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestration-types.js","sourceRoot":"","sources":["../src/orchestration-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"orchestration-types.js","sourceRoot":"","sources":["../src/orchestration-types.ts"],"names":[],"mappings":"AAwYA;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,UAAU,EAAE,CAAC;IACb,cAAc,EAAE,CAAC;IACjB,qBAAqB,EAAE,CAAC;IACxB,SAAS,EAAE,CAAC;CACJ,CAAC"}
|
package/dist/util/filtering.d.ts
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AzureContentFilter, AzureContentSafety, AzureContentSafetyFilterConfig, LlamaGuardCategory } from '../orchestration-types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Convenience function to build Azure content filter.
|
|
5
|
-
* @param filter - Filtering configuration for Azure filter. If skipped, the default Azure content filter configuration is used.
|
|
6
|
-
* @returns An object with the Azure filtering configuration.
|
|
7
|
-
* @deprecated Since 1.8.0. Use {@link buildAzureContentSafetyFilter()} instead.
|
|
8
|
-
*/
|
|
9
|
-
export declare function buildAzureContentFilter(filter?: AzureContentSafety): InputFilteringConfig | OutputFilteringConfig;
|
|
1
|
+
import type { AzureContentSafetyFilterParameters, AzureContentSafetyFilterReturnType, LlamaGuard38BCategory, LlamaGuard38BFilterReturnType, ConfigType } from '../orchestration-types.js';
|
|
10
2
|
/**
|
|
11
3
|
* Convenience function to build Azure content filter.
|
|
4
|
+
* @param type - Type of the filter, either 'input' or 'output'.
|
|
12
5
|
* @param config - Configuration for Azure content safety filter.
|
|
13
6
|
* If skipped, the default configuration of `ALLOW_SAFE_LOW` is used for all filter categories.
|
|
14
|
-
* @returns
|
|
15
|
-
* @example "buildAzureContentSafetyFilter({
|
|
7
|
+
* @returns Azure content safety configuration.
|
|
8
|
+
* @example "buildAzureContentSafetyFilter({ type: 'input', hate: 'ALLOW_SAFE', violence: 'ALLOW_SAFE_LOW_MEDIUM' })"
|
|
16
9
|
*/
|
|
17
|
-
export declare function buildAzureContentSafetyFilter(config?:
|
|
10
|
+
export declare function buildAzureContentSafetyFilter<T extends ConfigType>(type: T, config?: AzureContentSafetyFilterParameters<T>): AzureContentSafetyFilterReturnType<T>;
|
|
18
11
|
/**
|
|
19
|
-
* Convenience function to build Llama
|
|
12
|
+
* Convenience function to build Llama Guard 3 8B filter.
|
|
13
|
+
* @param type - Type of the filter, either `input` or `output`.
|
|
20
14
|
* @param categories - Categories to be enabled for filtering. Provide at least one category.
|
|
21
|
-
* @returns
|
|
22
|
-
* @example
|
|
15
|
+
* @returns Llama Guard 3 8B filter configuration.
|
|
16
|
+
* @example buildLlamaGuard38BFilter('input', ['elections', 'hate'])
|
|
23
17
|
*/
|
|
24
|
-
export declare function
|
|
18
|
+
export declare function buildLlamaGuard38BFilter<T extends ConfigType>(type: T, categories: [LlamaGuard38BCategory, ...LlamaGuard38BCategory[]]): LlamaGuard38BFilterReturnType<T>;
|
|
25
19
|
//# sourceMappingURL=filtering.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../src/util/filtering.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../src/util/filtering.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,kCAAkC,EAClC,kCAAkC,EAElC,qBAAqB,EACrB,6BAA6B,EAC7B,UAAU,EACX,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,SAAS,UAAU,EAChE,IAAI,EAAE,CAAC,EACP,MAAM,CAAC,EAAE,kCAAkC,CAAC,CAAC,CAAC,GAC7C,kCAAkC,CAAC,CAAC,CAAC,CAuCvC;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,UAAU,EAC3D,IAAI,EAAE,CAAC,EACP,UAAU,EAAE,CAAC,qBAAqB,EAAE,GAAG,qBAAqB,EAAE,CAAC,GAC9D,6BAA6B,CAAC,CAAC,CAAC,CAOlC"}
|
package/dist/util/filtering.js
CHANGED
|
@@ -1,53 +1,52 @@
|
|
|
1
1
|
import { supportedAzureFilterThresholds } from '../orchestration-types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Convenience function to build Azure content filter.
|
|
4
|
-
* @param
|
|
5
|
-
* @returns An object with the Azure filtering configuration.
|
|
6
|
-
* @deprecated Since 1.8.0. Use {@link buildAzureContentSafetyFilter()} instead.
|
|
7
|
-
*/
|
|
8
|
-
export function buildAzureContentFilter(filter) {
|
|
9
|
-
if (filter && !Object.keys(filter).length) {
|
|
10
|
-
throw new Error('Filter property cannot be an empty object');
|
|
11
|
-
}
|
|
12
|
-
return {
|
|
13
|
-
filters: [
|
|
14
|
-
{
|
|
15
|
-
type: 'azure_content_safety',
|
|
16
|
-
...(filter && { config: filter })
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Convenience function to build Azure content filter.
|
|
4
|
+
* @param type - Type of the filter, either 'input' or 'output'.
|
|
23
5
|
* @param config - Configuration for Azure content safety filter.
|
|
24
6
|
* If skipped, the default configuration of `ALLOW_SAFE_LOW` is used for all filter categories.
|
|
25
|
-
* @returns
|
|
26
|
-
* @example "buildAzureContentSafetyFilter({
|
|
7
|
+
* @returns Azure content safety configuration.
|
|
8
|
+
* @example "buildAzureContentSafetyFilter({ type: 'input', hate: 'ALLOW_SAFE', violence: 'ALLOW_SAFE_LOW_MEDIUM' })"
|
|
27
9
|
*/
|
|
28
|
-
export function buildAzureContentSafetyFilter(config) {
|
|
29
|
-
if (
|
|
30
|
-
|
|
10
|
+
export function buildAzureContentSafetyFilter(type, config) {
|
|
11
|
+
if (!config) {
|
|
12
|
+
return {
|
|
13
|
+
type: 'azure_content_safety'
|
|
14
|
+
};
|
|
31
15
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
if (!Object.keys(config).length) {
|
|
17
|
+
throw new Error('Filtering parameters cannot be empty');
|
|
18
|
+
}
|
|
19
|
+
if (type === 'input') {
|
|
20
|
+
const { prompt_shield, ...rest } = config;
|
|
21
|
+
return {
|
|
22
|
+
type: 'azure_content_safety',
|
|
35
23
|
config: {
|
|
36
|
-
...Object.fromEntries(Object.entries(
|
|
24
|
+
...Object.fromEntries(Object.entries(rest).map(([key, value]) => [
|
|
37
25
|
key,
|
|
38
26
|
supportedAzureFilterThresholds[value]
|
|
39
|
-
]))
|
|
27
|
+
])),
|
|
28
|
+
...(prompt_shield !== undefined && { prompt_shield })
|
|
40
29
|
}
|
|
41
|
-
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
type: 'azure_content_safety',
|
|
34
|
+
config: {
|
|
35
|
+
...Object.fromEntries(Object.entries(config).map(([key, value]) => [
|
|
36
|
+
key,
|
|
37
|
+
supportedAzureFilterThresholds[value]
|
|
38
|
+
]))
|
|
39
|
+
}
|
|
42
40
|
};
|
|
43
41
|
}
|
|
44
42
|
/**
|
|
45
|
-
* Convenience function to build Llama
|
|
43
|
+
* Convenience function to build Llama Guard 3 8B filter.
|
|
44
|
+
* @param type - Type of the filter, either `input` or `output`.
|
|
46
45
|
* @param categories - Categories to be enabled for filtering. Provide at least one category.
|
|
47
|
-
* @returns
|
|
48
|
-
* @example
|
|
46
|
+
* @returns Llama Guard 3 8B filter configuration.
|
|
47
|
+
* @example buildLlamaGuard38BFilter('input', ['elections', 'hate'])
|
|
49
48
|
*/
|
|
50
|
-
export function
|
|
49
|
+
export function buildLlamaGuard38BFilter(type, categories) {
|
|
51
50
|
return {
|
|
52
51
|
type: 'llama_guard_3_8b',
|
|
53
52
|
config: Object.fromEntries([...categories].map(category => [category, true]))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filtering.js","sourceRoot":"","sources":["../../src/util/filtering.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"filtering.js","sourceRoot":"","sources":["../../src/util/filtering.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAe3E;;;;;;;GAOG;AACH,MAAM,UAAU,6BAA6B,CAC3C,IAAO,EACP,MAA8C;IAE9C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,IAAI,EAAE,sBAAsB;SAC7B,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACrB,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,GAC9B,MAAiD,CAAC;QACpD,OAAO;YACL,IAAI,EAAE,sBAAsB;YAC5B,MAAM,EAAE;gBACN,GAAG,MAAM,CAAC,WAAW,CACnB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;oBACzC,GAAG;oBACH,8BAA8B,CAAC,KAA6B,CAAC;iBAC9D,CAAC,CACH;gBACD,GAAG,CAAC,aAAa,KAAK,SAAS,IAAI,EAAE,aAAa,EAAE,CAAC;aACtD;SACqC,CAAC;IAC3C,CAAC;IAED,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,MAAM,EAAE;YACN,GAAG,MAAM,CAAC,WAAW,CACnB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;gBAC3C,GAAG;gBACH,8BAA8B,CAAC,KAA6B,CAAC;aAC9D,CAAC,CACH;SACF;KACsC,CAAC;AAC5C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAAO,EACP,UAA+D;IAE/D,OAAO;QACL,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,MAAM,CAAC,WAAW,CACxB,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAClD;KACF,CAAC;AACJ,CAAC"}
|
package/dist/util/grounding.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { DocumentGroundingServiceConfig } from '../orchestration-types.js';
|
|
1
|
+
import type { DocumentGroundingServiceConfig, GroundingModule } from '../orchestration-types.js';
|
|
3
2
|
/**
|
|
4
3
|
* Convenience function to create Document Grounding configuration.
|
|
5
4
|
* @param groundingConfig - Configuration for the document grounding service.
|
|
6
5
|
* @returns An object with the full grounding configuration.
|
|
7
6
|
*/
|
|
8
|
-
export declare function buildDocumentGroundingConfig(groundingConfig: DocumentGroundingServiceConfig):
|
|
7
|
+
export declare function buildDocumentGroundingConfig(groundingConfig: DocumentGroundingServiceConfig): GroundingModule;
|
|
9
8
|
//# sourceMappingURL=grounding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grounding.d.ts","sourceRoot":"","sources":["../../src/util/grounding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"grounding.d.ts","sourceRoot":"","sources":["../../src/util/grounding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8BAA8B,EAC9B,eAAe,EAChB,MAAM,2BAA2B,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,eAAe,EAAE,8BAA8B,GAC9C,eAAe,CAmBjB"}
|
package/dist/util/grounding.js
CHANGED
|
@@ -7,8 +7,10 @@ export function buildDocumentGroundingConfig(groundingConfig) {
|
|
|
7
7
|
return {
|
|
8
8
|
type: 'document_grounding_service',
|
|
9
9
|
config: {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
placeholders: {
|
|
11
|
+
input: groundingConfig.placeholders.input,
|
|
12
|
+
output: groundingConfig.placeholders.output
|
|
13
|
+
},
|
|
12
14
|
...(groundingConfig.filters && {
|
|
13
15
|
filters: groundingConfig.filters?.map(filter => ({
|
|
14
16
|
data_repository_type: 'vector',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grounding.js","sourceRoot":"","sources":["../../src/util/grounding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"grounding.js","sourceRoot":"","sources":["../../src/util/grounding.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAC1C,eAA+C;IAE/C,OAAO;QACL,IAAI,EAAE,4BAA4B;QAClC,MAAM,EAAE;YACN,YAAY,EAAE;gBACZ,KAAK,EAAE,eAAe,CAAC,YAAY,CAAC,KAAK;gBACzC,MAAM,EAAE,eAAe,CAAC,YAAY,CAAC,MAAM;aAC5C;YACD,GAAG,CAAC,eAAe,CAAC,OAAO,IAAI;gBAC7B,OAAO,EAAE,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;oBAC/C,oBAAoB,EAAE,QAAQ;oBAC9B,GAAG,MAAM;iBACV,CAAC,CAAC;aACJ,CAAC;YACF,GAAG,CAAC,eAAe,CAAC,eAAe,IAAI;gBACrC,eAAe,EAAE,eAAe,CAAC,eAAe;aACjD,CAAC;SACH;KACF,CAAC;AACJ,CAAC"}
|