@websolutespa/bom-mixer-llm 0.0.4 → 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 +6 -0
- package/dist/cjs/index.css +16 -26
- package/dist/cjs/index.js +197 -122
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.css +16 -26
- 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 +4 -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 +15 -8
- package/dist/esm/llm/llm.js.map +1 -1
- package/dist/esm/useLlm/useLlm.js +16 -97
- 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.map +1 -1
- package/dist/types/useLlm/useLlm.d.ts +4 -14
- 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 +4 -3
- package/src/llm/components/Main/_style.scss +8 -2
- package/src/llm/components/Main/main.tsx +6 -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 +12 -7
- package/src/llm/scss/_base.scss +1 -16
- package/src/swiper.d.ts +52 -0
- package/src/useLlm/useLlm.tsx +19 -96
- package/src/useLlm/useLlmView.tsx +166 -0
package/CHANGELOG.md
CHANGED
package/dist/cjs/index.css
CHANGED
|
@@ -155,30 +155,11 @@
|
|
|
155
155
|
llm-embed {
|
|
156
156
|
display: block;
|
|
157
157
|
width: 100%;
|
|
158
|
+
height: 760px;
|
|
158
159
|
max-height: 100vh;
|
|
159
160
|
background: transparent;
|
|
160
161
|
overflow: clip;
|
|
161
162
|
}
|
|
162
|
-
@media (max-width: 799px) {
|
|
163
|
-
llm-embed {
|
|
164
|
-
height: 100vh;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
@media (min-width: 800px) {
|
|
168
|
-
llm-embed {
|
|
169
|
-
aspect-ratio: 1/1;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
@media (min-width: 1080px) {
|
|
173
|
-
llm-embed {
|
|
174
|
-
aspect-ratio: 4/3;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
@media (min-width: 1440px) {
|
|
178
|
-
llm-embed {
|
|
179
|
-
aspect-ratio: 16/9;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
163
|
|
|
183
164
|
.llm {
|
|
184
165
|
display: flex;
|
|
@@ -1018,7 +999,14 @@ llm-embed {
|
|
|
1018
999
|
height: 100%;
|
|
1019
1000
|
}
|
|
1020
1001
|
.llm.-embedded .llm__content {
|
|
1021
|
-
padding:
|
|
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
|
+
}
|
|
1022
1010
|
}
|
|
1023
1011
|
.llm:not(.-embedded) .llm__main {
|
|
1024
1012
|
position: absolute;
|
|
@@ -1029,7 +1017,7 @@ llm-embed {
|
|
|
1029
1017
|
}
|
|
1030
1018
|
@media (min-width: 1024px) {
|
|
1031
1019
|
.llm:not(.-embedded) .llm__content {
|
|
1032
|
-
padding: 200px
|
|
1020
|
+
padding-top: 200px;
|
|
1033
1021
|
padding-bottom: 280px;
|
|
1034
1022
|
}
|
|
1035
1023
|
}
|
|
@@ -1502,15 +1490,17 @@ llm-embed {
|
|
|
1502
1490
|
border: 2px solid rgba(255, 255, 255, 0.4);
|
|
1503
1491
|
}
|
|
1504
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 {
|
|
1505
1499
|
display: inline-flex;
|
|
1506
1500
|
justify-content: center;
|
|
1507
1501
|
align-items: center;
|
|
1508
1502
|
width: 320px;
|
|
1509
1503
|
height: 320px;
|
|
1510
|
-
font-size: 0;
|
|
1511
|
-
text-decoration: none;
|
|
1512
|
-
}
|
|
1513
|
-
.llm .llm__message--assistant .llm__inner--string .llm__text .llm__text-body .llm__text-img > img {
|
|
1514
1504
|
object-fit: cover;
|
|
1515
1505
|
}
|
|
1516
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,13 +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
|
-
embedded,
|
|
1512
1655
|
decorateUrl,
|
|
1513
1656
|
endpoint,
|
|
1514
1657
|
test,
|
|
@@ -1521,25 +1664,10 @@ const createLlmStore = _ref => {
|
|
|
1521
1664
|
prompt: '',
|
|
1522
1665
|
locale: 'en',
|
|
1523
1666
|
streaming: false,
|
|
1524
|
-
opened: opened != null || embedded != null ? Boolean(opened || embedded) : threadId != null ? true : false,
|
|
1525
|
-
embedded: embedded || false,
|
|
1526
|
-
hidden: false,
|
|
1527
|
-
fixed: false,
|
|
1528
|
-
idle: true,
|
|
1529
|
-
direction: 0,
|
|
1530
1667
|
speakEnabled: true
|
|
1531
1668
|
};
|
|
1532
1669
|
let messageService = undefined;
|
|
1533
1670
|
const speech = new Speech();
|
|
1534
|
-
let lenis_ = undefined;
|
|
1535
|
-
let autoScroll = true;
|
|
1536
|
-
const scrollToBottom = () => {
|
|
1537
|
-
if (lenis_ && autoScroll) {
|
|
1538
|
-
lenis_.scrollTo('bottom', {
|
|
1539
|
-
immediate: true
|
|
1540
|
-
});
|
|
1541
|
-
}
|
|
1542
|
-
};
|
|
1543
1671
|
function getApi(options) {
|
|
1544
1672
|
const origin = endpoint || (bomCore.isBrowser ? window.location.origin : process.env.STORE_URL);
|
|
1545
1673
|
const baseUrl = `${origin}/api/llm`;
|
|
@@ -1646,45 +1774,8 @@ const createLlmStore = _ref => {
|
|
|
1646
1774
|
app,
|
|
1647
1775
|
locale
|
|
1648
1776
|
}, thread));
|
|
1649
|
-
// handle idle times
|
|
1650
|
-
const setIdleTimeout = () => {
|
|
1651
|
-
return setTimeout(() => {
|
|
1652
|
-
set(() => ({
|
|
1653
|
-
idle: true
|
|
1654
|
-
}));
|
|
1655
|
-
}, 6000);
|
|
1656
|
-
};
|
|
1657
|
-
const handleIdleTimes = () => {
|
|
1658
|
-
let to = setIdleTimeout();
|
|
1659
|
-
let lastScrollTop = 0;
|
|
1660
|
-
window.addEventListener('scroll', () => {
|
|
1661
|
-
const st = window.scrollY || document.documentElement.scrollTop;
|
|
1662
|
-
let direction = 0;
|
|
1663
|
-
if (st > lastScrollTop) {
|
|
1664
|
-
direction = 1;
|
|
1665
|
-
} else if (st < lastScrollTop) {
|
|
1666
|
-
direction = -1;
|
|
1667
|
-
}
|
|
1668
|
-
lastScrollTop = st <= 0 ? 0 : st;
|
|
1669
|
-
if (direction === 1) {
|
|
1670
|
-
if (to) {
|
|
1671
|
-
clearTimeout(to);
|
|
1672
|
-
}
|
|
1673
|
-
set(() => ({
|
|
1674
|
-
idle: false
|
|
1675
|
-
}));
|
|
1676
|
-
to = setIdleTimeout();
|
|
1677
|
-
}
|
|
1678
|
-
});
|
|
1679
|
-
};
|
|
1680
|
-
setTimeout(() => {
|
|
1681
|
-
set(() => ({
|
|
1682
|
-
idle: false
|
|
1683
|
-
}));
|
|
1684
|
-
handleIdleTimes();
|
|
1685
|
-
}, 2000);
|
|
1686
1777
|
}),
|
|
1687
|
-
send: (prompt,
|
|
1778
|
+
send: (prompt, onMessage, onEnd) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1688
1779
|
if (test) {
|
|
1689
1780
|
const {
|
|
1690
1781
|
locale
|
|
@@ -1705,8 +1796,6 @@ const createLlmStore = _ref => {
|
|
|
1705
1796
|
prompt: '',
|
|
1706
1797
|
streaming: true
|
|
1707
1798
|
}));
|
|
1708
|
-
autoScroll = true;
|
|
1709
|
-
scrollToBottom();
|
|
1710
1799
|
const state = get();
|
|
1711
1800
|
const origin = endpoint || window.location.origin;
|
|
1712
1801
|
const url = `${origin}/api/llm/message?locale=${state.locale}`;
|
|
@@ -1737,10 +1826,9 @@ const createLlmStore = _ref => {
|
|
|
1737
1826
|
set(state => ({
|
|
1738
1827
|
chunks: response.chunks
|
|
1739
1828
|
}));
|
|
1740
|
-
if (typeof
|
|
1741
|
-
|
|
1829
|
+
if (typeof onMessage === 'function') {
|
|
1830
|
+
onMessage(response);
|
|
1742
1831
|
}
|
|
1743
|
-
scrollToBottom();
|
|
1744
1832
|
},
|
|
1745
1833
|
// onEnd
|
|
1746
1834
|
response => {
|
|
@@ -1781,7 +1869,6 @@ const createLlmStore = _ref => {
|
|
|
1781
1869
|
if (typeof onEnd === 'function') {
|
|
1782
1870
|
onEnd(response);
|
|
1783
1871
|
}
|
|
1784
|
-
scrollToBottom();
|
|
1785
1872
|
},
|
|
1786
1873
|
// onChunk
|
|
1787
1874
|
chunks => {
|
|
@@ -1873,42 +1960,9 @@ const createLlmStore = _ref => {
|
|
|
1873
1960
|
}
|
|
1874
1961
|
return url || defaultUrl || '#';
|
|
1875
1962
|
}),
|
|
1876
|
-
open: () => set(state => ({
|
|
1877
|
-
opened: !state.opened
|
|
1878
|
-
})),
|
|
1879
1963
|
clear: () => set(state => ({
|
|
1880
1964
|
messages: []
|
|
1881
|
-
}))
|
|
1882
|
-
setLenis: lenis => {
|
|
1883
|
-
if (lenis_ !== lenis) {
|
|
1884
|
-
lenis_ = lenis;
|
|
1885
|
-
if (lenis) {
|
|
1886
|
-
lenis.on('scroll', event => {
|
|
1887
|
-
const {
|
|
1888
|
-
direction,
|
|
1889
|
-
targetScroll,
|
|
1890
|
-
limit
|
|
1891
|
-
} = event;
|
|
1892
|
-
if (limit === targetScroll) {
|
|
1893
|
-
autoScroll = true;
|
|
1894
|
-
} else if (direction == -1 && Math.abs(limit - targetScroll) > 100) {
|
|
1895
|
-
autoScroll = false;
|
|
1896
|
-
}
|
|
1897
|
-
const scrolled = targetScroll > 100;
|
|
1898
|
-
const fixed = direction == -1 && scrolled && !autoScroll;
|
|
1899
|
-
const hidden = autoScroll || direction == 1 && scrolled;
|
|
1900
|
-
const state = get();
|
|
1901
|
-
if (state.hidden !== hidden || state.fixed !== fixed || state.direction !== direction) {
|
|
1902
|
-
set(state => ({
|
|
1903
|
-
hidden,
|
|
1904
|
-
fixed,
|
|
1905
|
-
direction
|
|
1906
|
-
}));
|
|
1907
|
-
}
|
|
1908
|
-
});
|
|
1909
|
-
}
|
|
1910
|
-
}
|
|
1911
|
-
}
|
|
1965
|
+
}))
|
|
1912
1966
|
}
|
|
1913
1967
|
}), {
|
|
1914
1968
|
name: 'llm',
|
|
@@ -1939,6 +1993,13 @@ const createLlmStore = _ref => {
|
|
|
1939
1993
|
}));
|
|
1940
1994
|
return useStore;
|
|
1941
1995
|
};
|
|
1996
|
+
let sharedLlmStore;
|
|
1997
|
+
function createSharedLlmStore(props) {
|
|
1998
|
+
if (!sharedLlmStore) {
|
|
1999
|
+
sharedLlmStore = createLlmStore(props);
|
|
2000
|
+
}
|
|
2001
|
+
return sharedLlmStore;
|
|
2002
|
+
}
|
|
1942
2003
|
const LlmContext = /*#__PURE__*/react.createContext(null);
|
|
1943
2004
|
function LlmProvider(_a) {
|
|
1944
2005
|
var {
|
|
@@ -1948,13 +2009,15 @@ function LlmProvider(_a) {
|
|
|
1948
2009
|
const label = bomMixerHooks.useLabel();
|
|
1949
2010
|
const storeRef = react.useRef();
|
|
1950
2011
|
if (!storeRef.current) {
|
|
1951
|
-
storeRef.current =
|
|
2012
|
+
storeRef.current = createSharedLlmStore(Object.assign(Object.assign({}, props), {
|
|
1952
2013
|
label
|
|
1953
2014
|
}));
|
|
1954
2015
|
}
|
|
1955
2016
|
return storeRef.current && jsxRuntime.jsx(LlmContext.Provider, {
|
|
1956
2017
|
value: storeRef.current,
|
|
1957
|
-
children:
|
|
2018
|
+
children: jsxRuntime.jsx(LlmViewProvider, Object.assign({}, props, {
|
|
2019
|
+
children: children
|
|
2020
|
+
}))
|
|
1958
2021
|
});
|
|
1959
2022
|
}
|
|
1960
2023
|
function useLlm(selector) {
|
|
@@ -2183,9 +2246,9 @@ const Header = props => {
|
|
|
2183
2246
|
const app = useLlm(state => state.app);
|
|
2184
2247
|
const {
|
|
2185
2248
|
open
|
|
2186
|
-
} =
|
|
2187
|
-
const hidden =
|
|
2188
|
-
const fixed =
|
|
2249
|
+
} = useLlmView(state => state.actions);
|
|
2250
|
+
const hidden = useLlmView(state => state.hidden);
|
|
2251
|
+
const fixed = useLlmView(state => state.fixed);
|
|
2189
2252
|
const label = bomMixerHooks.useLabel();
|
|
2190
2253
|
const logo = app === null || app === void 0 ? void 0 : app.contents.logo;
|
|
2191
2254
|
const logoMini = (_a = app === null || app === void 0 ? void 0 : app.contents) === null || _a === void 0 ? void 0 : _a.logoMini;
|
|
@@ -2236,10 +2299,10 @@ const QuickLinks = () => {
|
|
|
2236
2299
|
const {
|
|
2237
2300
|
width
|
|
2238
2301
|
} = bomMixerHooks.useWindowSize();
|
|
2302
|
+
const app = useLlm(state => state.app);
|
|
2239
2303
|
const {
|
|
2240
2304
|
send
|
|
2241
|
-
} =
|
|
2242
|
-
const app = useLlm(state => state.app);
|
|
2305
|
+
} = useLlmView(state => state.actions);
|
|
2243
2306
|
const swiperProps = {
|
|
2244
2307
|
spaceBetween: clamp(8, 16),
|
|
2245
2308
|
slidesOffsetAfter: clamp(20, 110),
|
|
@@ -2248,7 +2311,7 @@ const QuickLinks = () => {
|
|
|
2248
2311
|
};
|
|
2249
2312
|
const onClick = item => __awaiter(void 0, void 0, void 0, function* () {
|
|
2250
2313
|
yield send(item.message || item.title, response => {
|
|
2251
|
-
// console.log('QuickLinks.
|
|
2314
|
+
// console.log('QuickLinks.onMessage', response.chunks);
|
|
2252
2315
|
}, response => {
|
|
2253
2316
|
// console.log('QuickLinks.onEnd', response);
|
|
2254
2317
|
});
|
|
@@ -2489,7 +2552,7 @@ const Suggestions = () => {
|
|
|
2489
2552
|
const app = useLlm(state => state.app);
|
|
2490
2553
|
const {
|
|
2491
2554
|
send
|
|
2492
|
-
} =
|
|
2555
|
+
} = useLlmView(state => state.actions);
|
|
2493
2556
|
const swiperProps = {
|
|
2494
2557
|
modules: [swiper.FreeMode],
|
|
2495
2558
|
spaceBetween: 8,
|
|
@@ -2500,7 +2563,7 @@ const Suggestions = () => {
|
|
|
2500
2563
|
};
|
|
2501
2564
|
const onClick = item => __awaiter(void 0, void 0, void 0, function* () {
|
|
2502
2565
|
yield send(item.sampleInputText, response => {
|
|
2503
|
-
// console.log('Suggestions.
|
|
2566
|
+
// console.log('Suggestions.onMessage', response.chunks);
|
|
2504
2567
|
}, response => {
|
|
2505
2568
|
// console.log('Suggestions.onEnd', response);
|
|
2506
2569
|
});
|
|
@@ -2526,7 +2589,6 @@ const Prompt = () => {
|
|
|
2526
2589
|
const streaming = useLlm(state => state.streaming);
|
|
2527
2590
|
const speakEnabled = useLlm(state => state.speakEnabled);
|
|
2528
2591
|
const {
|
|
2529
|
-
send,
|
|
2530
2592
|
setPrompt,
|
|
2531
2593
|
recognizeStart,
|
|
2532
2594
|
recognizeStop,
|
|
@@ -2534,6 +2596,9 @@ const Prompt = () => {
|
|
|
2534
2596
|
toggleSpeak,
|
|
2535
2597
|
hasSpeechSupport
|
|
2536
2598
|
} = useLlm(state => state.actions);
|
|
2599
|
+
const {
|
|
2600
|
+
send
|
|
2601
|
+
} = useLlmView(state => state.actions);
|
|
2537
2602
|
useAutosizeTextArea(textArea.current, prompt);
|
|
2538
2603
|
const onChange = event => {
|
|
2539
2604
|
var _a;
|
|
@@ -2719,9 +2784,11 @@ const Cta = props => {
|
|
|
2719
2784
|
const Event = props => {
|
|
2720
2785
|
const label = bomMixerHooks.useLabel();
|
|
2721
2786
|
const {
|
|
2722
|
-
send,
|
|
2723
2787
|
decorateUrl
|
|
2724
2788
|
} = useLlm(state => state.actions);
|
|
2789
|
+
const {
|
|
2790
|
+
send
|
|
2791
|
+
} = useLlmView(state => state.actions);
|
|
2725
2792
|
const onTellMeMore = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2726
2793
|
const prompt = `${label('llm.tellMeMoreAbout')} ${props.title}`;
|
|
2727
2794
|
yield send(prompt, response => {
|
|
@@ -3158,9 +3225,11 @@ const FormRequest = _ref => {
|
|
|
3158
3225
|
const Poi = props => {
|
|
3159
3226
|
const label = bomMixerHooks.useLabel();
|
|
3160
3227
|
const {
|
|
3161
|
-
send,
|
|
3162
3228
|
decorateUrl
|
|
3163
3229
|
} = useLlm(state => state.actions);
|
|
3230
|
+
const {
|
|
3231
|
+
send
|
|
3232
|
+
} = useLlmView(state => state.actions);
|
|
3164
3233
|
const onTellMeMore = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
3165
3234
|
const prompt = `${label('llm.tellMeMoreAbout')} ${props.title}`;
|
|
3166
3235
|
yield send(prompt, response => {
|
|
@@ -3440,11 +3509,11 @@ const Thread = () => {
|
|
|
3440
3509
|
const Main = () => {
|
|
3441
3510
|
var _a;
|
|
3442
3511
|
const lenisRef = react.useRef(null);
|
|
3443
|
-
const embedded = useLlm(state => state.embedded);
|
|
3444
3512
|
const messages = useLlm(state => state.messages);
|
|
3513
|
+
const embedded = useLlmView(state => state.embedded);
|
|
3445
3514
|
const {
|
|
3446
3515
|
setLenis
|
|
3447
|
-
} =
|
|
3516
|
+
} = useLlmView(state => state.actions);
|
|
3448
3517
|
const classNames = bomCore.getClassNames('llm__main');
|
|
3449
3518
|
setLenis((_a = lenisRef.current) === null || _a === void 0 ? void 0 : _a.lenis);
|
|
3450
3519
|
const reveal = {
|
|
@@ -3512,7 +3581,7 @@ const Main = () => {
|
|
|
3512
3581
|
animate: "show",
|
|
3513
3582
|
exit: "exit",
|
|
3514
3583
|
children: !embedded && jsxRuntime.jsx(Header, {})
|
|
3515
|
-
}), jsxRuntime.jsx(
|
|
3584
|
+
}), jsxRuntime.jsx(react$2.ReactLenis, {
|
|
3516
3585
|
ref: lenisRef,
|
|
3517
3586
|
className: "llm__scroller",
|
|
3518
3587
|
children: jsxRuntime.jsxs(framerMotion.motion.div, {
|
|
@@ -3534,10 +3603,10 @@ const Main = () => {
|
|
|
3534
3603
|
};
|
|
3535
3604
|
|
|
3536
3605
|
const Trigger = () => {
|
|
3606
|
+
const app = useLlm(state => state.app);
|
|
3537
3607
|
const {
|
|
3538
3608
|
open
|
|
3539
|
-
} =
|
|
3540
|
-
const app = useLlm(state => state.app);
|
|
3609
|
+
} = useLlmView(state => state.actions);
|
|
3541
3610
|
const label = bomMixerHooks.useLabel();
|
|
3542
3611
|
return jsxRuntime.jsxs(framerMotion.motion.div, {
|
|
3543
3612
|
initial: {
|
|
@@ -3590,13 +3659,16 @@ const LlmComponent = /*#__PURE__*/react.forwardRef((props, ref) => {
|
|
|
3590
3659
|
locale
|
|
3591
3660
|
} = bomMixerHooks.useLayout();
|
|
3592
3661
|
const {
|
|
3593
|
-
init
|
|
3594
|
-
open
|
|
3662
|
+
init
|
|
3595
3663
|
} = useLlm(state => state.actions);
|
|
3596
3664
|
const app = useLlm(state => state.app);
|
|
3597
|
-
const
|
|
3598
|
-
|
|
3599
|
-
|
|
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);
|
|
3600
3672
|
react.useImperativeHandle(ref, () => ({
|
|
3601
3673
|
open: () => {
|
|
3602
3674
|
open();
|
|
@@ -3604,10 +3676,13 @@ const LlmComponent = /*#__PURE__*/react.forwardRef((props, ref) => {
|
|
|
3604
3676
|
}));
|
|
3605
3677
|
react.useEffect(() => {
|
|
3606
3678
|
init(locale);
|
|
3607
|
-
|
|
3679
|
+
initView();
|
|
3680
|
+
}, [init, locale, initView]);
|
|
3608
3681
|
react.useEffect(() => {
|
|
3609
|
-
|
|
3610
|
-
|
|
3682
|
+
if (!embedded) {
|
|
3683
|
+
document.documentElement.style.overflow = opened ? 'hidden' : 'auto';
|
|
3684
|
+
}
|
|
3685
|
+
}, [opened, embedded]);
|
|
3611
3686
|
const mounted = bomMixerHooks.useMounted();
|
|
3612
3687
|
const classNames = bomCore.getClassNames('llm', {
|
|
3613
3688
|
'-open': opened,
|