@arizeai/phoenix-client 6.11.2 → 6.12.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/README.md +26 -0
- package/dist/esm/spans/index.d.ts +1 -0
- package/dist/esm/spans/index.d.ts.map +1 -1
- package/dist/esm/spans/index.js +1 -0
- package/dist/esm/spans/index.js.map +1 -1
- package/dist/esm/spans/logSpans.d.ts +94 -0
- package/dist/esm/spans/logSpans.d.ts.map +1 -0
- package/dist/esm/spans/logSpans.js +216 -0
- package/dist/esm/spans/logSpans.js.map +1 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/src/spans/index.d.ts +1 -0
- package/dist/src/spans/index.d.ts.map +1 -1
- package/dist/src/spans/index.js +1 -0
- package/dist/src/spans/index.js.map +1 -1
- package/dist/src/spans/logSpans.d.ts +94 -0
- package/dist/src/spans/logSpans.d.ts.map +1 -0
- package/dist/src/spans/logSpans.js +214 -0
- package/dist/src/spans/logSpans.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/spans/index.ts +1 -0
- package/src/spans/logSpans.ts +328 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spans/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrE,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spans/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrE,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
package/dist/src/spans/index.js
CHANGED
|
@@ -22,4 +22,5 @@ __exportStar(require("./logDocumentAnnotations"), exports);
|
|
|
22
22
|
__exportStar(require("./getSpans"), exports);
|
|
23
23
|
__exportStar(require("./getSpanAnnotations"), exports);
|
|
24
24
|
__exportStar(require("./deleteSpan"), exports);
|
|
25
|
+
__exportStar(require("./logSpans"), exports);
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/spans/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,gDAA8B;AAC9B,uDAAqC;AACrC,0DAAwC;AACxC,2DAAyC;AACzC,6CAA2B;AAE3B,uDAAqC;AACrC,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/spans/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,gDAA8B;AAC9B,uDAAqC;AACrC,0DAAwC;AACxC,2DAAyC;AACzC,6CAA2B;AAE3B,uDAAqC;AACrC,+CAA6B;AAC7B,6CAA2B"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { paths } from "../__generated__/api/v1";
|
|
2
|
+
import type { ClientFn } from "../types/core";
|
|
3
|
+
import type { ProjectIdentifier } from "../types/projects";
|
|
4
|
+
type CreateSpansRequestData = paths["/v1/projects/{project_identifier}/spans"]["post"]["requestBody"]["content"]["application/json"]["data"];
|
|
5
|
+
/**
|
|
6
|
+
* A span in Phoenix's simplified span structure, as accepted by {@link logSpans}.
|
|
7
|
+
* This is the same shape returned by `getSpans`, which makes it possible to read
|
|
8
|
+
* spans from one project and log them into another.
|
|
9
|
+
*/
|
|
10
|
+
export type Span = CreateSpansRequestData[number];
|
|
11
|
+
/** Information about a span that failed validation and was not queued. */
|
|
12
|
+
export interface InvalidSpanInfo {
|
|
13
|
+
spanId: string;
|
|
14
|
+
traceId: string;
|
|
15
|
+
error: string;
|
|
16
|
+
}
|
|
17
|
+
/** Information about a span that was rejected because it already exists. */
|
|
18
|
+
export interface DuplicateSpanInfo {
|
|
19
|
+
spanId: string;
|
|
20
|
+
traceId: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Raised by {@link logSpans} when one or more spans in the request are invalid
|
|
24
|
+
* or duplicates. If any span in a request fails, none of the spans in that
|
|
25
|
+
* request are queued.
|
|
26
|
+
*/
|
|
27
|
+
export declare class SpanCreationError extends Error {
|
|
28
|
+
readonly invalidSpans: InvalidSpanInfo[];
|
|
29
|
+
readonly duplicateSpans: DuplicateSpanInfo[];
|
|
30
|
+
readonly totalReceived: number;
|
|
31
|
+
readonly totalQueued: number;
|
|
32
|
+
constructor(params: {
|
|
33
|
+
message: string;
|
|
34
|
+
invalidSpans?: InvalidSpanInfo[];
|
|
35
|
+
duplicateSpans?: DuplicateSpanInfo[];
|
|
36
|
+
totalReceived?: number;
|
|
37
|
+
totalQueued?: number;
|
|
38
|
+
});
|
|
39
|
+
/** Number of spans rejected as invalid. */
|
|
40
|
+
get totalInvalid(): number;
|
|
41
|
+
/** Number of spans rejected as duplicates. */
|
|
42
|
+
get totalDuplicates(): number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parameters to log spans to a project
|
|
46
|
+
*/
|
|
47
|
+
export interface LogSpansParams extends ClientFn {
|
|
48
|
+
/** The project to log spans into */
|
|
49
|
+
project: ProjectIdentifier;
|
|
50
|
+
/** The spans to log */
|
|
51
|
+
spans: Span[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Statistics about a {@link logSpans} call. When successful, `totalQueued`
|
|
55
|
+
* equals `totalReceived`.
|
|
56
|
+
*/
|
|
57
|
+
export interface LogSpansResult {
|
|
58
|
+
totalReceived: number;
|
|
59
|
+
totalQueued: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Log spans to a project using Phoenix's simplified span structure.
|
|
63
|
+
*
|
|
64
|
+
* If any span in the request is invalid or a duplicate of a span that already
|
|
65
|
+
* exists, none of the spans in the request are queued and a
|
|
66
|
+
* {@link SpanCreationError} is thrown with details about the failures.
|
|
67
|
+
*
|
|
68
|
+
* @experimental this function is experimental and may change in the future
|
|
69
|
+
*
|
|
70
|
+
* @param params - The parameters to log spans
|
|
71
|
+
* @returns Statistics about the operation. When successful, `totalQueued`
|
|
72
|
+
* equals `totalReceived`.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* const result = await logSpans({
|
|
77
|
+
* project: { projectName: "my-project" },
|
|
78
|
+
* spans: [
|
|
79
|
+
* {
|
|
80
|
+
* name: "test",
|
|
81
|
+
* context: { trace_id: "123", span_id: "456" },
|
|
82
|
+
* span_kind: "CHAIN",
|
|
83
|
+
* start_time: "2024-01-01T00:00:00Z",
|
|
84
|
+
* end_time: "2024-01-01T00:00:01Z",
|
|
85
|
+
* status_code: "OK",
|
|
86
|
+
* },
|
|
87
|
+
* ],
|
|
88
|
+
* });
|
|
89
|
+
* console.log(`Queued ${result.totalQueued} spans`);
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare function logSpans({ client: _client, project, spans, }: LogSpansParams): Promise<LogSpansResult>;
|
|
93
|
+
export {};
|
|
94
|
+
//# sourceMappingURL=logSpans.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSpans.d.ts","sourceRoot":"","sources":["../../../src/spans/logSpans.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,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AAQ;IAC9C,oCAAoC;IACpC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,uBAAuB;IACvB,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB;AAoLD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,QAAQ,CAAC,EAC7B,MAAM,EAAE,OAAO,EACf,OAAO,EACP,KAAK,GACN,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CA0B1C"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SpanCreationError = void 0;
|
|
4
|
+
exports.logSpans = logSpans;
|
|
5
|
+
const client_1 = require("../client");
|
|
6
|
+
const projects_1 = require("../types/projects");
|
|
7
|
+
const apiErrorUtils_1 = require("../utils/apiErrorUtils");
|
|
8
|
+
const isObject_1 = require("../utils/isObject");
|
|
9
|
+
const safelyParseJSON_1 = require("../utils/safelyParseJSON");
|
|
10
|
+
/**
|
|
11
|
+
* Raised by {@link logSpans} when one or more spans in the request are invalid
|
|
12
|
+
* or duplicates. If any span in a request fails, none of the spans in that
|
|
13
|
+
* request are queued.
|
|
14
|
+
*/
|
|
15
|
+
class SpanCreationError extends Error {
|
|
16
|
+
constructor(params) {
|
|
17
|
+
var _a, _b, _c, _d;
|
|
18
|
+
super(params.message);
|
|
19
|
+
this.name = "SpanCreationError";
|
|
20
|
+
this.invalidSpans = (_a = params.invalidSpans) !== null && _a !== void 0 ? _a : [];
|
|
21
|
+
this.duplicateSpans = (_b = params.duplicateSpans) !== null && _b !== void 0 ? _b : [];
|
|
22
|
+
this.totalReceived = (_c = params.totalReceived) !== null && _c !== void 0 ? _c : 0;
|
|
23
|
+
this.totalQueued = (_d = params.totalQueued) !== null && _d !== void 0 ? _d : 0;
|
|
24
|
+
}
|
|
25
|
+
/** Number of spans rejected as invalid. */
|
|
26
|
+
get totalInvalid() {
|
|
27
|
+
return this.invalidSpans.length;
|
|
28
|
+
}
|
|
29
|
+
/** Number of spans rejected as duplicates. */
|
|
30
|
+
get totalDuplicates() {
|
|
31
|
+
return this.duplicateSpans.length;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.SpanCreationError = SpanCreationError;
|
|
35
|
+
const MAX_ERRORS_TO_SHOW = 5;
|
|
36
|
+
function formatLogSpansErrorMessage({ invalidSpans, duplicateSpans, }) {
|
|
37
|
+
const parts = [];
|
|
38
|
+
if (invalidSpans.length > 0) {
|
|
39
|
+
parts.push(`Failed to queue ${invalidSpans.length} invalid spans:`);
|
|
40
|
+
for (const span of invalidSpans.slice(0, MAX_ERRORS_TO_SHOW)) {
|
|
41
|
+
parts.push(` - Span ${span.spanId}: ${span.error}`);
|
|
42
|
+
}
|
|
43
|
+
if (invalidSpans.length > MAX_ERRORS_TO_SHOW) {
|
|
44
|
+
parts.push(` ... and ${invalidSpans.length - MAX_ERRORS_TO_SHOW} more invalid spans`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (duplicateSpans.length > 0) {
|
|
48
|
+
if (parts.length > 0)
|
|
49
|
+
parts.push("");
|
|
50
|
+
parts.push(`Found ${duplicateSpans.length} duplicate spans:`);
|
|
51
|
+
for (const span of duplicateSpans.slice(0, MAX_ERRORS_TO_SHOW)) {
|
|
52
|
+
parts.push(` - Span ${span.spanId}`);
|
|
53
|
+
}
|
|
54
|
+
if (duplicateSpans.length > MAX_ERRORS_TO_SHOW) {
|
|
55
|
+
parts.push(` ... and ${duplicateSpans.length - MAX_ERRORS_TO_SHOW} more duplicates`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return parts.join("\n");
|
|
59
|
+
}
|
|
60
|
+
function toSpanIdAndTraceId(item) {
|
|
61
|
+
const record = (0, isObject_1.isObject)(item) ? item : {};
|
|
62
|
+
return {
|
|
63
|
+
spanId: typeof record.span_id === "string" ? record.span_id : "unknown",
|
|
64
|
+
traceId: typeof record.trace_id === "string" ? record.trace_id : "unknown",
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function toInvalidSpanInfoList(value) {
|
|
68
|
+
if (!Array.isArray(value))
|
|
69
|
+
return [];
|
|
70
|
+
return value.map((item) => {
|
|
71
|
+
const record = (0, isObject_1.isObject)(item) ? item : {};
|
|
72
|
+
return Object.assign(Object.assign({}, toSpanIdAndTraceId(item)), { error: typeof record.error === "string" ? record.error : "Validation error" });
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function toDuplicateSpanInfoList(value) {
|
|
76
|
+
if (!Array.isArray(value))
|
|
77
|
+
return [];
|
|
78
|
+
return value.map(toSpanIdAndTraceId);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Builds a {@link SpanCreationError} from already-normalized invalid/duplicate
|
|
82
|
+
* span lists, computing the shared message once.
|
|
83
|
+
*/
|
|
84
|
+
function makeSpanCreationError(params) {
|
|
85
|
+
return new SpanCreationError(Object.assign({ message: formatLogSpansErrorMessage(params) }, params));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Builds a {@link SpanCreationError} from a parsed error payload matching the
|
|
89
|
+
* shape returned by the server for invalid/duplicate spans:
|
|
90
|
+
* `{ total_received, total_queued, total_invalid, total_duplicates, invalid_spans, duplicate_spans }`.
|
|
91
|
+
*/
|
|
92
|
+
function buildSpanCreationError(payload) {
|
|
93
|
+
return makeSpanCreationError({
|
|
94
|
+
invalidSpans: toInvalidSpanInfoList(payload.invalid_spans),
|
|
95
|
+
duplicateSpans: toDuplicateSpanInfoList(payload.duplicate_spans),
|
|
96
|
+
totalReceived: typeof payload.total_received === "number" ? payload.total_received : 0,
|
|
97
|
+
totalQueued: typeof payload.total_queued === "number" ? payload.total_queued : 0,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function isSpanCreationErrorPayload(value) {
|
|
101
|
+
return ((0, isObject_1.isObject)(value) && ("invalid_spans" in value || "duplicate_spans" in value));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Extracts invalid span info from a FastAPI request-validation error array
|
|
105
|
+
* (returned with a 422 status when a span in the payload is malformed).
|
|
106
|
+
*/
|
|
107
|
+
function extractInvalidSpansFromValidationErrors(errors, spans) {
|
|
108
|
+
var _a, _b, _c, _d;
|
|
109
|
+
const invalidSpans = [];
|
|
110
|
+
for (const rawError of errors) {
|
|
111
|
+
if (!(0, isObject_1.isObject)(rawError))
|
|
112
|
+
continue;
|
|
113
|
+
const loc = rawError.loc;
|
|
114
|
+
if (!Array.isArray(loc) ||
|
|
115
|
+
loc.length < 3 ||
|
|
116
|
+
loc[0] !== "body" ||
|
|
117
|
+
loc[1] !== "data" ||
|
|
118
|
+
typeof loc[2] !== "number") {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const span = spans[loc[2]];
|
|
122
|
+
if (!span)
|
|
123
|
+
continue;
|
|
124
|
+
const msg = rawError.msg;
|
|
125
|
+
invalidSpans.push({
|
|
126
|
+
spanId: (_b = (_a = span.context) === null || _a === void 0 ? void 0 : _a.span_id) !== null && _b !== void 0 ? _b : "unknown",
|
|
127
|
+
traceId: (_d = (_c = span.context) === null || _c === void 0 ? void 0 : _c.trace_id) !== null && _d !== void 0 ? _d : "unknown",
|
|
128
|
+
error: typeof msg === "string" ? msg : "Validation error",
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return invalidSpans;
|
|
132
|
+
}
|
|
133
|
+
function parseLogSpansError(error, spans) {
|
|
134
|
+
if ((0, isObject_1.isObject)(error)) {
|
|
135
|
+
const detail = error.detail;
|
|
136
|
+
if (typeof detail === "string") {
|
|
137
|
+
const { json: parsed } = (0, safelyParseJSON_1.safelyParseJSON)(detail);
|
|
138
|
+
if (isSpanCreationErrorPayload(parsed)) {
|
|
139
|
+
return buildSpanCreationError(parsed);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else if (Array.isArray(detail)) {
|
|
143
|
+
const invalidSpans = extractInvalidSpansFromValidationErrors(detail, spans);
|
|
144
|
+
if (invalidSpans.length > 0) {
|
|
145
|
+
return makeSpanCreationError({
|
|
146
|
+
invalidSpans,
|
|
147
|
+
duplicateSpans: [],
|
|
148
|
+
totalReceived: spans.length,
|
|
149
|
+
// A FastAPI 422 rejects the entire request body, so no spans are
|
|
150
|
+
// queued — matching the all-or-nothing contract and the 400 path.
|
|
151
|
+
totalQueued: 0,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else if (isSpanCreationErrorPayload(error)) {
|
|
156
|
+
return buildSpanCreationError(error);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return new Error(`Failed to log spans: ${(0, apiErrorUtils_1.formatApiError)(error)}`);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Log spans to a project using Phoenix's simplified span structure.
|
|
163
|
+
*
|
|
164
|
+
* If any span in the request is invalid or a duplicate of a span that already
|
|
165
|
+
* exists, none of the spans in the request are queued and a
|
|
166
|
+
* {@link SpanCreationError} is thrown with details about the failures.
|
|
167
|
+
*
|
|
168
|
+
* @experimental this function is experimental and may change in the future
|
|
169
|
+
*
|
|
170
|
+
* @param params - The parameters to log spans
|
|
171
|
+
* @returns Statistics about the operation. When successful, `totalQueued`
|
|
172
|
+
* equals `totalReceived`.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* const result = await logSpans({
|
|
177
|
+
* project: { projectName: "my-project" },
|
|
178
|
+
* spans: [
|
|
179
|
+
* {
|
|
180
|
+
* name: "test",
|
|
181
|
+
* context: { trace_id: "123", span_id: "456" },
|
|
182
|
+
* span_kind: "CHAIN",
|
|
183
|
+
* start_time: "2024-01-01T00:00:00Z",
|
|
184
|
+
* end_time: "2024-01-01T00:00:01Z",
|
|
185
|
+
* status_code: "OK",
|
|
186
|
+
* },
|
|
187
|
+
* ],
|
|
188
|
+
* });
|
|
189
|
+
* console.log(`Queued ${result.totalQueued} spans`);
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
async function logSpans({ client: _client, project, spans, }) {
|
|
193
|
+
var _a, _b;
|
|
194
|
+
const client = _client !== null && _client !== void 0 ? _client : (0, client_1.createClient)();
|
|
195
|
+
const projectIdentifier = (0, projects_1.resolveProjectIdentifier)(project);
|
|
196
|
+
const { data, error } = await client.POST("/v1/projects/{project_identifier}/spans", {
|
|
197
|
+
params: {
|
|
198
|
+
path: {
|
|
199
|
+
project_identifier: projectIdentifier,
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
body: {
|
|
203
|
+
data: spans,
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
if (error) {
|
|
207
|
+
throw parseLogSpansError(error, spans);
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
totalReceived: (_a = data === null || data === void 0 ? void 0 : data.total_received) !== null && _a !== void 0 ? _a : spans.length,
|
|
211
|
+
totalQueued: (_b = data === null || data === void 0 ? void 0 : data.total_queued) !== null && _b !== void 0 ? _b : 0,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=logSpans.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSpans.js","sourceRoot":"","sources":["../../../src/spans/logSpans.ts"],"names":[],"mappings":";;;AAySA,4BA8BC;AAtUD,sCAAyC;AAGzC,gDAA6D;AAC7D,0DAAwD;AACxD,gDAA6C;AAC7C,8DAA2D;AAyB3D;;;;GAIG;AACH,MAAa,iBAAkB,SAAQ,KAAK;IAM1C,YAAY,MAMX;;QACC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,YAAY,GAAG,MAAA,MAAM,CAAC,YAAY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