@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @websolutespa/bom-llm
|
|
2
2
|
|
|
3
|
+
## 2.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added: setCurrentContext with openingContext
|
|
8
|
+
|
|
9
|
+
## 2.0.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Added: openingContext & IntroContext
|
|
14
|
+
- 71f0616: Added: pluginLabels
|
|
15
|
+
|
|
3
16
|
## 2.0.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/esm/index.js
CHANGED
|
@@ -19896,7 +19896,8 @@ const createLlmViewStore = _ref => {
|
|
|
19896
19896
|
embedded,
|
|
19897
19897
|
portal,
|
|
19898
19898
|
send,
|
|
19899
|
-
setEmbed
|
|
19899
|
+
setEmbed,
|
|
19900
|
+
setCurrentContext
|
|
19900
19901
|
} = _ref;
|
|
19901
19902
|
const props = {
|
|
19902
19903
|
opened: opened != null ? opened : embedded != null || threadId != null ? true : false,
|
|
@@ -20059,12 +20060,20 @@ const createLlmViewStore = _ref => {
|
|
|
20059
20060
|
}
|
|
20060
20061
|
});
|
|
20061
20062
|
},
|
|
20062
|
-
open:
|
|
20063
|
+
open: openingContext => {
|
|
20063
20064
|
setIdleTimeout();
|
|
20064
20065
|
set(state => {
|
|
20065
20066
|
const opened = !state.opened;
|
|
20067
|
+
if (opened) {
|
|
20068
|
+
state.openingContext = openingContext;
|
|
20069
|
+
setCurrentContext(openingContext ? {
|
|
20070
|
+
context: openingContext,
|
|
20071
|
+
title: 'opening-context'
|
|
20072
|
+
} : undefined);
|
|
20073
|
+
}
|
|
20066
20074
|
pushDataLayer({
|
|
20067
|
-
event: opened ? 'llm_open' : 'llm_close'
|
|
20075
|
+
event: opened ? state.openingContext ? 'llm_open_context' : 'llm_open' : 'llm_close',
|
|
20076
|
+
...(state.openingContext || {})
|
|
20068
20077
|
});
|
|
20069
20078
|
persistMinimized(false);
|
|
20070
20079
|
return {
|
|
@@ -20079,11 +20088,19 @@ const createLlmViewStore = _ref => {
|
|
|
20079
20088
|
} = get();
|
|
20080
20089
|
return opened;
|
|
20081
20090
|
},
|
|
20082
|
-
setOpened: opened => {
|
|
20091
|
+
setOpened: (opened, openingContext) => {
|
|
20083
20092
|
setIdleTimeout();
|
|
20084
20093
|
set(state => {
|
|
20094
|
+
if (opened) {
|
|
20095
|
+
state.openingContext = openingContext;
|
|
20096
|
+
setCurrentContext(openingContext ? {
|
|
20097
|
+
context: openingContext,
|
|
20098
|
+
title: 'opening-context'
|
|
20099
|
+
} : undefined);
|
|
20100
|
+
}
|
|
20085
20101
|
pushDataLayer({
|
|
20086
|
-
event: opened ? 'llm_open' : 'llm_close'
|
|
20102
|
+
event: opened ? state.openingContext ? 'llm_open_context' : 'llm_open' : 'llm_close',
|
|
20103
|
+
...(state.openingContext || {})
|
|
20087
20104
|
});
|
|
20088
20105
|
return {
|
|
20089
20106
|
opened
|
|
@@ -20150,14 +20167,16 @@ function LlmViewProvider(_ref2) {
|
|
|
20150
20167
|
} = _ref2;
|
|
20151
20168
|
const {
|
|
20152
20169
|
send,
|
|
20153
|
-
setEmbed
|
|
20170
|
+
setEmbed,
|
|
20171
|
+
setCurrentContext
|
|
20154
20172
|
} = useLlm(state => state.actions);
|
|
20155
20173
|
const storeRef = reactExports.useRef();
|
|
20156
20174
|
if (!storeRef.current) {
|
|
20157
20175
|
storeRef.current = createLlmViewStore({
|
|
20158
20176
|
...props,
|
|
20159
20177
|
send,
|
|
20160
|
-
setEmbed
|
|
20178
|
+
setEmbed,
|
|
20179
|
+
setCurrentContext
|
|
20161
20180
|
});
|
|
20162
20181
|
}
|
|
20163
20182
|
return storeRef.current && /*#__PURE__*/jsxRuntimeExports.jsx(LlmViewContext.Provider, {
|
|
@@ -32779,11 +32798,19 @@ const Intro = () => {
|
|
|
32779
32798
|
});
|
|
32780
32799
|
};
|
|
32781
32800
|
|
|
32801
|
+
const IntroContext = () => {
|
|
32802
|
+
const {
|
|
32803
|
+
Intro
|
|
32804
|
+
} = useLlm(state => state.components);
|
|
32805
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(Intro, {});
|
|
32806
|
+
};
|
|
32807
|
+
|
|
32782
32808
|
const Main = () => {
|
|
32783
32809
|
const {
|
|
32784
32810
|
Canvas,
|
|
32785
32811
|
Header,
|
|
32786
32812
|
Intro,
|
|
32813
|
+
IntroContext,
|
|
32787
32814
|
Prompt,
|
|
32788
32815
|
Scroller,
|
|
32789
32816
|
ScrollProposition,
|
|
@@ -32792,6 +32819,7 @@ const Main = () => {
|
|
|
32792
32819
|
const app = useLlm(state => state.app);
|
|
32793
32820
|
const theme = useLlm(state => state.theme);
|
|
32794
32821
|
const messages = useLlm(state => state.messages);
|
|
32822
|
+
const openingContext = useLlmView(state => state.openingContext);
|
|
32795
32823
|
const introed = useLlmView(state => state.introed);
|
|
32796
32824
|
const visible = useLlmView(state => state.visible);
|
|
32797
32825
|
const embedded = useLlmView(state => state.embedded);
|
|
@@ -32875,7 +32903,7 @@ const Main = () => {
|
|
|
32875
32903
|
initial: "hidden",
|
|
32876
32904
|
animate: "show",
|
|
32877
32905
|
className: "llm__content",
|
|
32878
|
-
children: [/*#__PURE__*/jsxRuntimeExports.jsx(Intro, {}), messages && messages.length > 0 && /*#__PURE__*/jsxRuntimeExports.jsx(Thread, {})]
|
|
32906
|
+
children: [openingContext ? /*#__PURE__*/jsxRuntimeExports.jsx(IntroContext, {}) : /*#__PURE__*/jsxRuntimeExports.jsx(Intro, {}), messages && messages.length > 0 && /*#__PURE__*/jsxRuntimeExports.jsx(Thread, {})]
|
|
32879
32907
|
})
|
|
32880
32908
|
}), shouldShowPrompt && /*#__PURE__*/jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
|
|
32881
32909
|
children: [app && !theme.canvas?.enabled && /*#__PURE__*/jsxRuntimeExports.jsx("div", {
|
|
@@ -42170,6 +42198,7 @@ const Stream = _ref => {
|
|
|
42170
42198
|
const Suggestions = () => {
|
|
42171
42199
|
useWindowSize();
|
|
42172
42200
|
const app = useLlm(state => state.app);
|
|
42201
|
+
const openingContext = useLlmView(state => state.openingContext);
|
|
42173
42202
|
const {
|
|
42174
42203
|
send
|
|
42175
42204
|
} = useLlmView(state => state.actions);
|
|
@@ -42180,6 +42209,9 @@ const Suggestions = () => {
|
|
|
42180
42209
|
// console.log('Suggestions.onEnd', response);
|
|
42181
42210
|
});
|
|
42182
42211
|
};
|
|
42212
|
+
if (openingContext) {
|
|
42213
|
+
return;
|
|
42214
|
+
}
|
|
42183
42215
|
const sampleInputTexts = app?.contents.sampleInputTexts;
|
|
42184
42216
|
return /*#__PURE__*/jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {
|
|
42185
42217
|
children: sampleInputTexts && sampleInputTexts.length > 0 && /*#__PURE__*/jsxRuntimeExports.jsx("section", {
|
|
@@ -42374,6 +42406,7 @@ const LLM_COMPONENTS = {
|
|
|
42374
42406
|
Header,
|
|
42375
42407
|
Hints,
|
|
42376
42408
|
Intro,
|
|
42409
|
+
IntroContext,
|
|
42377
42410
|
Main,
|
|
42378
42411
|
PageActions,
|
|
42379
42412
|
PageContext,
|
|
@@ -45659,7 +45692,7 @@ const createLlmStore = config => {
|
|
|
45659
45692
|
currentContext,
|
|
45660
45693
|
systemContext: {
|
|
45661
45694
|
...systemContext,
|
|
45662
|
-
...currentContext
|
|
45695
|
+
...currentContext?.context
|
|
45663
45696
|
}
|
|
45664
45697
|
}));
|
|
45665
45698
|
},
|
|
@@ -46038,17 +46071,17 @@ const LlmComponent = /*#__PURE__*/reactExports.forwardRef((props, ref) => {
|
|
|
46038
46071
|
const embedded = useLlmView(state => state.embedded);
|
|
46039
46072
|
const imperative = useLlmView(state => state.imperative);
|
|
46040
46073
|
const instance = reactExports.useMemo(() => ({
|
|
46041
|
-
open:
|
|
46042
|
-
open();
|
|
46074
|
+
open: openingContext => {
|
|
46075
|
+
open(openingContext);
|
|
46043
46076
|
},
|
|
46044
46077
|
isOpened: () => {
|
|
46045
46078
|
return isOpened();
|
|
46046
46079
|
},
|
|
46047
|
-
setOpened: opened => {
|
|
46048
|
-
setOpened(opened);
|
|
46080
|
+
setOpened: (opened, openingContext) => {
|
|
46081
|
+
setOpened(opened, openingContext);
|
|
46049
46082
|
},
|
|
46050
|
-
send: message => {
|
|
46051
|
-
setOpened(true);
|
|
46083
|
+
send: (message, openingContext) => {
|
|
46084
|
+
setOpened(true, openingContext);
|
|
46052
46085
|
send(message);
|
|
46053
46086
|
},
|
|
46054
46087
|
clear: () => {
|
|
@@ -46474,7 +46507,7 @@ const App = _ref => {
|
|
|
46474
46507
|
const defaultEndpoint = typeof props.test !== 'undefined' ? 'https://bom-sample-basic-web-git-bom-llm-actarian.vercel.app' : 'https://platform.websolute.ai';
|
|
46475
46508
|
const endpoint = props.endpoint || defaultEndpoint;
|
|
46476
46509
|
const layout = {
|
|
46477
|
-
labels: getLabels(data.locale, defaultLabels, props.labels),
|
|
46510
|
+
labels: getLabels(data.locale, defaultLabels, props.pluginLabels, props.labels),
|
|
46478
46511
|
locale: data.locale,
|
|
46479
46512
|
locales: [{
|
|
46480
46513
|
id: data.locale,
|
|
@@ -46545,12 +46578,16 @@ const App = _ref => {
|
|
|
46545
46578
|
})
|
|
46546
46579
|
});
|
|
46547
46580
|
};
|
|
46548
|
-
function getLabels(locale, defaultLabels,
|
|
46549
|
-
if (
|
|
46550
|
-
|
|
46581
|
+
function getLabels(locale, defaultLabels, pluginLabels, externalLabels) {
|
|
46582
|
+
if (pluginLabels === void 0) {
|
|
46583
|
+
pluginLabels = [];
|
|
46584
|
+
}
|
|
46585
|
+
if (externalLabels === void 0) {
|
|
46586
|
+
externalLabels = [];
|
|
46551
46587
|
}
|
|
46552
|
-
const labels = [...defaultLabels.filter(x =>
|
|
46553
|
-
|
|
46588
|
+
const labels = [...defaultLabels.filter(x => pluginLabels.findIndex(e => e.id === x.id) === -1), ...pluginLabels];
|
|
46589
|
+
const finalLabels = [...labels.filter(x => externalLabels.findIndex(e => e.id === x.id) === -1), ...externalLabels];
|
|
46590
|
+
return finalLabels.map(x => {
|
|
46554
46591
|
const localizedItem = localizeItem(x, locale, 'en');
|
|
46555
46592
|
return {
|
|
46556
46593
|
id: localizedItem.id,
|
|
@@ -46699,7 +46736,7 @@ function isIterable(element) {
|
|
|
46699
46736
|
return element != null && typeof element[Symbol.iterator] === 'function';
|
|
46700
46737
|
}
|
|
46701
46738
|
|
|
46702
|
-
function getInitializer(globalName, plugins) {
|
|
46739
|
+
function getInitializer(globalName, plugins, pluginLabels) {
|
|
46703
46740
|
if (globalName === void 0) {
|
|
46704
46741
|
globalName = 'bomLlm';
|
|
46705
46742
|
}
|
|
@@ -46712,23 +46749,24 @@ function getInitializer(globalName, plugins) {
|
|
|
46712
46749
|
return;
|
|
46713
46750
|
}
|
|
46714
46751
|
props.plugins = [...(props.plugins || []), ...(plugins || [])];
|
|
46752
|
+
props.pluginLabels = pluginLabels;
|
|
46715
46753
|
const id = toKebabCase(globalName);
|
|
46716
46754
|
const node = document.createElement('div');
|
|
46717
46755
|
node.setAttribute('id', id);
|
|
46718
46756
|
body.appendChild(node);
|
|
46719
46757
|
const initError = 'llm plugin is not initialized';
|
|
46720
46758
|
const llmInstance = {
|
|
46721
|
-
open:
|
|
46759
|
+
open: openingContext => {
|
|
46722
46760
|
console.log(initError);
|
|
46723
46761
|
},
|
|
46724
|
-
setOpened: opened => {
|
|
46762
|
+
setOpened: (opened, openingContext) => {
|
|
46725
46763
|
console.log(initError);
|
|
46726
46764
|
},
|
|
46727
46765
|
isOpened: () => {
|
|
46728
46766
|
console.log(initError);
|
|
46729
46767
|
return false;
|
|
46730
46768
|
},
|
|
46731
|
-
send: message => {
|
|
46769
|
+
send: (message, openingContext) => {
|
|
46732
46770
|
console.log(initError);
|
|
46733
46771
|
},
|
|
46734
46772
|
clear: () => {
|