@anuma/sdk 10.6.1 → 10.7.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/expo/index.cjs +7 -1
- package/dist/expo/index.d.mts +2 -0
- package/dist/expo/index.d.ts +2 -0
- package/dist/expo/index.mjs +7 -1
- package/dist/pii/transformers.cjs +22 -11
- package/dist/pii/transformers.d.mts +3 -6
- package/dist/pii/transformers.d.ts +3 -6
- package/dist/pii/transformers.mjs +22 -11
- package/dist/react/{consolidate-RASCVKD2.mjs → consolidate-KM26Y2LT.mjs} +1 -1
- package/dist/react/index.cjs +6508 -6227
- package/dist/react/index.d.mts +256 -155
- package/dist/react/index.d.ts +256 -155
- package/dist/react/index.mjs +5999 -5722
- package/dist/server/index.cjs +7 -1
- package/dist/server/index.d.mts +2 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.mjs +7 -1
- package/package.json +1 -1
- package/dist/react/{chunk-6QCUNXU6.mjs → chunk-3VZG3QO5.mjs} +957 -957
package/dist/expo/index.cjs
CHANGED
|
@@ -11129,7 +11129,13 @@ Executing tool: ${toolInfo}
|
|
|
11129
11129
|
if (onError) onError(errorObj);
|
|
11130
11130
|
await fireRunError({ error: errorMsg, stage: "model", errorObject: errorObj });
|
|
11131
11131
|
const statusCode = err instanceof Error && "statusCode" in err ? err.statusCode : void 0;
|
|
11132
|
-
|
|
11132
|
+
const connectionLost = !(err instanceof ProviderStreamError) && !(err instanceof SseError);
|
|
11133
|
+
return {
|
|
11134
|
+
data: null,
|
|
11135
|
+
error: errorMsg,
|
|
11136
|
+
statusCode,
|
|
11137
|
+
...connectionLost ? { connectionLost: true } : {}
|
|
11138
|
+
};
|
|
11133
11139
|
} finally {
|
|
11134
11140
|
cleanupSignalLink();
|
|
11135
11141
|
}
|
package/dist/expo/index.d.mts
CHANGED
|
@@ -2587,6 +2587,8 @@ type RunToolLoopResult = {
|
|
|
2587
2587
|
detached?: true;
|
|
2588
2588
|
/** Non-null only when `resumable` was true AND an inference id was captured before detach. */
|
|
2589
2589
|
resume?: StreamResumeHandle | null;
|
|
2590
|
+
/** True when the connection failed rather than the generation: the portal may still be generating. */
|
|
2591
|
+
connectionLost?: true;
|
|
2590
2592
|
/**
|
|
2591
2593
|
* Terminal state of the final model response, when the failure is one the
|
|
2592
2594
|
* loop diagnosed FROM that response — today, the truncated-to-nothing
|
package/dist/expo/index.d.ts
CHANGED
|
@@ -2587,6 +2587,8 @@ type RunToolLoopResult = {
|
|
|
2587
2587
|
detached?: true;
|
|
2588
2588
|
/** Non-null only when `resumable` was true AND an inference id was captured before detach. */
|
|
2589
2589
|
resume?: StreamResumeHandle | null;
|
|
2590
|
+
/** True when the connection failed rather than the generation: the portal may still be generating. */
|
|
2591
|
+
connectionLost?: true;
|
|
2590
2592
|
/**
|
|
2591
2593
|
* Terminal state of the final model response, when the failure is one the
|
|
2592
2594
|
* loop diagnosed FROM that response — today, the truncated-to-nothing
|
package/dist/expo/index.mjs
CHANGED
|
@@ -9461,7 +9461,13 @@ Executing tool: ${toolInfo}
|
|
|
9461
9461
|
if (onError) onError(errorObj);
|
|
9462
9462
|
await fireRunError({ error: errorMsg, stage: "model", errorObject: errorObj });
|
|
9463
9463
|
const statusCode = err instanceof Error && "statusCode" in err ? err.statusCode : void 0;
|
|
9464
|
-
|
|
9464
|
+
const connectionLost = !(err instanceof ProviderStreamError) && !(err instanceof SseError);
|
|
9465
|
+
return {
|
|
9466
|
+
data: null,
|
|
9467
|
+
error: errorMsg,
|
|
9468
|
+
statusCode,
|
|
9469
|
+
...connectionLost ? { connectionLost: true } : {}
|
|
9470
|
+
};
|
|
9465
9471
|
} finally {
|
|
9466
9472
|
cleanupSignalLink();
|
|
9467
9473
|
}
|
|
@@ -42,20 +42,24 @@ var DEFAULT_TAG_MAP = {
|
|
|
42
42
|
MISC: void 0
|
|
43
43
|
};
|
|
44
44
|
function placeTokens(tokens, text) {
|
|
45
|
-
|
|
45
|
+
return tokens.map((token) => {
|
|
46
|
+
const { start = -1, end = -1 } = token;
|
|
47
|
+
return Number.isInteger(start) && Number.isInteger(end) && start >= 0 && end > start && end <= text.length ? { ...token, start, end } : { ...token, start: -1, end: -1 };
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function tokenOffsets(text, tokenizer) {
|
|
51
|
+
const { input_ids } = tokenizer(text, { return_tensor: false, truncation: true });
|
|
46
52
|
let cursor = 0;
|
|
47
|
-
|
|
48
|
-
const
|
|
53
|
+
return input_ids.map((id) => {
|
|
54
|
+
const word = tokenizer.decode([id], { skip_special_tokens: true });
|
|
55
|
+
const surface = word.startsWith("##") ? word.slice(2) : word;
|
|
56
|
+
if (!surface) return { start: -1, end: -1 };
|
|
49
57
|
const start = text.indexOf(surface, cursor);
|
|
50
|
-
if (start < 0) {
|
|
51
|
-
placed.push({ ...t, start: -1, end: -1 });
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
58
|
+
if (start < 0) return { start: -1, end: -1 };
|
|
54
59
|
const end = start + surface.length;
|
|
55
|
-
placed.push({ ...t, start, end });
|
|
56
60
|
cursor = end;
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
return { start, end };
|
|
62
|
+
});
|
|
59
63
|
}
|
|
60
64
|
function aggregateTokens(tokens, text, tagMap, minScore) {
|
|
61
65
|
const placed = placeTokens(tokens, text);
|
|
@@ -115,7 +119,14 @@ function createTransformersNerDetector(options = {}) {
|
|
|
115
119
|
if (!text) return [];
|
|
116
120
|
const classify = await load();
|
|
117
121
|
const tokens = await classify(text);
|
|
118
|
-
|
|
122
|
+
if (!tokens.length) return [];
|
|
123
|
+
const offsets = tokenOffsets(text, classify.tokenizer);
|
|
124
|
+
return aggregateTokens(
|
|
125
|
+
tokens.map((token) => ({ ...token, ...offsets[token.index] })),
|
|
126
|
+
text,
|
|
127
|
+
tagMap,
|
|
128
|
+
minScore
|
|
129
|
+
);
|
|
119
130
|
}
|
|
120
131
|
};
|
|
121
132
|
}
|
|
@@ -54,13 +54,10 @@ interface RawToken {
|
|
|
54
54
|
score: number;
|
|
55
55
|
index: number;
|
|
56
56
|
word: string;
|
|
57
|
+
start?: number;
|
|
58
|
+
end?: number;
|
|
57
59
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Aggregate B-/I- subword tokens into whole-entity spans. A new entity starts
|
|
60
|
-
* on a `B-` tag or a tag change; contiguous `I-` tokens (and WordPiece "##"
|
|
61
|
-
* continuations) of the same base tag extend it. (The SDK additionally snaps
|
|
62
|
-
* spans to word boundaries, so dropped trailing subwords are recovered there.)
|
|
63
|
-
*/
|
|
60
|
+
/** Aggregate classified tokens with character offsets into whole-entity spans. */
|
|
64
61
|
declare function aggregateTokens(tokens: RawToken[], text: string, tagMap: Record<string, string | undefined>, minScore: number): PiiSpan[];
|
|
65
62
|
/**
|
|
66
63
|
* Create a Transformers.js-backed {@link NerDetector}. The returned detector
|
|
@@ -54,13 +54,10 @@ interface RawToken {
|
|
|
54
54
|
score: number;
|
|
55
55
|
index: number;
|
|
56
56
|
word: string;
|
|
57
|
+
start?: number;
|
|
58
|
+
end?: number;
|
|
57
59
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Aggregate B-/I- subword tokens into whole-entity spans. A new entity starts
|
|
60
|
-
* on a `B-` tag or a tag change; contiguous `I-` tokens (and WordPiece "##"
|
|
61
|
-
* continuations) of the same base tag extend it. (The SDK additionally snaps
|
|
62
|
-
* spans to word boundaries, so dropped trailing subwords are recovered there.)
|
|
63
|
-
*/
|
|
60
|
+
/** Aggregate classified tokens with character offsets into whole-entity spans. */
|
|
64
61
|
declare function aggregateTokens(tokens: RawToken[], text: string, tagMap: Record<string, string | undefined>, minScore: number): PiiSpan[];
|
|
65
62
|
/**
|
|
66
63
|
* Create a Transformers.js-backed {@link NerDetector}. The returned detector
|
|
@@ -7,20 +7,24 @@ var DEFAULT_TAG_MAP = {
|
|
|
7
7
|
MISC: void 0
|
|
8
8
|
};
|
|
9
9
|
function placeTokens(tokens, text) {
|
|
10
|
-
|
|
10
|
+
return tokens.map((token) => {
|
|
11
|
+
const { start = -1, end = -1 } = token;
|
|
12
|
+
return Number.isInteger(start) && Number.isInteger(end) && start >= 0 && end > start && end <= text.length ? { ...token, start, end } : { ...token, start: -1, end: -1 };
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function tokenOffsets(text, tokenizer) {
|
|
16
|
+
const { input_ids } = tokenizer(text, { return_tensor: false, truncation: true });
|
|
11
17
|
let cursor = 0;
|
|
12
|
-
|
|
13
|
-
const
|
|
18
|
+
return input_ids.map((id) => {
|
|
19
|
+
const word = tokenizer.decode([id], { skip_special_tokens: true });
|
|
20
|
+
const surface = word.startsWith("##") ? word.slice(2) : word;
|
|
21
|
+
if (!surface) return { start: -1, end: -1 };
|
|
14
22
|
const start = text.indexOf(surface, cursor);
|
|
15
|
-
if (start < 0) {
|
|
16
|
-
placed.push({ ...t, start: -1, end: -1 });
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
23
|
+
if (start < 0) return { start: -1, end: -1 };
|
|
19
24
|
const end = start + surface.length;
|
|
20
|
-
placed.push({ ...t, start, end });
|
|
21
25
|
cursor = end;
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
return { start, end };
|
|
27
|
+
});
|
|
24
28
|
}
|
|
25
29
|
function aggregateTokens(tokens, text, tagMap, minScore) {
|
|
26
30
|
const placed = placeTokens(tokens, text);
|
|
@@ -80,7 +84,14 @@ function createTransformersNerDetector(options = {}) {
|
|
|
80
84
|
if (!text) return [];
|
|
81
85
|
const classify = await load();
|
|
82
86
|
const tokens = await classify(text);
|
|
83
|
-
|
|
87
|
+
if (!tokens.length) return [];
|
|
88
|
+
const offsets = tokenOffsets(text, classify.tokenizer);
|
|
89
|
+
return aggregateTokens(
|
|
90
|
+
tokens.map((token) => ({ ...token, ...offsets[token.index] })),
|
|
91
|
+
text,
|
|
92
|
+
tagMap,
|
|
93
|
+
minScore
|
|
94
|
+
);
|
|
84
95
|
}
|
|
85
96
|
};
|
|
86
97
|
}
|