@websolutespa/bom-mixer-llm 0.0.3 → 0.0.5
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 +42 -29
- package/dist/cjs/index.css +45 -12
- package/dist/cjs/index.js +206 -120
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.css +45 -12
- package/dist/esm/llm/components/Event/event.js +4 -1
- package/dist/esm/llm/components/Event/event.js.map +1 -1
- package/dist/esm/llm/components/FormRequest/FormRequest.js.map +1 -1
- package/dist/esm/llm/components/Header/header.js +4 -3
- package/dist/esm/llm/components/Header/header.js.map +1 -1
- package/dist/esm/llm/components/Main/main.js +5 -3
- package/dist/esm/llm/components/Main/main.js.map +1 -1
- package/dist/esm/llm/components/Poi/poi.js +4 -1
- package/dist/esm/llm/components/Poi/poi.js.map +1 -1
- package/dist/esm/llm/components/Prompt/prompt.js +4 -1
- package/dist/esm/llm/components/Prompt/prompt.js.map +1 -1
- package/dist/esm/llm/components/Prompt/suggestions.js +3 -2
- package/dist/esm/llm/components/Prompt/suggestions.js.map +1 -1
- package/dist/esm/llm/components/QuickLinks/quicklinks.js +4 -3
- package/dist/esm/llm/components/QuickLinks/quicklinks.js.map +1 -1
- package/dist/esm/llm/components/Trigger/trigger.js +3 -2
- package/dist/esm/llm/components/Trigger/trigger.js.map +1 -1
- package/dist/esm/llm/llm.js +24 -9
- package/dist/esm/llm/llm.js.map +1 -1
- package/dist/esm/useLlm/useLlm.js +16 -95
- package/dist/esm/useLlm/useLlm.js.map +1 -1
- package/dist/esm/useLlm/useLlmView.js +153 -0
- package/dist/esm/useLlm/useLlmView.js.map +1 -0
- package/dist/types/llm/components/Event/event.d.ts.map +1 -1
- package/dist/types/llm/components/FormRequest/FormRequest.d.ts.map +1 -1
- package/dist/types/llm/components/Header/header.d.ts.map +1 -1
- package/dist/types/llm/components/Main/main.d.ts.map +1 -1
- package/dist/types/llm/components/Poi/poi.d.ts.map +1 -1
- package/dist/types/llm/components/Prompt/prompt.d.ts.map +1 -1
- package/dist/types/llm/components/Prompt/suggestions.d.ts.map +1 -1
- package/dist/types/llm/components/QuickLinks/quicklinks.d.ts.map +1 -1
- package/dist/types/llm/components/Trigger/trigger.d.ts.map +1 -1
- package/dist/types/llm/llm.d.ts +3 -3
- package/dist/types/llm/llm.d.ts.map +1 -1
- package/dist/types/types.d.ts +3 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/useLlm/useLlm.d.ts +4 -12
- package/dist/types/useLlm/useLlm.d.ts.map +1 -1
- package/dist/types/useLlm/useLlmView.d.ts +36 -0
- package/dist/types/useLlm/useLlmView.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/llm/components/Event/event.tsx +3 -1
- package/src/llm/components/FormRequest/FormRequest.tsx +0 -1
- package/src/llm/components/Header/header.tsx +8 -4
- package/src/llm/components/Main/_style.scss +33 -6
- package/src/llm/components/Main/main.tsx +7 -5
- package/src/llm/components/Poi/poi.tsx +3 -1
- package/src/llm/components/Prompt/prompt.tsx +3 -1
- package/src/llm/components/Prompt/suggestions.tsx +3 -2
- package/src/llm/components/QuickLinks/quicklinks.tsx +3 -2
- package/src/llm/components/Text/_style.scss +7 -5
- package/src/llm/components/Trigger/trigger.tsx +2 -1
- package/src/llm/llm.tsx +22 -10
- package/src/llm/scss/_base.scss +17 -5
- package/src/swiper.d.ts +52 -0
- package/src/types.ts +4 -0
- package/src/useLlm/useLlm.tsx +19 -93
- package/src/useLlm/useLlmView.tsx +166 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,29 +1,42 @@
|
|
|
1
|
-
# @websolutespa/bom-mixer-llm
|
|
2
|
-
|
|
3
|
-
## 0.0.
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
- @websolutespa/bom-mixer-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
# @websolutespa/bom-mixer-llm
|
|
2
|
+
|
|
3
|
+
## 0.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added: shared state between instances
|
|
8
|
+
|
|
9
|
+
## 0.0.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Added: embed options
|
|
14
|
+
- Added: returning instance with methods
|
|
15
|
+
|
|
16
|
+
## 0.0.3
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updating: dependencies
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @websolutespa/bom-mixer-models@1.7.2
|
|
23
|
+
- @websolutespa/bom-mixer-forms@0.3.1
|
|
24
|
+
- @websolutespa/bom-mixer-hooks@1.7.2
|
|
25
|
+
- @websolutespa/bom-mixer-icons@0.2.3
|
|
26
|
+
- @websolutespa/bom-mixer-store@1.7.3
|
|
27
|
+
- @websolutespa/bom-mixer-ui@1.7.5
|
|
28
|
+
- @websolutespa/bom-core@1.7.3
|
|
29
|
+
|
|
30
|
+
## 0.0.2
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Modified: Speech synthesis & recognition, disclaimer, markdown
|
|
35
|
+
- Updated dependencies
|
|
36
|
+
- @websolutespa/bom-mixer-icons@0.2.2
|
|
37
|
+
|
|
38
|
+
## 0.0.1
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- Added: first release
|
package/dist/cjs/index.css
CHANGED
|
@@ -152,16 +152,27 @@
|
|
|
152
152
|
box-sizing: border-box;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
llm-embed {
|
|
156
|
+
display: block;
|
|
157
|
+
width: 100%;
|
|
158
|
+
height: 760px;
|
|
159
|
+
max-height: 100vh;
|
|
160
|
+
background: transparent;
|
|
161
|
+
overflow: clip;
|
|
162
|
+
}
|
|
163
|
+
|
|
155
164
|
.llm {
|
|
156
|
-
position: fixed;
|
|
157
165
|
display: flex;
|
|
158
166
|
flex-direction: column;
|
|
159
167
|
align-items: center;
|
|
160
168
|
justify-content: flex-end;
|
|
161
|
-
top: 0;
|
|
162
|
-
left: 0;
|
|
163
169
|
width: 100%;
|
|
164
170
|
height: 100%;
|
|
171
|
+
}
|
|
172
|
+
.llm:not(.-embedded) {
|
|
173
|
+
position: fixed;
|
|
174
|
+
top: 0;
|
|
175
|
+
left: 0;
|
|
165
176
|
pointer-events: none;
|
|
166
177
|
z-index: 9999;
|
|
167
178
|
}
|
|
@@ -938,7 +949,8 @@
|
|
|
938
949
|
}
|
|
939
950
|
|
|
940
951
|
.llm .llm__main {
|
|
941
|
-
|
|
952
|
+
display: block;
|
|
953
|
+
position: relative;
|
|
942
954
|
pointer-events: auto;
|
|
943
955
|
inset: 0;
|
|
944
956
|
background: var(--llm-color-ui-1);
|
|
@@ -978,15 +990,34 @@
|
|
|
978
990
|
}
|
|
979
991
|
.llm .llm__content {
|
|
980
992
|
min-height: 100%;
|
|
981
|
-
padding-top: 100px;
|
|
982
|
-
padding-bottom: 180px;
|
|
983
993
|
display: flex;
|
|
984
994
|
flex-direction: column;
|
|
985
995
|
justify-content: center;
|
|
986
996
|
}
|
|
997
|
+
.llm.-embedded .llm__main {
|
|
998
|
+
width: 100%;
|
|
999
|
+
height: 100%;
|
|
1000
|
+
}
|
|
1001
|
+
.llm.-embedded .llm__content {
|
|
1002
|
+
padding-top: 40px;
|
|
1003
|
+
padding-bottom: 180px;
|
|
1004
|
+
}
|
|
1005
|
+
@media (min-width: 1024px) {
|
|
1006
|
+
.llm.-embedded .llm__content {
|
|
1007
|
+
padding-top: 60px;
|
|
1008
|
+
padding-bottom: 180px;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
.llm:not(.-embedded) .llm__main {
|
|
1012
|
+
position: absolute;
|
|
1013
|
+
}
|
|
1014
|
+
.llm:not(.-embedded) .llm__content {
|
|
1015
|
+
padding-top: 100px;
|
|
1016
|
+
padding-bottom: 180px;
|
|
1017
|
+
}
|
|
987
1018
|
@media (min-width: 1024px) {
|
|
988
|
-
.llm .llm__content {
|
|
989
|
-
padding: 200px
|
|
1019
|
+
.llm:not(.-embedded) .llm__content {
|
|
1020
|
+
padding-top: 200px;
|
|
990
1021
|
padding-bottom: 280px;
|
|
991
1022
|
}
|
|
992
1023
|
}
|
|
@@ -1459,15 +1490,17 @@
|
|
|
1459
1490
|
border: 2px solid rgba(255, 255, 255, 0.4);
|
|
1460
1491
|
}
|
|
1461
1492
|
.llm .llm__message--assistant .llm__inner--string .llm__text .llm__text-body .llm__text-img {
|
|
1493
|
+
display: block;
|
|
1494
|
+
margin: 1rem 0;
|
|
1495
|
+
font-size: 0;
|
|
1496
|
+
text-decoration: none;
|
|
1497
|
+
}
|
|
1498
|
+
.llm .llm__message--assistant .llm__inner--string .llm__text .llm__text-body .llm__text-img > img {
|
|
1462
1499
|
display: inline-flex;
|
|
1463
1500
|
justify-content: center;
|
|
1464
1501
|
align-items: center;
|
|
1465
1502
|
width: 320px;
|
|
1466
1503
|
height: 320px;
|
|
1467
|
-
font-size: 0;
|
|
1468
|
-
text-decoration: none;
|
|
1469
|
-
}
|
|
1470
|
-
.llm .llm__message--assistant .llm__inner--string .llm__text .llm__text-body .llm__text-img > img {
|
|
1471
1504
|
object-fit: cover;
|
|
1472
1505
|
}
|
|
1473
1506
|
.llm .llm__text-disclaimer {
|
package/dist/cjs/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var framerMotion = require('framer-motion');
|
|
|
7
7
|
var react = require('react');
|
|
8
8
|
var zustand = require('zustand');
|
|
9
9
|
var middleware = require('zustand/middleware');
|
|
10
|
-
var
|
|
10
|
+
var react$2 = require('lenis/react');
|
|
11
11
|
var ArrayBuffer = require('nanogl/arraybuffer');
|
|
12
12
|
var Program = require('nanogl/program');
|
|
13
13
|
var bomMixerIcons = require('@websolutespa/bom-mixer-icons');
|
|
@@ -1502,12 +1502,156 @@ function stripEmojis(text) {
|
|
|
1502
1502
|
return text.replace(/(\s?)([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g, '');
|
|
1503
1503
|
}
|
|
1504
1504
|
|
|
1505
|
+
const createLlmViewStore = _ref => {
|
|
1506
|
+
let {
|
|
1507
|
+
threadId,
|
|
1508
|
+
opened,
|
|
1509
|
+
embedded,
|
|
1510
|
+
send
|
|
1511
|
+
} = _ref;
|
|
1512
|
+
const props = {
|
|
1513
|
+
opened: opened != null || embedded != null ? Boolean(opened || embedded) : threadId != null ? true : false,
|
|
1514
|
+
embedded: embedded || false,
|
|
1515
|
+
hidden: false,
|
|
1516
|
+
fixed: false,
|
|
1517
|
+
idle: true,
|
|
1518
|
+
direction: 0
|
|
1519
|
+
};
|
|
1520
|
+
let lenis_ = undefined;
|
|
1521
|
+
let autoScroll = true;
|
|
1522
|
+
const useStore = zustand.createStore((set, get) => Object.assign(Object.assign({}, props), {
|
|
1523
|
+
actions: {
|
|
1524
|
+
initView: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1525
|
+
get();
|
|
1526
|
+
// handle idle times
|
|
1527
|
+
const setIdleTimeout = () => {
|
|
1528
|
+
return setTimeout(() => {
|
|
1529
|
+
set(() => ({
|
|
1530
|
+
idle: true
|
|
1531
|
+
}));
|
|
1532
|
+
}, 6000);
|
|
1533
|
+
};
|
|
1534
|
+
const handleIdleTimes = () => {
|
|
1535
|
+
let to = setIdleTimeout();
|
|
1536
|
+
let lastScrollTop = 0;
|
|
1537
|
+
window.addEventListener('scroll', () => {
|
|
1538
|
+
const st = window.scrollY || document.documentElement.scrollTop;
|
|
1539
|
+
let direction = 0;
|
|
1540
|
+
if (st > lastScrollTop) {
|
|
1541
|
+
direction = 1;
|
|
1542
|
+
} else if (st < lastScrollTop) {
|
|
1543
|
+
direction = -1;
|
|
1544
|
+
}
|
|
1545
|
+
lastScrollTop = st <= 0 ? 0 : st;
|
|
1546
|
+
if (direction === 1) {
|
|
1547
|
+
if (to) {
|
|
1548
|
+
clearTimeout(to);
|
|
1549
|
+
}
|
|
1550
|
+
set(() => ({
|
|
1551
|
+
idle: false
|
|
1552
|
+
}));
|
|
1553
|
+
to = setIdleTimeout();
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1556
|
+
};
|
|
1557
|
+
setTimeout(() => {
|
|
1558
|
+
set(() => ({
|
|
1559
|
+
idle: false
|
|
1560
|
+
}));
|
|
1561
|
+
handleIdleTimes();
|
|
1562
|
+
}, 2000);
|
|
1563
|
+
}),
|
|
1564
|
+
send: (prompt, onMessage, onEnd) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1565
|
+
const state = get();
|
|
1566
|
+
autoScroll = true;
|
|
1567
|
+
state.actions.scrollToBottom();
|
|
1568
|
+
yield send(prompt, response => {
|
|
1569
|
+
state.actions.scrollToBottom();
|
|
1570
|
+
if (typeof onMessage === 'function') {
|
|
1571
|
+
onMessage(response);
|
|
1572
|
+
}
|
|
1573
|
+
}, response => {
|
|
1574
|
+
state.actions.scrollToBottom();
|
|
1575
|
+
if (typeof onEnd === 'function') {
|
|
1576
|
+
onEnd(response);
|
|
1577
|
+
}
|
|
1578
|
+
});
|
|
1579
|
+
}),
|
|
1580
|
+
open: () => set(state => ({
|
|
1581
|
+
opened: !state.opened
|
|
1582
|
+
})),
|
|
1583
|
+
setLenis: lenis => {
|
|
1584
|
+
if (lenis_ !== lenis) {
|
|
1585
|
+
lenis_ = lenis;
|
|
1586
|
+
if (lenis) {
|
|
1587
|
+
lenis.on('scroll', event => {
|
|
1588
|
+
const {
|
|
1589
|
+
direction,
|
|
1590
|
+
targetScroll,
|
|
1591
|
+
limit
|
|
1592
|
+
} = event;
|
|
1593
|
+
if (limit === targetScroll) {
|
|
1594
|
+
autoScroll = true;
|
|
1595
|
+
} else if (direction == -1 && Math.abs(limit - targetScroll) > 100) {
|
|
1596
|
+
autoScroll = false;
|
|
1597
|
+
}
|
|
1598
|
+
const scrolled = targetScroll > 100;
|
|
1599
|
+
const fixed = direction == -1 && scrolled && !autoScroll;
|
|
1600
|
+
const hidden = autoScroll || direction == 1 && scrolled;
|
|
1601
|
+
const state = get();
|
|
1602
|
+
if (state.hidden !== hidden || state.fixed !== fixed || state.direction !== direction) {
|
|
1603
|
+
set(state => ({
|
|
1604
|
+
hidden,
|
|
1605
|
+
fixed,
|
|
1606
|
+
direction
|
|
1607
|
+
}));
|
|
1608
|
+
}
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
},
|
|
1613
|
+
scrollToBottom: () => {
|
|
1614
|
+
if (lenis_ && autoScroll) {
|
|
1615
|
+
lenis_.scrollTo('bottom', {
|
|
1616
|
+
immediate: true
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
}));
|
|
1622
|
+
return useStore;
|
|
1623
|
+
};
|
|
1624
|
+
const LlmViewContext = /*#__PURE__*/react.createContext(null);
|
|
1625
|
+
function LlmViewProvider(_a) {
|
|
1626
|
+
var {
|
|
1627
|
+
children
|
|
1628
|
+
} = _a,
|
|
1629
|
+
props = __rest(_a, ["children"]);
|
|
1630
|
+
const {
|
|
1631
|
+
send
|
|
1632
|
+
} = useLlm(state => state.actions);
|
|
1633
|
+
const storeRef = react.useRef();
|
|
1634
|
+
if (!storeRef.current) {
|
|
1635
|
+
storeRef.current = createLlmViewStore(Object.assign(Object.assign({}, props), {
|
|
1636
|
+
send
|
|
1637
|
+
}));
|
|
1638
|
+
}
|
|
1639
|
+
return storeRef.current && jsxRuntime.jsx(LlmViewContext.Provider, {
|
|
1640
|
+
value: storeRef.current,
|
|
1641
|
+
children: children
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
function useLlmView(selector) {
|
|
1645
|
+
const store = react.useContext(LlmViewContext);
|
|
1646
|
+
if (!store) throw new Error('Missing LlmContext.Provider in the tree');
|
|
1647
|
+
return zustand.useStore(store, selector);
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1505
1650
|
const createLlmStore = _ref => {
|
|
1506
1651
|
let {
|
|
1507
1652
|
appKey,
|
|
1508
1653
|
apiKey,
|
|
1509
1654
|
threadId,
|
|
1510
|
-
opened,
|
|
1511
1655
|
decorateUrl,
|
|
1512
1656
|
endpoint,
|
|
1513
1657
|
test,
|
|
@@ -1520,24 +1664,10 @@ const createLlmStore = _ref => {
|
|
|
1520
1664
|
prompt: '',
|
|
1521
1665
|
locale: 'en',
|
|
1522
1666
|
streaming: false,
|
|
1523
|
-
opened: opened != null ? opened : threadId != null ? true : false,
|
|
1524
|
-
hidden: false,
|
|
1525
|
-
fixed: false,
|
|
1526
|
-
idle: true,
|
|
1527
|
-
direction: 0,
|
|
1528
1667
|
speakEnabled: true
|
|
1529
1668
|
};
|
|
1530
1669
|
let messageService = undefined;
|
|
1531
1670
|
const speech = new Speech();
|
|
1532
|
-
let lenis_ = undefined;
|
|
1533
|
-
let autoScroll = true;
|
|
1534
|
-
const scrollToBottom = () => {
|
|
1535
|
-
if (lenis_ && autoScroll) {
|
|
1536
|
-
lenis_.scrollTo('bottom', {
|
|
1537
|
-
immediate: true
|
|
1538
|
-
});
|
|
1539
|
-
}
|
|
1540
|
-
};
|
|
1541
1671
|
function getApi(options) {
|
|
1542
1672
|
const origin = endpoint || (bomCore.isBrowser ? window.location.origin : process.env.STORE_URL);
|
|
1543
1673
|
const baseUrl = `${origin}/api/llm`;
|
|
@@ -1644,45 +1774,8 @@ const createLlmStore = _ref => {
|
|
|
1644
1774
|
app,
|
|
1645
1775
|
locale
|
|
1646
1776
|
}, thread));
|
|
1647
|
-
// handle idle times
|
|
1648
|
-
const setIdleTimeout = () => {
|
|
1649
|
-
return setTimeout(() => {
|
|
1650
|
-
set(() => ({
|
|
1651
|
-
idle: true
|
|
1652
|
-
}));
|
|
1653
|
-
}, 6000);
|
|
1654
|
-
};
|
|
1655
|
-
const handleIdleTimes = () => {
|
|
1656
|
-
let to = setIdleTimeout();
|
|
1657
|
-
let lastScrollTop = 0;
|
|
1658
|
-
window.addEventListener('scroll', () => {
|
|
1659
|
-
const st = window.scrollY || document.documentElement.scrollTop;
|
|
1660
|
-
let direction = 0;
|
|
1661
|
-
if (st > lastScrollTop) {
|
|
1662
|
-
direction = 1;
|
|
1663
|
-
} else if (st < lastScrollTop) {
|
|
1664
|
-
direction = -1;
|
|
1665
|
-
}
|
|
1666
|
-
lastScrollTop = st <= 0 ? 0 : st;
|
|
1667
|
-
if (direction === 1) {
|
|
1668
|
-
if (to) {
|
|
1669
|
-
clearTimeout(to);
|
|
1670
|
-
}
|
|
1671
|
-
set(() => ({
|
|
1672
|
-
idle: false
|
|
1673
|
-
}));
|
|
1674
|
-
to = setIdleTimeout();
|
|
1675
|
-
}
|
|
1676
|
-
});
|
|
1677
|
-
};
|
|
1678
|
-
setTimeout(() => {
|
|
1679
|
-
set(() => ({
|
|
1680
|
-
idle: false
|
|
1681
|
-
}));
|
|
1682
|
-
handleIdleTimes();
|
|
1683
|
-
}, 2000);
|
|
1684
1777
|
}),
|
|
1685
|
-
send: (prompt,
|
|
1778
|
+
send: (prompt, onMessage, onEnd) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1686
1779
|
if (test) {
|
|
1687
1780
|
const {
|
|
1688
1781
|
locale
|
|
@@ -1703,8 +1796,6 @@ const createLlmStore = _ref => {
|
|
|
1703
1796
|
prompt: '',
|
|
1704
1797
|
streaming: true
|
|
1705
1798
|
}));
|
|
1706
|
-
autoScroll = true;
|
|
1707
|
-
scrollToBottom();
|
|
1708
1799
|
const state = get();
|
|
1709
1800
|
const origin = endpoint || window.location.origin;
|
|
1710
1801
|
const url = `${origin}/api/llm/message?locale=${state.locale}`;
|
|
@@ -1735,10 +1826,9 @@ const createLlmStore = _ref => {
|
|
|
1735
1826
|
set(state => ({
|
|
1736
1827
|
chunks: response.chunks
|
|
1737
1828
|
}));
|
|
1738
|
-
if (typeof
|
|
1739
|
-
|
|
1829
|
+
if (typeof onMessage === 'function') {
|
|
1830
|
+
onMessage(response);
|
|
1740
1831
|
}
|
|
1741
|
-
scrollToBottom();
|
|
1742
1832
|
},
|
|
1743
1833
|
// onEnd
|
|
1744
1834
|
response => {
|
|
@@ -1779,7 +1869,6 @@ const createLlmStore = _ref => {
|
|
|
1779
1869
|
if (typeof onEnd === 'function') {
|
|
1780
1870
|
onEnd(response);
|
|
1781
1871
|
}
|
|
1782
|
-
scrollToBottom();
|
|
1783
1872
|
},
|
|
1784
1873
|
// onChunk
|
|
1785
1874
|
chunks => {
|
|
@@ -1871,42 +1960,9 @@ const createLlmStore = _ref => {
|
|
|
1871
1960
|
}
|
|
1872
1961
|
return url || defaultUrl || '#';
|
|
1873
1962
|
}),
|
|
1874
|
-
open: () => set(state => ({
|
|
1875
|
-
opened: !state.opened
|
|
1876
|
-
})),
|
|
1877
1963
|
clear: () => set(state => ({
|
|
1878
1964
|
messages: []
|
|
1879
|
-
}))
|
|
1880
|
-
setLenis: lenis => {
|
|
1881
|
-
if (lenis_ !== lenis) {
|
|
1882
|
-
lenis_ = lenis;
|
|
1883
|
-
if (lenis) {
|
|
1884
|
-
lenis.on('scroll', event => {
|
|
1885
|
-
const {
|
|
1886
|
-
direction,
|
|
1887
|
-
targetScroll,
|
|
1888
|
-
limit
|
|
1889
|
-
} = event;
|
|
1890
|
-
if (limit === targetScroll) {
|
|
1891
|
-
autoScroll = true;
|
|
1892
|
-
} else if (direction == -1 && Math.abs(limit - targetScroll) > 100) {
|
|
1893
|
-
autoScroll = false;
|
|
1894
|
-
}
|
|
1895
|
-
const scrolled = targetScroll > 100;
|
|
1896
|
-
const fixed = direction == -1 && scrolled && !autoScroll;
|
|
1897
|
-
const hidden = autoScroll || direction == 1 && scrolled;
|
|
1898
|
-
const state = get();
|
|
1899
|
-
if (state.hidden !== hidden || state.fixed !== fixed || state.direction !== direction) {
|
|
1900
|
-
set(state => ({
|
|
1901
|
-
hidden,
|
|
1902
|
-
fixed,
|
|
1903
|
-
direction
|
|
1904
|
-
}));
|
|
1905
|
-
}
|
|
1906
|
-
});
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1965
|
+
}))
|
|
1910
1966
|
}
|
|
1911
1967
|
}), {
|
|
1912
1968
|
name: 'llm',
|
|
@@ -1937,6 +1993,13 @@ const createLlmStore = _ref => {
|
|
|
1937
1993
|
}));
|
|
1938
1994
|
return useStore;
|
|
1939
1995
|
};
|
|
1996
|
+
let sharedLlmStore;
|
|
1997
|
+
function createSharedLlmStore(props) {
|
|
1998
|
+
if (!sharedLlmStore) {
|
|
1999
|
+
sharedLlmStore = createLlmStore(props);
|
|
2000
|
+
}
|
|
2001
|
+
return sharedLlmStore;
|
|
2002
|
+
}
|
|
1940
2003
|
const LlmContext = /*#__PURE__*/react.createContext(null);
|
|
1941
2004
|
function LlmProvider(_a) {
|
|
1942
2005
|
var {
|
|
@@ -1946,13 +2009,15 @@ function LlmProvider(_a) {
|
|
|
1946
2009
|
const label = bomMixerHooks.useLabel();
|
|
1947
2010
|
const storeRef = react.useRef();
|
|
1948
2011
|
if (!storeRef.current) {
|
|
1949
|
-
storeRef.current =
|
|
2012
|
+
storeRef.current = createSharedLlmStore(Object.assign(Object.assign({}, props), {
|
|
1950
2013
|
label
|
|
1951
2014
|
}));
|
|
1952
2015
|
}
|
|
1953
2016
|
return storeRef.current && jsxRuntime.jsx(LlmContext.Provider, {
|
|
1954
2017
|
value: storeRef.current,
|
|
1955
|
-
children:
|
|
2018
|
+
children: jsxRuntime.jsx(LlmViewProvider, Object.assign({}, props, {
|
|
2019
|
+
children: children
|
|
2020
|
+
}))
|
|
1956
2021
|
});
|
|
1957
2022
|
}
|
|
1958
2023
|
function useLlm(selector) {
|
|
@@ -2181,9 +2246,9 @@ const Header = props => {
|
|
|
2181
2246
|
const app = useLlm(state => state.app);
|
|
2182
2247
|
const {
|
|
2183
2248
|
open
|
|
2184
|
-
} =
|
|
2185
|
-
const hidden =
|
|
2186
|
-
const fixed =
|
|
2249
|
+
} = useLlmView(state => state.actions);
|
|
2250
|
+
const hidden = useLlmView(state => state.hidden);
|
|
2251
|
+
const fixed = useLlmView(state => state.fixed);
|
|
2187
2252
|
const label = bomMixerHooks.useLabel();
|
|
2188
2253
|
const logo = app === null || app === void 0 ? void 0 : app.contents.logo;
|
|
2189
2254
|
const logoMini = (_a = app === null || app === void 0 ? void 0 : app.contents) === null || _a === void 0 ? void 0 : _a.logoMini;
|
|
@@ -2234,10 +2299,10 @@ const QuickLinks = () => {
|
|
|
2234
2299
|
const {
|
|
2235
2300
|
width
|
|
2236
2301
|
} = bomMixerHooks.useWindowSize();
|
|
2302
|
+
const app = useLlm(state => state.app);
|
|
2237
2303
|
const {
|
|
2238
2304
|
send
|
|
2239
|
-
} =
|
|
2240
|
-
const app = useLlm(state => state.app);
|
|
2305
|
+
} = useLlmView(state => state.actions);
|
|
2241
2306
|
const swiperProps = {
|
|
2242
2307
|
spaceBetween: clamp(8, 16),
|
|
2243
2308
|
slidesOffsetAfter: clamp(20, 110),
|
|
@@ -2246,7 +2311,7 @@ const QuickLinks = () => {
|
|
|
2246
2311
|
};
|
|
2247
2312
|
const onClick = item => __awaiter(void 0, void 0, void 0, function* () {
|
|
2248
2313
|
yield send(item.message || item.title, response => {
|
|
2249
|
-
// console.log('QuickLinks.
|
|
2314
|
+
// console.log('QuickLinks.onMessage', response.chunks);
|
|
2250
2315
|
}, response => {
|
|
2251
2316
|
// console.log('QuickLinks.onEnd', response);
|
|
2252
2317
|
});
|
|
@@ -2487,7 +2552,7 @@ const Suggestions = () => {
|
|
|
2487
2552
|
const app = useLlm(state => state.app);
|
|
2488
2553
|
const {
|
|
2489
2554
|
send
|
|
2490
|
-
} =
|
|
2555
|
+
} = useLlmView(state => state.actions);
|
|
2491
2556
|
const swiperProps = {
|
|
2492
2557
|
modules: [swiper.FreeMode],
|
|
2493
2558
|
spaceBetween: 8,
|
|
@@ -2498,7 +2563,7 @@ const Suggestions = () => {
|
|
|
2498
2563
|
};
|
|
2499
2564
|
const onClick = item => __awaiter(void 0, void 0, void 0, function* () {
|
|
2500
2565
|
yield send(item.sampleInputText, response => {
|
|
2501
|
-
// console.log('Suggestions.
|
|
2566
|
+
// console.log('Suggestions.onMessage', response.chunks);
|
|
2502
2567
|
}, response => {
|
|
2503
2568
|
// console.log('Suggestions.onEnd', response);
|
|
2504
2569
|
});
|
|
@@ -2524,7 +2589,6 @@ const Prompt = () => {
|
|
|
2524
2589
|
const streaming = useLlm(state => state.streaming);
|
|
2525
2590
|
const speakEnabled = useLlm(state => state.speakEnabled);
|
|
2526
2591
|
const {
|
|
2527
|
-
send,
|
|
2528
2592
|
setPrompt,
|
|
2529
2593
|
recognizeStart,
|
|
2530
2594
|
recognizeStop,
|
|
@@ -2532,6 +2596,9 @@ const Prompt = () => {
|
|
|
2532
2596
|
toggleSpeak,
|
|
2533
2597
|
hasSpeechSupport
|
|
2534
2598
|
} = useLlm(state => state.actions);
|
|
2599
|
+
const {
|
|
2600
|
+
send
|
|
2601
|
+
} = useLlmView(state => state.actions);
|
|
2535
2602
|
useAutosizeTextArea(textArea.current, prompt);
|
|
2536
2603
|
const onChange = event => {
|
|
2537
2604
|
var _a;
|
|
@@ -2717,9 +2784,11 @@ const Cta = props => {
|
|
|
2717
2784
|
const Event = props => {
|
|
2718
2785
|
const label = bomMixerHooks.useLabel();
|
|
2719
2786
|
const {
|
|
2720
|
-
send,
|
|
2721
2787
|
decorateUrl
|
|
2722
2788
|
} = useLlm(state => state.actions);
|
|
2789
|
+
const {
|
|
2790
|
+
send
|
|
2791
|
+
} = useLlmView(state => state.actions);
|
|
2723
2792
|
const onTellMeMore = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2724
2793
|
const prompt = `${label('llm.tellMeMoreAbout')} ${props.title}`;
|
|
2725
2794
|
yield send(prompt, response => {
|
|
@@ -3156,9 +3225,11 @@ const FormRequest = _ref => {
|
|
|
3156
3225
|
const Poi = props => {
|
|
3157
3226
|
const label = bomMixerHooks.useLabel();
|
|
3158
3227
|
const {
|
|
3159
|
-
send,
|
|
3160
3228
|
decorateUrl
|
|
3161
3229
|
} = useLlm(state => state.actions);
|
|
3230
|
+
const {
|
|
3231
|
+
send
|
|
3232
|
+
} = useLlmView(state => state.actions);
|
|
3162
3233
|
const onTellMeMore = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
3163
3234
|
const prompt = `${label('llm.tellMeMoreAbout')} ${props.title}`;
|
|
3164
3235
|
yield send(prompt, response => {
|
|
@@ -3439,9 +3510,10 @@ const Main = () => {
|
|
|
3439
3510
|
var _a;
|
|
3440
3511
|
const lenisRef = react.useRef(null);
|
|
3441
3512
|
const messages = useLlm(state => state.messages);
|
|
3513
|
+
const embedded = useLlmView(state => state.embedded);
|
|
3442
3514
|
const {
|
|
3443
3515
|
setLenis
|
|
3444
|
-
} =
|
|
3516
|
+
} = useLlmView(state => state.actions);
|
|
3445
3517
|
const classNames = bomCore.getClassNames('llm__main');
|
|
3446
3518
|
setLenis((_a = lenisRef.current) === null || _a === void 0 ? void 0 : _a.lenis);
|
|
3447
3519
|
const reveal = {
|
|
@@ -3508,8 +3580,8 @@ const Main = () => {
|
|
|
3508
3580
|
initial: "hidden",
|
|
3509
3581
|
animate: "show",
|
|
3510
3582
|
exit: "exit",
|
|
3511
|
-
children: jsxRuntime.jsx(Header, {})
|
|
3512
|
-
}), jsxRuntime.jsx(
|
|
3583
|
+
children: !embedded && jsxRuntime.jsx(Header, {})
|
|
3584
|
+
}), jsxRuntime.jsx(react$2.ReactLenis, {
|
|
3513
3585
|
ref: lenisRef,
|
|
3514
3586
|
className: "llm__scroller",
|
|
3515
3587
|
children: jsxRuntime.jsxs(framerMotion.motion.div, {
|
|
@@ -3531,10 +3603,10 @@ const Main = () => {
|
|
|
3531
3603
|
};
|
|
3532
3604
|
|
|
3533
3605
|
const Trigger = () => {
|
|
3606
|
+
const app = useLlm(state => state.app);
|
|
3534
3607
|
const {
|
|
3535
3608
|
open
|
|
3536
|
-
} =
|
|
3537
|
-
const app = useLlm(state => state.app);
|
|
3609
|
+
} = useLlmView(state => state.actions);
|
|
3538
3610
|
const label = bomMixerHooks.useLabel();
|
|
3539
3611
|
return jsxRuntime.jsxs(framerMotion.motion.div, {
|
|
3540
3612
|
initial: {
|
|
@@ -3582,7 +3654,7 @@ const Trigger = () => {
|
|
|
3582
3654
|
});
|
|
3583
3655
|
};
|
|
3584
3656
|
|
|
3585
|
-
const LlmComponent = props => {
|
|
3657
|
+
const LlmComponent = /*#__PURE__*/react.forwardRef((props, ref) => {
|
|
3586
3658
|
const {
|
|
3587
3659
|
locale
|
|
3588
3660
|
} = bomMixerHooks.useLayout();
|
|
@@ -3590,17 +3662,31 @@ const LlmComponent = props => {
|
|
|
3590
3662
|
init
|
|
3591
3663
|
} = useLlm(state => state.actions);
|
|
3592
3664
|
const app = useLlm(state => state.app);
|
|
3593
|
-
const
|
|
3594
|
-
|
|
3665
|
+
const {
|
|
3666
|
+
initView,
|
|
3667
|
+
open
|
|
3668
|
+
} = useLlmView(state => state.actions);
|
|
3669
|
+
const idle = useLlmView(state => state.idle);
|
|
3670
|
+
const opened = useLlmView(state => state.opened);
|
|
3671
|
+
const embedded = useLlmView(state => state.embedded);
|
|
3672
|
+
react.useImperativeHandle(ref, () => ({
|
|
3673
|
+
open: () => {
|
|
3674
|
+
open();
|
|
3675
|
+
}
|
|
3676
|
+
}));
|
|
3595
3677
|
react.useEffect(() => {
|
|
3596
3678
|
init(locale);
|
|
3597
|
-
|
|
3679
|
+
initView();
|
|
3680
|
+
}, [init, locale, initView]);
|
|
3598
3681
|
react.useEffect(() => {
|
|
3599
|
-
|
|
3600
|
-
|
|
3682
|
+
if (!embedded) {
|
|
3683
|
+
document.documentElement.style.overflow = opened ? 'hidden' : 'auto';
|
|
3684
|
+
}
|
|
3685
|
+
}, [opened, embedded]);
|
|
3601
3686
|
const mounted = bomMixerHooks.useMounted();
|
|
3602
3687
|
const classNames = bomCore.getClassNames('llm', {
|
|
3603
|
-
'-open': opened
|
|
3688
|
+
'-open': opened,
|
|
3689
|
+
'-embedded': embedded
|
|
3604
3690
|
});
|
|
3605
3691
|
if (mounted) {
|
|
3606
3692
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
@@ -3617,7 +3703,7 @@ const LlmComponent = props => {
|
|
|
3617
3703
|
} else {
|
|
3618
3704
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
3619
3705
|
}
|
|
3620
|
-
};
|
|
3706
|
+
});
|
|
3621
3707
|
|
|
3622
3708
|
exports.LlmComponent = LlmComponent;
|
|
3623
3709
|
exports.LlmContext = LlmContext;
|