@atlaskit/editor-plugin-autocomplete 3.6.0 → 3.6.1
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 +11 -0
- package/dist/cjs/pm-plugins/autocomplete-plugin.js +6 -2
- package/dist/cjs/pm-plugins/local-slow-lane-client.js +3 -1
- package/dist/cjs/pm-plugins/text-predictor.js +18 -4
- package/dist/es2019/pm-plugins/autocomplete-plugin.js +6 -2
- package/dist/es2019/pm-plugins/local-slow-lane-client.js +3 -1
- package/dist/es2019/pm-plugins/text-predictor.js +17 -3
- package/dist/esm/pm-plugins/autocomplete-plugin.js +6 -2
- package/dist/esm/pm-plugins/local-slow-lane-client.js +3 -1
- package/dist/esm/pm-plugins/text-predictor.js +18 -4
- package/dist/types/pm-plugins/local-slow-lane-client.d.ts +2 -2
- package/dist/types/pm-plugins/text-predictor.d.ts +4 -1
- package/dist/types-ts4.5/pm-plugins/local-slow-lane-client.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/text-predictor.d.ts +4 -1
- package/package.json +1 -1
- package/src/pm-plugins/autocomplete-plugin.ts +12 -9
- package/src/pm-plugins/local-slow-lane-client.ts +4 -3
- package/src/pm-plugins/text-predictor.ts +12 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-autocomplete
|
|
2
2
|
|
|
3
|
+
## 3.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`2d57d65205edd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2d57d65205edd) -
|
|
8
|
+
[ASIMO] Add `isLocalLLM` attribute to `load-vectors` and `load-vocabulary` UFO experiences.
|
|
9
|
+
|
|
10
|
+
Both experiences now include an `isLocalLLM: boolean` attribute on every event (start, succeed,
|
|
11
|
+
fail) so analysts can segment loading performance and reliability by whether the user is on the
|
|
12
|
+
local on-device model setup vs the standard network-based slow-lane backend.
|
|
13
|
+
|
|
3
14
|
## 3.6.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
|
@@ -583,13 +583,17 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
|
|
|
583
583
|
return false;
|
|
584
584
|
},
|
|
585
585
|
focus: function focus() {
|
|
586
|
-
|
|
586
|
+
var _options$useLocalMode, _options$useLocalMode2;
|
|
587
|
+
(0, _textPredictor.loadDefaultVocabulary)({
|
|
588
|
+
isLocalLLM: (_options$useLocalMode = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode !== void 0 ? _options$useLocalMode : false
|
|
589
|
+
}).catch(function (error) {
|
|
587
590
|
(0, _monitoring.logException)(error, {
|
|
588
591
|
location: 'editor-plugin-autocomplete/loadDefaultVocabulary'
|
|
589
592
|
});
|
|
590
593
|
});
|
|
591
594
|
(0, _textPredictor.loadVectorsAsync)({
|
|
592
|
-
getBinaryUrl: options === null || options === void 0 ? void 0 : options.getVectorsBinaryUrl
|
|
595
|
+
getBinaryUrl: options === null || options === void 0 ? void 0 : options.getVectorsBinaryUrl,
|
|
596
|
+
isLocalLLM: (_options$useLocalMode2 = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode2 !== void 0 ? _options$useLocalMode2 : false
|
|
593
597
|
}).catch(function (error) {
|
|
594
598
|
(0, _monitoring.logException)(error, {
|
|
595
599
|
location: 'editor-plugin-autocomplete/loadVectorsAsync'
|
|
@@ -765,7 +765,9 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
|
|
|
765
765
|
if (lower.includes('loading chunk') || lower.includes('dynamically imported module') || lower.includes('dynamic import')) {
|
|
766
766
|
return 'module_load_failed';
|
|
767
767
|
}
|
|
768
|
-
if (lower.includes('out of memory') ||
|
|
768
|
+
if (lower.includes('out of memory') ||
|
|
769
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
770
|
+
/\boom\b/.test(lower) || lower.includes('allocation') || lower.includes('exceeds') || lower.includes('buffer size') || lower.includes('not enough memory')) {
|
|
769
771
|
return 'insufficient_memory';
|
|
770
772
|
}
|
|
771
773
|
// Pre-flight already returns missing_shader_f16 when the feature is absent,
|
|
@@ -733,7 +733,8 @@ var unwrapJsonModule = function unwrapJsonModule(mod, shape) {
|
|
|
733
733
|
};
|
|
734
734
|
var loadVectorsAsync = exports.loadVectorsAsync = /*#__PURE__*/function () {
|
|
735
735
|
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(options) {
|
|
736
|
-
var
|
|
736
|
+
var _options$isLocalLLM;
|
|
737
|
+
var isLocalLLM, url, _wordIndexOuter$index, res, buffer, float32, wordIndexModule, wordIndexOuter, wordIndex, nWords, dim, _t, _t2;
|
|
737
738
|
return _regenerator.default.wrap(function (_context) {
|
|
738
739
|
while (1) switch (_context.prev = _context.next) {
|
|
739
740
|
case 0:
|
|
@@ -751,8 +752,11 @@ var loadVectorsAsync = exports.loadVectorsAsync = /*#__PURE__*/function () {
|
|
|
751
752
|
console.warn('[text-predictor] loadVectorsAsync called without a getBinaryUrl — vectors will not load. Pass getVectorsBinaryUrl via plugin options.');
|
|
752
753
|
return _context.abrupt("return");
|
|
753
754
|
case 2:
|
|
755
|
+
isLocalLLM = (_options$isLocalLLM = options === null || options === void 0 ? void 0 : options.isLocalLLM) !== null && _options$isLocalLLM !== void 0 ? _options$isLocalLLM : false;
|
|
754
756
|
vectorsLoadStarted = true;
|
|
755
|
-
(0, _ufo.startExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton'
|
|
757
|
+
(0, _ufo.startExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
758
|
+
isLocalLLM: isLocalLLM
|
|
759
|
+
});
|
|
756
760
|
_context.prev = 3;
|
|
757
761
|
_context.next = 4;
|
|
758
762
|
return options.getBinaryUrl();
|
|
@@ -765,6 +769,7 @@ var loadVectorsAsync = exports.loadVectorsAsync = /*#__PURE__*/function () {
|
|
|
765
769
|
_t = _context["catch"](3);
|
|
766
770
|
vectorsLoadStarted = false;
|
|
767
771
|
(0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
772
|
+
isLocalLLM: isLocalLLM,
|
|
768
773
|
errorType: 'resolve_url'
|
|
769
774
|
});
|
|
770
775
|
// eslint-disable-next-line no-console
|
|
@@ -782,6 +787,7 @@ var loadVectorsAsync = exports.loadVectorsAsync = /*#__PURE__*/function () {
|
|
|
782
787
|
}
|
|
783
788
|
vectorsLoadStarted = false;
|
|
784
789
|
(0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
790
|
+
isLocalLLM: isLocalLLM,
|
|
785
791
|
status: res.status,
|
|
786
792
|
errorType: 'http_error'
|
|
787
793
|
});
|
|
@@ -816,6 +822,7 @@ var loadVectorsAsync = exports.loadVectorsAsync = /*#__PURE__*/function () {
|
|
|
816
822
|
dim: dim
|
|
817
823
|
};
|
|
818
824
|
(0, _ufo.succeedExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
825
|
+
isLocalLLM: isLocalLLM,
|
|
819
826
|
wordCount: nWords,
|
|
820
827
|
dim: dim,
|
|
821
828
|
sizeBytes: float32.byteLength
|
|
@@ -835,6 +842,7 @@ var loadVectorsAsync = exports.loadVectorsAsync = /*#__PURE__*/function () {
|
|
|
835
842
|
_t2 = _context["catch"](6);
|
|
836
843
|
vectorsLoadStarted = false;
|
|
837
844
|
(0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
845
|
+
isLocalLLM: isLocalLLM,
|
|
838
846
|
errorType: 'network'
|
|
839
847
|
});
|
|
840
848
|
// eslint-disable-next-line no-console
|
|
@@ -853,19 +861,23 @@ var initVectors = exports.initVectors = function initVectors(store) {
|
|
|
853
861
|
vectorStore = store;
|
|
854
862
|
};
|
|
855
863
|
var vocabularyLoadPromise;
|
|
856
|
-
var loadDefaultVocabulary = exports.loadDefaultVocabulary = function loadDefaultVocabulary() {
|
|
864
|
+
var loadDefaultVocabulary = exports.loadDefaultVocabulary = function loadDefaultVocabulary(options) {
|
|
865
|
+
var _options$isLocalLLM2;
|
|
857
866
|
if (isInitialized) {
|
|
858
867
|
return Promise.resolve();
|
|
859
868
|
}
|
|
860
869
|
if (vocabularyLoadPromise) {
|
|
861
870
|
return vocabularyLoadPromise;
|
|
862
871
|
}
|
|
872
|
+
var isLocalLLM = (_options$isLocalLLM2 = options === null || options === void 0 ? void 0 : options.isLocalLLM) !== null && _options$isLocalLLM2 !== void 0 ? _options$isLocalLLM2 : false;
|
|
863
873
|
vocabularyLoadPromise = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
864
874
|
var _yield$Promise$all, _yield$Promise$all2, vocabularyModule, l3VocabularyModule, vocabularyData, l3VocabularyData, terms, _t3;
|
|
865
875
|
return _regenerator.default.wrap(function (_context2) {
|
|
866
876
|
while (1) switch (_context2.prev = _context2.next) {
|
|
867
877
|
case 0:
|
|
868
|
-
(0, _ufo.startExp)(_ufo.EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton'
|
|
878
|
+
(0, _ufo.startExp)(_ufo.EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
|
|
879
|
+
isLocalLLM: isLocalLLM
|
|
880
|
+
});
|
|
869
881
|
_context2.prev = 1;
|
|
870
882
|
_context2.next = 2;
|
|
871
883
|
return Promise.all([Promise.resolve().then(function () {
|
|
@@ -904,6 +916,7 @@ var loadDefaultVocabulary = exports.loadDefaultVocabulary = function loadDefault
|
|
|
904
916
|
terms: terms
|
|
905
917
|
});
|
|
906
918
|
(0, _ufo.succeedExp)(_ufo.EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
|
|
919
|
+
isLocalLLM: isLocalLLM,
|
|
907
920
|
l2WordCount: terms.length,
|
|
908
921
|
l3WordCount: l3VocabularyData.length
|
|
909
922
|
});
|
|
@@ -913,6 +926,7 @@ var loadDefaultVocabulary = exports.loadDefaultVocabulary = function loadDefault
|
|
|
913
926
|
_context2.prev = 4;
|
|
914
927
|
_t3 = _context2["catch"](1);
|
|
915
928
|
(0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
|
|
929
|
+
isLocalLLM: isLocalLLM,
|
|
916
930
|
errorType: 'parse_error'
|
|
917
931
|
});
|
|
918
932
|
// Allow a later call to retry the load rather than caching the failure.
|
|
@@ -570,13 +570,17 @@ export const createAutocompletePlugin = (options, api) => {
|
|
|
570
570
|
return false;
|
|
571
571
|
},
|
|
572
572
|
focus: () => {
|
|
573
|
-
|
|
573
|
+
var _options$useLocalMode, _options$useLocalMode2;
|
|
574
|
+
loadDefaultVocabulary({
|
|
575
|
+
isLocalLLM: (_options$useLocalMode = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode !== void 0 ? _options$useLocalMode : false
|
|
576
|
+
}).catch(error => {
|
|
574
577
|
logException(error, {
|
|
575
578
|
location: 'editor-plugin-autocomplete/loadDefaultVocabulary'
|
|
576
579
|
});
|
|
577
580
|
});
|
|
578
581
|
loadVectorsAsync({
|
|
579
|
-
getBinaryUrl: options === null || options === void 0 ? void 0 : options.getVectorsBinaryUrl
|
|
582
|
+
getBinaryUrl: options === null || options === void 0 ? void 0 : options.getVectorsBinaryUrl,
|
|
583
|
+
isLocalLLM: (_options$useLocalMode2 = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode2 !== void 0 ? _options$useLocalMode2 : false
|
|
580
584
|
}).catch(error => {
|
|
581
585
|
logException(error, {
|
|
582
586
|
location: 'editor-plugin-autocomplete/loadVectorsAsync'
|
|
@@ -586,7 +586,9 @@ export const createLocalSlowLaneClient = (config = {}) => {
|
|
|
586
586
|
if (lower.includes('loading chunk') || lower.includes('dynamically imported module') || lower.includes('dynamic import')) {
|
|
587
587
|
return 'module_load_failed';
|
|
588
588
|
}
|
|
589
|
-
if (lower.includes('out of memory') ||
|
|
589
|
+
if (lower.includes('out of memory') ||
|
|
590
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
591
|
+
/\boom\b/.test(lower) || lower.includes('allocation') || lower.includes('exceeds') || lower.includes('buffer size') || lower.includes('not enough memory')) {
|
|
590
592
|
return 'insufficient_memory';
|
|
591
593
|
}
|
|
592
594
|
// Pre-flight already returns missing_shader_f16 when the feature is absent,
|
|
@@ -587,6 +587,7 @@ const unwrapJsonModule = (mod, shape) => {
|
|
|
587
587
|
return null;
|
|
588
588
|
};
|
|
589
589
|
export const loadVectorsAsync = async options => {
|
|
590
|
+
var _options$isLocalLLM;
|
|
590
591
|
if (vectorStore || vectorsLoadStarted) {
|
|
591
592
|
return;
|
|
592
593
|
}
|
|
@@ -595,14 +596,18 @@ export const loadVectorsAsync = async options => {
|
|
|
595
596
|
console.warn('[text-predictor] loadVectorsAsync called without a getBinaryUrl — vectors will not load. Pass getVectorsBinaryUrl via plugin options.');
|
|
596
597
|
return;
|
|
597
598
|
}
|
|
599
|
+
const isLocalLLM = (_options$isLocalLLM = options === null || options === void 0 ? void 0 : options.isLocalLLM) !== null && _options$isLocalLLM !== void 0 ? _options$isLocalLLM : false;
|
|
598
600
|
vectorsLoadStarted = true;
|
|
599
|
-
startExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton'
|
|
601
|
+
startExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
602
|
+
isLocalLLM
|
|
603
|
+
});
|
|
600
604
|
let url;
|
|
601
605
|
try {
|
|
602
606
|
url = await options.getBinaryUrl();
|
|
603
607
|
} catch (e) {
|
|
604
608
|
vectorsLoadStarted = false;
|
|
605
609
|
failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
610
|
+
isLocalLLM,
|
|
606
611
|
errorType: 'resolve_url'
|
|
607
612
|
});
|
|
608
613
|
// eslint-disable-next-line no-console
|
|
@@ -615,6 +620,7 @@ export const loadVectorsAsync = async options => {
|
|
|
615
620
|
if (!res.ok) {
|
|
616
621
|
vectorsLoadStarted = false;
|
|
617
622
|
failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
623
|
+
isLocalLLM,
|
|
618
624
|
status: res.status,
|
|
619
625
|
errorType: 'http_error'
|
|
620
626
|
});
|
|
@@ -643,6 +649,7 @@ export const loadVectorsAsync = async options => {
|
|
|
643
649
|
dim
|
|
644
650
|
};
|
|
645
651
|
succeedExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
652
|
+
isLocalLLM,
|
|
646
653
|
wordCount: nWords,
|
|
647
654
|
dim,
|
|
648
655
|
sizeBytes: float32.byteLength
|
|
@@ -658,6 +665,7 @@ export const loadVectorsAsync = async options => {
|
|
|
658
665
|
} catch (e) {
|
|
659
666
|
vectorsLoadStarted = false;
|
|
660
667
|
failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
668
|
+
isLocalLLM,
|
|
661
669
|
errorType: 'network'
|
|
662
670
|
});
|
|
663
671
|
// eslint-disable-next-line no-console
|
|
@@ -668,15 +676,19 @@ export const initVectors = store => {
|
|
|
668
676
|
vectorStore = store;
|
|
669
677
|
};
|
|
670
678
|
let vocabularyLoadPromise;
|
|
671
|
-
export const loadDefaultVocabulary =
|
|
679
|
+
export const loadDefaultVocabulary = options => {
|
|
680
|
+
var _options$isLocalLLM2;
|
|
672
681
|
if (isInitialized) {
|
|
673
682
|
return Promise.resolve();
|
|
674
683
|
}
|
|
675
684
|
if (vocabularyLoadPromise) {
|
|
676
685
|
return vocabularyLoadPromise;
|
|
677
686
|
}
|
|
687
|
+
const isLocalLLM = (_options$isLocalLLM2 = options === null || options === void 0 ? void 0 : options.isLocalLLM) !== null && _options$isLocalLLM2 !== void 0 ? _options$isLocalLLM2 : false;
|
|
678
688
|
vocabularyLoadPromise = (async () => {
|
|
679
|
-
startExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton'
|
|
689
|
+
startExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
|
|
690
|
+
isLocalLLM
|
|
691
|
+
});
|
|
680
692
|
try {
|
|
681
693
|
// The L2 vocabulary and L3 word list are code-split into their own async
|
|
682
694
|
// chunks so they stay out of the editor's main bundle.
|
|
@@ -701,11 +713,13 @@ export const loadDefaultVocabulary = () => {
|
|
|
701
713
|
terms
|
|
702
714
|
});
|
|
703
715
|
succeedExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
|
|
716
|
+
isLocalLLM,
|
|
704
717
|
l2WordCount: terms.length,
|
|
705
718
|
l3WordCount: l3VocabularyData.length
|
|
706
719
|
});
|
|
707
720
|
} catch (e) {
|
|
708
721
|
failExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
|
|
722
|
+
isLocalLLM,
|
|
709
723
|
errorType: 'parse_error'
|
|
710
724
|
});
|
|
711
725
|
// Allow a later call to retry the load rather than caching the failure.
|
|
@@ -576,13 +576,17 @@ export var createAutocompletePlugin = function createAutocompletePlugin(options,
|
|
|
576
576
|
return false;
|
|
577
577
|
},
|
|
578
578
|
focus: function focus() {
|
|
579
|
-
|
|
579
|
+
var _options$useLocalMode, _options$useLocalMode2;
|
|
580
|
+
loadDefaultVocabulary({
|
|
581
|
+
isLocalLLM: (_options$useLocalMode = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode !== void 0 ? _options$useLocalMode : false
|
|
582
|
+
}).catch(function (error) {
|
|
580
583
|
logException(error, {
|
|
581
584
|
location: 'editor-plugin-autocomplete/loadDefaultVocabulary'
|
|
582
585
|
});
|
|
583
586
|
});
|
|
584
587
|
loadVectorsAsync({
|
|
585
|
-
getBinaryUrl: options === null || options === void 0 ? void 0 : options.getVectorsBinaryUrl
|
|
588
|
+
getBinaryUrl: options === null || options === void 0 ? void 0 : options.getVectorsBinaryUrl,
|
|
589
|
+
isLocalLLM: (_options$useLocalMode2 = options === null || options === void 0 ? void 0 : options.useLocalModel) !== null && _options$useLocalMode2 !== void 0 ? _options$useLocalMode2 : false
|
|
586
590
|
}).catch(function (error) {
|
|
587
591
|
logException(error, {
|
|
588
592
|
location: 'editor-plugin-autocomplete/loadVectorsAsync'
|
|
@@ -755,7 +755,9 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
|
|
|
755
755
|
if (lower.includes('loading chunk') || lower.includes('dynamically imported module') || lower.includes('dynamic import')) {
|
|
756
756
|
return 'module_load_failed';
|
|
757
757
|
}
|
|
758
|
-
if (lower.includes('out of memory') ||
|
|
758
|
+
if (lower.includes('out of memory') ||
|
|
759
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
760
|
+
/\boom\b/.test(lower) || lower.includes('allocation') || lower.includes('exceeds') || lower.includes('buffer size') || lower.includes('not enough memory')) {
|
|
759
761
|
return 'insufficient_memory';
|
|
760
762
|
}
|
|
761
763
|
// Pre-flight already returns missing_shader_f16 when the feature is absent,
|
|
@@ -729,7 +729,8 @@ var unwrapJsonModule = function unwrapJsonModule(mod, shape) {
|
|
|
729
729
|
};
|
|
730
730
|
export var loadVectorsAsync = /*#__PURE__*/function () {
|
|
731
731
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
732
|
-
var
|
|
732
|
+
var _options$isLocalLLM;
|
|
733
|
+
var isLocalLLM, url, _wordIndexOuter$index, res, buffer, float32, wordIndexModule, wordIndexOuter, wordIndex, nWords, dim, _t, _t2;
|
|
733
734
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
734
735
|
while (1) switch (_context.prev = _context.next) {
|
|
735
736
|
case 0:
|
|
@@ -747,8 +748,11 @@ export var loadVectorsAsync = /*#__PURE__*/function () {
|
|
|
747
748
|
console.warn('[text-predictor] loadVectorsAsync called without a getBinaryUrl — vectors will not load. Pass getVectorsBinaryUrl via plugin options.');
|
|
748
749
|
return _context.abrupt("return");
|
|
749
750
|
case 2:
|
|
751
|
+
isLocalLLM = (_options$isLocalLLM = options === null || options === void 0 ? void 0 : options.isLocalLLM) !== null && _options$isLocalLLM !== void 0 ? _options$isLocalLLM : false;
|
|
750
752
|
vectorsLoadStarted = true;
|
|
751
|
-
startExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton'
|
|
753
|
+
startExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
754
|
+
isLocalLLM: isLocalLLM
|
|
755
|
+
});
|
|
752
756
|
_context.prev = 3;
|
|
753
757
|
_context.next = 4;
|
|
754
758
|
return options.getBinaryUrl();
|
|
@@ -761,6 +765,7 @@ export var loadVectorsAsync = /*#__PURE__*/function () {
|
|
|
761
765
|
_t = _context["catch"](3);
|
|
762
766
|
vectorsLoadStarted = false;
|
|
763
767
|
failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
768
|
+
isLocalLLM: isLocalLLM,
|
|
764
769
|
errorType: 'resolve_url'
|
|
765
770
|
});
|
|
766
771
|
// eslint-disable-next-line no-console
|
|
@@ -778,6 +783,7 @@ export var loadVectorsAsync = /*#__PURE__*/function () {
|
|
|
778
783
|
}
|
|
779
784
|
vectorsLoadStarted = false;
|
|
780
785
|
failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
786
|
+
isLocalLLM: isLocalLLM,
|
|
781
787
|
status: res.status,
|
|
782
788
|
errorType: 'http_error'
|
|
783
789
|
});
|
|
@@ -810,6 +816,7 @@ export var loadVectorsAsync = /*#__PURE__*/function () {
|
|
|
810
816
|
dim: dim
|
|
811
817
|
};
|
|
812
818
|
succeedExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
819
|
+
isLocalLLM: isLocalLLM,
|
|
813
820
|
wordCount: nWords,
|
|
814
821
|
dim: dim,
|
|
815
822
|
sizeBytes: float32.byteLength
|
|
@@ -829,6 +836,7 @@ export var loadVectorsAsync = /*#__PURE__*/function () {
|
|
|
829
836
|
_t2 = _context["catch"](6);
|
|
830
837
|
vectorsLoadStarted = false;
|
|
831
838
|
failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
839
|
+
isLocalLLM: isLocalLLM,
|
|
832
840
|
errorType: 'network'
|
|
833
841
|
});
|
|
834
842
|
// eslint-disable-next-line no-console
|
|
@@ -847,19 +855,23 @@ export var initVectors = function initVectors(store) {
|
|
|
847
855
|
vectorStore = store;
|
|
848
856
|
};
|
|
849
857
|
var vocabularyLoadPromise;
|
|
850
|
-
export var loadDefaultVocabulary = function loadDefaultVocabulary() {
|
|
858
|
+
export var loadDefaultVocabulary = function loadDefaultVocabulary(options) {
|
|
859
|
+
var _options$isLocalLLM2;
|
|
851
860
|
if (isInitialized) {
|
|
852
861
|
return Promise.resolve();
|
|
853
862
|
}
|
|
854
863
|
if (vocabularyLoadPromise) {
|
|
855
864
|
return vocabularyLoadPromise;
|
|
856
865
|
}
|
|
866
|
+
var isLocalLLM = (_options$isLocalLLM2 = options === null || options === void 0 ? void 0 : options.isLocalLLM) !== null && _options$isLocalLLM2 !== void 0 ? _options$isLocalLLM2 : false;
|
|
857
867
|
vocabularyLoadPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
858
868
|
var _yield$Promise$all, _yield$Promise$all2, vocabularyModule, l3VocabularyModule, vocabularyData, l3VocabularyData, terms, _t3;
|
|
859
869
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
860
870
|
while (1) switch (_context2.prev = _context2.next) {
|
|
861
871
|
case 0:
|
|
862
|
-
startExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton'
|
|
872
|
+
startExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
|
|
873
|
+
isLocalLLM: isLocalLLM
|
|
874
|
+
});
|
|
863
875
|
_context2.prev = 1;
|
|
864
876
|
_context2.next = 2;
|
|
865
877
|
return Promise.all([import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-autocomplete-vocabulary-10k" */'./data/vocabulary_10k.json'), import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-autocomplete-l3-vocabulary" */'./data/l3_vocabulary.json')]);
|
|
@@ -894,6 +906,7 @@ export var loadDefaultVocabulary = function loadDefaultVocabulary() {
|
|
|
894
906
|
terms: terms
|
|
895
907
|
});
|
|
896
908
|
succeedExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
|
|
909
|
+
isLocalLLM: isLocalLLM,
|
|
897
910
|
l2WordCount: terms.length,
|
|
898
911
|
l3WordCount: l3VocabularyData.length
|
|
899
912
|
});
|
|
@@ -903,6 +916,7 @@ export var loadDefaultVocabulary = function loadDefaultVocabulary() {
|
|
|
903
916
|
_context2.prev = 4;
|
|
904
917
|
_t3 = _context2["catch"](1);
|
|
905
918
|
failExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
|
|
919
|
+
isLocalLLM: isLocalLLM,
|
|
906
920
|
errorType: 'parse_error'
|
|
907
921
|
});
|
|
908
922
|
// Allow a later call to retry the load rather than caching the failure.
|
|
@@ -96,10 +96,10 @@ export interface LocalSlowLaneClient {
|
|
|
96
96
|
export type LocalSlowLaneLoadErrorReason = 'webgpu_unavailable' | 'webgpu_no_adapter' | 'missing_shader_f16' | 'insufficient_memory' | 'model_download_failed' | 'module_load_failed' | 'init_failed';
|
|
97
97
|
/** Snapshot of the machine's WebGPU support, used to explain hardware limits. */
|
|
98
98
|
export interface WebGpuCapabilities {
|
|
99
|
-
/** GPU architecture reported by the adapter (e.g. "metal-3", "rdna2"). */
|
|
100
|
-
architecture?: string;
|
|
101
99
|
/** Whether `navigator.gpu.requestAdapter()` returned a usable adapter. */
|
|
102
100
|
adapterAvailable?: boolean;
|
|
101
|
+
/** GPU architecture reported by the adapter (e.g. "metal-3", "rdna2"). */
|
|
102
|
+
architecture?: string;
|
|
103
103
|
/** Whether `navigator.gpu` exists at all. */
|
|
104
104
|
available: boolean;
|
|
105
105
|
/** Largest single GPU buffer the adapter allows, in MB. */
|
|
@@ -82,7 +82,10 @@ export declare const ingestDocumentPage: (pageContent: string | undefined) => vo
|
|
|
82
82
|
export declare const predict: (textBefore: string) => string | null;
|
|
83
83
|
export declare const loadVectorsAsync: (options?: {
|
|
84
84
|
getBinaryUrl?: () => Promise<string>;
|
|
85
|
+
isLocalLLM?: boolean;
|
|
85
86
|
}) => Promise<void>;
|
|
86
87
|
export declare const initVectors: (store: VectorStore) => void;
|
|
87
|
-
export declare const loadDefaultVocabulary: (
|
|
88
|
+
export declare const loadDefaultVocabulary: (options?: {
|
|
89
|
+
isLocalLLM?: boolean;
|
|
90
|
+
}) => Promise<void>;
|
|
88
91
|
export {};
|
|
@@ -96,10 +96,10 @@ export interface LocalSlowLaneClient {
|
|
|
96
96
|
export type LocalSlowLaneLoadErrorReason = 'webgpu_unavailable' | 'webgpu_no_adapter' | 'missing_shader_f16' | 'insufficient_memory' | 'model_download_failed' | 'module_load_failed' | 'init_failed';
|
|
97
97
|
/** Snapshot of the machine's WebGPU support, used to explain hardware limits. */
|
|
98
98
|
export interface WebGpuCapabilities {
|
|
99
|
-
/** GPU architecture reported by the adapter (e.g. "metal-3", "rdna2"). */
|
|
100
|
-
architecture?: string;
|
|
101
99
|
/** Whether `navigator.gpu.requestAdapter()` returned a usable adapter. */
|
|
102
100
|
adapterAvailable?: boolean;
|
|
101
|
+
/** GPU architecture reported by the adapter (e.g. "metal-3", "rdna2"). */
|
|
102
|
+
architecture?: string;
|
|
103
103
|
/** Whether `navigator.gpu` exists at all. */
|
|
104
104
|
available: boolean;
|
|
105
105
|
/** Largest single GPU buffer the adapter allows, in MB. */
|
|
@@ -82,7 +82,10 @@ export declare const ingestDocumentPage: (pageContent: string | undefined) => vo
|
|
|
82
82
|
export declare const predict: (textBefore: string) => string | null;
|
|
83
83
|
export declare const loadVectorsAsync: (options?: {
|
|
84
84
|
getBinaryUrl?: () => Promise<string>;
|
|
85
|
+
isLocalLLM?: boolean;
|
|
85
86
|
}) => Promise<void>;
|
|
86
87
|
export declare const initVectors: (store: VectorStore) => void;
|
|
87
|
-
export declare const loadDefaultVocabulary: (
|
|
88
|
+
export declare const loadDefaultVocabulary: (options?: {
|
|
89
|
+
isLocalLLM?: boolean;
|
|
90
|
+
}) => Promise<void>;
|
|
88
91
|
export {};
|
package/package.json
CHANGED
|
@@ -680,17 +680,20 @@ export const createAutocompletePlugin = (
|
|
|
680
680
|
}
|
|
681
681
|
return false;
|
|
682
682
|
},
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
});
|
|
683
|
+
focus: () => {
|
|
684
|
+
loadDefaultVocabulary({ isLocalLLM: options?.useLocalModel ?? false }).catch((error) => {
|
|
685
|
+
logException(error as Error, {
|
|
686
|
+
location: 'editor-plugin-autocomplete/loadDefaultVocabulary',
|
|
688
687
|
});
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
688
|
+
});
|
|
689
|
+
loadVectorsAsync({
|
|
690
|
+
getBinaryUrl: options?.getVectorsBinaryUrl,
|
|
691
|
+
isLocalLLM: options?.useLocalModel ?? false,
|
|
692
|
+
}).catch((error) => {
|
|
693
|
+
logException(error as Error, {
|
|
694
|
+
location: 'editor-plugin-autocomplete/loadVectorsAsync',
|
|
693
695
|
});
|
|
696
|
+
});
|
|
694
697
|
if (!hasIngestedPage) {
|
|
695
698
|
hasIngestedPage = true;
|
|
696
699
|
refreshContext({
|
|
@@ -114,10 +114,10 @@ export type LocalSlowLaneLoadErrorReason =
|
|
|
114
114
|
|
|
115
115
|
/** Snapshot of the machine's WebGPU support, used to explain hardware limits. */
|
|
116
116
|
export interface WebGpuCapabilities {
|
|
117
|
-
/** GPU architecture reported by the adapter (e.g. "metal-3", "rdna2"). */
|
|
118
|
-
architecture?: string;
|
|
119
117
|
/** Whether `navigator.gpu.requestAdapter()` returned a usable adapter. */
|
|
120
118
|
adapterAvailable?: boolean;
|
|
119
|
+
/** GPU architecture reported by the adapter (e.g. "metal-3", "rdna2"). */
|
|
120
|
+
architecture?: string;
|
|
121
121
|
/** Whether `navigator.gpu` exists at all. */
|
|
122
122
|
available: boolean;
|
|
123
123
|
/** Largest single GPU buffer the adapter allows, in MB. */
|
|
@@ -773,7 +773,8 @@ export const createLocalSlowLaneClient = (
|
|
|
773
773
|
}
|
|
774
774
|
if (
|
|
775
775
|
lower.includes('out of memory') ||
|
|
776
|
-
|
|
776
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
777
|
+
/\boom\b/.test(lower) ||
|
|
777
778
|
lower.includes('allocation') ||
|
|
778
779
|
lower.includes('exceeds') ||
|
|
779
780
|
lower.includes('buffer size') ||
|
|
@@ -747,6 +747,7 @@ const unwrapJsonModule = <T>(mod: unknown, shape: 'object' | 'array'): T | null
|
|
|
747
747
|
|
|
748
748
|
export const loadVectorsAsync = async (options?: {
|
|
749
749
|
getBinaryUrl?: () => Promise<string>;
|
|
750
|
+
isLocalLLM?: boolean;
|
|
750
751
|
}): Promise<void> => {
|
|
751
752
|
if (vectorStore || vectorsLoadStarted) {
|
|
752
753
|
return;
|
|
@@ -758,15 +759,16 @@ export const loadVectorsAsync = async (options?: {
|
|
|
758
759
|
);
|
|
759
760
|
return;
|
|
760
761
|
}
|
|
762
|
+
const isLocalLLM = options?.isLocalLLM ?? false;
|
|
761
763
|
vectorsLoadStarted = true;
|
|
762
|
-
startExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton');
|
|
764
|
+
startExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', { isLocalLLM });
|
|
763
765
|
|
|
764
766
|
let url: string;
|
|
765
767
|
try {
|
|
766
768
|
url = await options.getBinaryUrl();
|
|
767
769
|
} catch (e) {
|
|
768
770
|
vectorsLoadStarted = false;
|
|
769
|
-
failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', { errorType: 'resolve_url' });
|
|
771
|
+
failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', { isLocalLLM, errorType: 'resolve_url' });
|
|
770
772
|
// eslint-disable-next-line no-console
|
|
771
773
|
console.warn('[text-predictor] Failed to resolve vectors URL:', e);
|
|
772
774
|
return;
|
|
@@ -777,6 +779,7 @@ export const loadVectorsAsync = async (options?: {
|
|
|
777
779
|
if (!res.ok) {
|
|
778
780
|
vectorsLoadStarted = false;
|
|
779
781
|
failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
782
|
+
isLocalLLM,
|
|
780
783
|
status: res.status,
|
|
781
784
|
errorType: 'http_error',
|
|
782
785
|
});
|
|
@@ -809,6 +812,7 @@ export const loadVectorsAsync = async (options?: {
|
|
|
809
812
|
|
|
810
813
|
vectorStore = { float32, wordIndex, dim };
|
|
811
814
|
succeedExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
|
|
815
|
+
isLocalLLM,
|
|
812
816
|
wordCount: nWords,
|
|
813
817
|
dim,
|
|
814
818
|
sizeBytes: float32.byteLength,
|
|
@@ -823,7 +827,7 @@ export const loadVectorsAsync = async (options?: {
|
|
|
823
827
|
}
|
|
824
828
|
} catch (e) {
|
|
825
829
|
vectorsLoadStarted = false;
|
|
826
|
-
failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', { errorType: 'network' });
|
|
830
|
+
failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', { isLocalLLM, errorType: 'network' });
|
|
827
831
|
// eslint-disable-next-line no-console
|
|
828
832
|
console.warn('[text-predictor] Failed to load vectors:', e);
|
|
829
833
|
}
|
|
@@ -835,7 +839,7 @@ export const initVectors = (store: VectorStore): void => {
|
|
|
835
839
|
|
|
836
840
|
let vocabularyLoadPromise: Promise<void> | undefined;
|
|
837
841
|
|
|
838
|
-
export const loadDefaultVocabulary = (): Promise<void> => {
|
|
842
|
+
export const loadDefaultVocabulary = (options?: { isLocalLLM?: boolean }): Promise<void> => {
|
|
839
843
|
if (isInitialized) {
|
|
840
844
|
return Promise.resolve();
|
|
841
845
|
}
|
|
@@ -843,8 +847,9 @@ export const loadDefaultVocabulary = (): Promise<void> => {
|
|
|
843
847
|
return vocabularyLoadPromise;
|
|
844
848
|
}
|
|
845
849
|
|
|
850
|
+
const isLocalLLM = options?.isLocalLLM ?? false;
|
|
846
851
|
vocabularyLoadPromise = (async () => {
|
|
847
|
-
startExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton');
|
|
852
|
+
startExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', { isLocalLLM });
|
|
848
853
|
|
|
849
854
|
try {
|
|
850
855
|
// The L2 vocabulary and L3 word list are code-split into their own async
|
|
@@ -879,11 +884,12 @@ export const loadDefaultVocabulary = (): Promise<void> => {
|
|
|
879
884
|
initVocabulary({ terms });
|
|
880
885
|
|
|
881
886
|
succeedExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
|
|
887
|
+
isLocalLLM,
|
|
882
888
|
l2WordCount: terms.length,
|
|
883
889
|
l3WordCount: l3VocabularyData.length,
|
|
884
890
|
});
|
|
885
891
|
} catch (e) {
|
|
886
|
-
failExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', { errorType: 'parse_error' });
|
|
892
|
+
failExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', { isLocalLLM, errorType: 'parse_error' });
|
|
887
893
|
// Allow a later call to retry the load rather than caching the failure.
|
|
888
894
|
vocabularyLoadPromise = undefined;
|
|
889
895
|
throw e;
|