@websolutespa/bom-llm 2.0.1 → 2.0.3
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 +13 -0
- package/dist/esm/index.js +63 -25
- package/dist/esm/index.js.map +1 -1
- package/dist/umd/index.js +63 -25
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -2
package/dist/umd/index.js
CHANGED
|
@@ -19902,7 +19902,8 @@
|
|
|
19902
19902
|
embedded,
|
|
19903
19903
|
portal,
|
|
19904
19904
|
send,
|
|
19905
|
-
setEmbed
|
|
19905
|
+
setEmbed,
|
|
19906
|
+
setCurrentContext
|
|
19906
19907
|
} = _ref;
|
|
19907
19908
|
const props = {
|
|
19908
19909
|
opened: opened != null ? opened : embedded != null || threadId != null ? true : false,
|
|
@@ -20065,12 +20066,20 @@
|
|
|
20065
20066
|
}
|
|
20066
20067
|
});
|
|
20067
20068
|
},
|
|
20068
|
-
open:
|
|
20069
|
+
open: openingContext => {
|
|
20069
20070
|
setIdleTimeout();
|
|
20070
20071
|
set(state => {
|
|
20071
20072
|
const opened = !state.opened;
|
|
20073
|
+
if (opened) {
|
|
20074
|
+
state.openingContext = openingContext;
|
|
20075
|
+
setCurrentContext(openingContext ? {
|
|
20076
|
+
context: openingContext,
|
|
20077
|
+
title: 'opening-context'
|
|
20078
|
+
} : undefined);
|
|
20079
|
+
}
|
|
20072
20080
|
pushDataLayer({
|
|
20073
|
-
event: opened ? 'llm_open' : 'llm_close'
|
|
20081
|
+
event: opened ? state.openingContext ? 'llm_open_context' : 'llm_open' : 'llm_close',
|
|
20082
|
+
...(state.openingContext || {})
|
|
20074
20083
|
});
|
|
20075
20084
|
persistMinimized(false);
|
|
20076
20085
|
return {
|
|
@@ -20085,11 +20094,19 @@
|
|
|
20085
20094
|
} = get();
|
|
20086
20095
|
return opened;
|
|
20087
20096
|
},
|
|
20088
|
-
setOpened: opened => {
|
|
20097
|
+
setOpened: (opened, openingContext) => {
|
|
20089
20098
|
setIdleTimeout();
|
|
20090
20099
|
set(state => {
|
|
20100
|
+
if (opened) {
|
|
20101
|
+
state.openingContext = openingContext;
|
|
20102
|
+
setCurrentContext(openingContext ? {
|
|
20103
|
+
context: openingContext,
|
|
20104
|
+
title: 'opening-context'
|
|
20105
|
+
} : undefined);
|
|
20106
|
+
}
|
|
20091
20107
|
pushDataLayer({
|
|
20092
|
-
event: opened ? 'llm_open' : 'llm_close'
|
|
20108
|
+
event: opened ? state.openingContext ? 'llm_open_context' : 'llm_open' : 'llm_close',
|
|
20109
|
+
...(state.openingContext || {})
|
|
20093
20110
|
});
|
|
20094
20111
|
return {
|
|
20095
20112
|
opened
|
|
@@ -20156,14 +20173,16 @@
|
|
|
20156
20173
|
} = _ref2;
|
|
20157
20174
|
const {
|
|
20158
20175
|
send,
|
|
20159
|
-
setEmbed
|
|
20176
|
+
setEmbed,
|
|
20177
|
+
setCurrentContext
|
|
20160
20178
|
} = useLlm(state => state.actions);
|
|
20161
20179
|
const storeRef = reactExports.useRef();
|
|
20162
20180
|
if (!storeRef.current) {
|
|
20163
20181
|
storeRef.current = createLlmViewStore({
|
|
20164
20182
|
...props,
|
|
20165
20183
|
send,
|
|
20166
|
-
setEmbed
|
|
20184
|
+
setEmbed,
|
|
20185
|
+
setCurrentContext
|
|
20167
20186
|
});
|
|
20168
20187
|
}
|
|
20169
20188
|
return storeRef.current && /*#__PURE__*/jsxRuntimeExports.jsx(LlmViewContext.Provider, {
|
|
@@ -32785,11 +32804,19 @@ void main(void) {
|
|
|
32785
32804
|
});
|
|
32786
32805
|
};
|
|
32787
32806
|
|
|
32807
|
+
const IntroContext = () => {
|
|
32808
|
+
const {
|
|
32809
|
+
Intro
|
|
32810
|
+
} = useLlm(state => state.components);
|
|
32811
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(Intro, {});
|
|
32812
|
+
};
|
|
32813
|
+
|
|
32788
32814
|
const Main = () => {
|
|
32789
32815
|
const {
|
|
32790
32816
|
Canvas,
|
|
32791
32817
|
Header,
|
|
32792
32818
|
Intro,
|
|
32819
|
+
IntroContext,
|
|
32793
32820
|
Prompt,
|
|
32794
32821
|
Scroller,
|
|
32795
32822
|
ScrollProposition,
|
|
@@ -32798,6 +32825,7 @@ void main(void) {
|
|
|
32798
32825
|
const app = useLlm(state => state.app);
|
|
32799
32826
|
const theme = useLlm(state => state.theme);
|
|
32800
32827
|
const messages = useLlm(state => state.messages);
|
|
32828
|
+
const openingContext = useLlmView(state => state.openingContext);
|
|
32801
32829
|
const introed = useLlmView(state => state.introed);
|
|
32802
32830
|
const visible = useLlmView(state => state.visible);
|
|
32803
32831
|
const embedded = useLlmView(state => state.embedded);
|
|
@@ -32881,7 +32909,7 @@ void main(void) {
|
|
|
32881
32909
|
initial: "hidden",
|
|
32882
32910
|
animate: "show",
|
|
32883
32911
|
className: "llm__content",
|
|
32884
|
-
children: [/*#__PURE__*/jsxRuntimeExports.jsx(Intro, {}), messages && messages.length > 0 && /*#__PURE__*/jsxRuntimeExports.jsx(Thread, {})]
|
|
32912
|
+
children: [openingContext ? /*#__PURE__*/jsxRuntimeExports.jsx(IntroContext, {}) : /*#__PURE__*/jsxRuntimeExports.jsx(Intro, {}), messages && messages.length > 0 && /*#__PURE__*/jsxRuntimeExports.jsx(Thread, {})]
|
|
32885
32913
|
})
|
|
32886
32914
|
}), shouldShowPrompt && /*#__PURE__*/jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
|
|
32887
32915
|
children: [app && !theme.canvas?.enabled && /*#__PURE__*/jsxRuntimeExports.jsx("div", {
|
|
@@ -42176,6 +42204,7 @@ void main(void) {
|
|
|
42176
42204
|
const Suggestions = () => {
|
|
42177
42205
|
useWindowSize();
|
|
42178
42206
|
const app = useLlm(state => state.app);
|
|
42207
|
+
const openingContext = useLlmView(state => state.openingContext);
|
|
42179
42208
|
const {
|
|
42180
42209
|
send
|
|
42181
42210
|
} = useLlmView(state => state.actions);
|
|
@@ -42186,6 +42215,9 @@ void main(void) {
|
|
|
42186
42215
|
// console.log('Suggestions.onEnd', response);
|
|
42187
42216
|
});
|
|
42188
42217
|
};
|
|
42218
|
+
if (openingContext) {
|
|
42219
|
+
return;
|
|
42220
|
+
}
|
|
42189
42221
|
const sampleInputTexts = app?.contents.sampleInputTexts;
|
|
42190
42222
|
return /*#__PURE__*/jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {
|
|
42191
42223
|
children: sampleInputTexts && sampleInputTexts.length > 0 && /*#__PURE__*/jsxRuntimeExports.jsx("section", {
|
|
@@ -42380,6 +42412,7 @@ void main(void) {
|
|
|
42380
42412
|
Header,
|
|
42381
42413
|
Hints,
|
|
42382
42414
|
Intro,
|
|
42415
|
+
IntroContext,
|
|
42383
42416
|
Main,
|
|
42384
42417
|
PageActions,
|
|
42385
42418
|
PageContext,
|
|
@@ -45665,7 +45698,7 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
45665
45698
|
currentContext,
|
|
45666
45699
|
systemContext: {
|
|
45667
45700
|
...systemContext,
|
|
45668
|
-
...currentContext
|
|
45701
|
+
...currentContext?.context
|
|
45669
45702
|
}
|
|
45670
45703
|
}));
|
|
45671
45704
|
},
|
|
@@ -46044,17 +46077,17 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
46044
46077
|
const embedded = useLlmView(state => state.embedded);
|
|
46045
46078
|
const imperative = useLlmView(state => state.imperative);
|
|
46046
46079
|
const instance = reactExports.useMemo(() => ({
|
|
46047
|
-
open:
|
|
46048
|
-
open();
|
|
46080
|
+
open: openingContext => {
|
|
46081
|
+
open(openingContext);
|
|
46049
46082
|
},
|
|
46050
46083
|
isOpened: () => {
|
|
46051
46084
|
return isOpened();
|
|
46052
46085
|
},
|
|
46053
|
-
setOpened: opened => {
|
|
46054
|
-
setOpened(opened);
|
|
46086
|
+
setOpened: (opened, openingContext) => {
|
|
46087
|
+
setOpened(opened, openingContext);
|
|
46055
46088
|
},
|
|
46056
|
-
send: message => {
|
|
46057
|
-
setOpened(true);
|
|
46089
|
+
send: (message, openingContext) => {
|
|
46090
|
+
setOpened(true, openingContext);
|
|
46058
46091
|
send(message);
|
|
46059
46092
|
},
|
|
46060
46093
|
clear: () => {
|
|
@@ -46480,7 +46513,7 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
46480
46513
|
const defaultEndpoint = typeof props.test !== 'undefined' ? 'https://bom-sample-basic-web-git-bom-llm-actarian.vercel.app' : 'https://platform.websolute.ai';
|
|
46481
46514
|
const endpoint = props.endpoint || defaultEndpoint;
|
|
46482
46515
|
const layout = {
|
|
46483
|
-
labels: getLabels(data.locale, defaultLabels, props.labels),
|
|
46516
|
+
labels: getLabels(data.locale, defaultLabels, props.pluginLabels, props.labels),
|
|
46484
46517
|
locale: data.locale,
|
|
46485
46518
|
locales: [{
|
|
46486
46519
|
id: data.locale,
|
|
@@ -46551,12 +46584,16 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
46551
46584
|
})
|
|
46552
46585
|
});
|
|
46553
46586
|
};
|
|
46554
|
-
function getLabels(locale, defaultLabels,
|
|
46555
|
-
if (
|
|
46556
|
-
|
|
46587
|
+
function getLabels(locale, defaultLabels, pluginLabels, externalLabels) {
|
|
46588
|
+
if (pluginLabels === void 0) {
|
|
46589
|
+
pluginLabels = [];
|
|
46590
|
+
}
|
|
46591
|
+
if (externalLabels === void 0) {
|
|
46592
|
+
externalLabels = [];
|
|
46557
46593
|
}
|
|
46558
|
-
const labels = [...defaultLabels.filter(x =>
|
|
46559
|
-
|
|
46594
|
+
const labels = [...defaultLabels.filter(x => pluginLabels.findIndex(e => e.id === x.id) === -1), ...pluginLabels];
|
|
46595
|
+
const finalLabels = [...labels.filter(x => externalLabels.findIndex(e => e.id === x.id) === -1), ...externalLabels];
|
|
46596
|
+
return finalLabels.map(x => {
|
|
46560
46597
|
const localizedItem = localizeItem(x, locale, 'en');
|
|
46561
46598
|
return {
|
|
46562
46599
|
id: localizedItem.id,
|
|
@@ -46705,7 +46742,7 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
46705
46742
|
return element != null && typeof element[Symbol.iterator] === 'function';
|
|
46706
46743
|
}
|
|
46707
46744
|
|
|
46708
|
-
function getInitializer(globalName, plugins) {
|
|
46745
|
+
function getInitializer(globalName, plugins, pluginLabels) {
|
|
46709
46746
|
if (globalName === void 0) {
|
|
46710
46747
|
globalName = 'bomLlm';
|
|
46711
46748
|
}
|
|
@@ -46718,23 +46755,24 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
46718
46755
|
return;
|
|
46719
46756
|
}
|
|
46720
46757
|
props.plugins = [...(props.plugins || []), ...(plugins || [])];
|
|
46758
|
+
props.pluginLabels = pluginLabels;
|
|
46721
46759
|
const id = toKebabCase(globalName);
|
|
46722
46760
|
const node = document.createElement('div');
|
|
46723
46761
|
node.setAttribute('id', id);
|
|
46724
46762
|
body.appendChild(node);
|
|
46725
46763
|
const initError = 'llm plugin is not initialized';
|
|
46726
46764
|
const llmInstance = {
|
|
46727
|
-
open:
|
|
46765
|
+
open: openingContext => {
|
|
46728
46766
|
console.log(initError);
|
|
46729
46767
|
},
|
|
46730
|
-
setOpened: opened => {
|
|
46768
|
+
setOpened: (opened, openingContext) => {
|
|
46731
46769
|
console.log(initError);
|
|
46732
46770
|
},
|
|
46733
46771
|
isOpened: () => {
|
|
46734
46772
|
console.log(initError);
|
|
46735
46773
|
return false;
|
|
46736
46774
|
},
|
|
46737
|
-
send: message => {
|
|
46775
|
+
send: (message, openingContext) => {
|
|
46738
46776
|
console.log(initError);
|
|
46739
46777
|
},
|
|
46740
46778
|
clear: () => {
|