@websolutespa/bom-mixer-llm 0.0.14 → 1.8.0
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 +14 -0
- package/dist/cjs/index.css +2 -2
- package/dist/cjs/index.js +55 -29
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.css +2 -2
- package/dist/esm/llm/components/Card/card.js +16 -10
- package/dist/esm/llm/components/Card/card.js.map +1 -1
- package/dist/esm/llm/components/Prompt/prompt.js +2 -2
- package/dist/esm/llm/components/Prompt/prompt.js.map +1 -1
- package/dist/esm/llm/llm.js +2 -1
- package/dist/esm/llm/llm.js.map +1 -1
- package/dist/esm/useLlm/useLlm.js +4 -1
- package/dist/esm/useLlm/useLlm.js.map +1 -1
- package/dist/esm/useLlm/useLlmView.js +31 -15
- package/dist/esm/useLlm/useLlmView.js.map +1 -1
- package/dist/types/llm/components/Card/card.d.ts.map +1 -1
- package/dist/types/llm/components/Prompt/prompt.d.ts.map +1 -1
- package/dist/types/llm/llm.d.ts.map +1 -1
- package/dist/types/useLlm/useLlm.d.ts +1 -1
- package/dist/types/useLlm/useLlm.d.ts.map +1 -1
- package/dist/types/useLlm/useLlmView.d.ts +1 -1
- package/dist/types/useLlm/useLlmView.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/llm/components/Card/card.tsx +10 -7
- package/src/llm/components/Main/_style.scss +4 -2
- package/src/llm/components/Prompt/prompt.tsx +7 -2
- package/src/llm/llm.tsx +2 -1
- package/src/useLlm/useLlm.tsx +5 -2
- package/src/useLlm/useLlmView.tsx +30 -16
- /package/src/{swiper.d.ts → global.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @websolutespa/bom-mixer-llm
|
|
2
2
|
|
|
3
|
+
## 1.8.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [f8a1d97]
|
|
8
|
+
- @websolutespa/bom-core@1.8.0
|
|
9
|
+
- @websolutespa/bom-mixer-hooks@1.8.0
|
|
10
|
+
|
|
11
|
+
## 0.0.15
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Modified: scroll behaviour
|
|
16
|
+
|
|
3
17
|
## 0.0.14
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/cjs/index.css
CHANGED
|
@@ -1016,12 +1016,12 @@ llm-embed {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
.llm:not(.-embedded) .llm__content {
|
|
1018
1018
|
padding-top: 100px;
|
|
1019
|
-
padding-bottom:
|
|
1019
|
+
padding-bottom: calc(100vh - 240px);
|
|
1020
1020
|
}
|
|
1021
1021
|
@media (min-width: 1024px) {
|
|
1022
1022
|
.llm:not(.-embedded) .llm__content {
|
|
1023
1023
|
padding-top: 200px;
|
|
1024
|
-
padding-bottom:
|
|
1024
|
+
padding-bottom: calc(100vh - 240px);
|
|
1025
1025
|
}
|
|
1026
1026
|
}
|
|
1027
1027
|
.llm:not(.-embedded).-custom-intro .llm__content {
|
package/dist/cjs/index.js
CHANGED
|
@@ -2207,7 +2207,6 @@ const createLlmViewStore = _ref => {
|
|
|
2207
2207
|
direction: 0
|
|
2208
2208
|
};
|
|
2209
2209
|
let scroller_ = undefined;
|
|
2210
|
-
let autoScroll = true;
|
|
2211
2210
|
const useStore = zustand.createStore((set, get) => {
|
|
2212
2211
|
const onScrollerScroll = event => {
|
|
2213
2212
|
const {
|
|
@@ -2216,14 +2215,9 @@ const createLlmViewStore = _ref => {
|
|
|
2216
2215
|
limit
|
|
2217
2216
|
} = event;
|
|
2218
2217
|
// console.log('onScrollerScroll', direction, targetScroll, limit);
|
|
2219
|
-
if (limit === targetScroll) {
|
|
2220
|
-
autoScroll = true;
|
|
2221
|
-
} else if (direction == -1 && Math.abs(limit - targetScroll) > 100) {
|
|
2222
|
-
autoScroll = false;
|
|
2223
|
-
}
|
|
2224
2218
|
const scrolled = targetScroll > 100;
|
|
2225
|
-
const fixed = direction == -1 && scrolled
|
|
2226
|
-
const hidden =
|
|
2219
|
+
const fixed = direction == -1 && scrolled;
|
|
2220
|
+
const hidden = direction == 1 && scrolled;
|
|
2227
2221
|
const state = get();
|
|
2228
2222
|
if (state.hidden !== hidden || state.fixed !== fixed || state.direction !== direction) {
|
|
2229
2223
|
set(state => ({
|
|
@@ -2306,16 +2300,38 @@ const createLlmViewStore = _ref => {
|
|
|
2306
2300
|
handleIntersection();
|
|
2307
2301
|
},
|
|
2308
2302
|
send: (prompt, onMessage, onEnd) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2303
|
+
yield send(prompt, () => {
|
|
2304
|
+
set({
|
|
2305
|
+
skipCustomIntro: true
|
|
2306
|
+
});
|
|
2307
|
+
setTimeout(() => {
|
|
2308
|
+
/*
|
|
2309
|
+
const state = get();
|
|
2310
|
+
state.actions.scrollToBottom();
|
|
2311
|
+
*/
|
|
2312
|
+
if (scroller_) {
|
|
2313
|
+
const userMessages = Array.from(document.querySelectorAll('.llm.-open .llm__message.llm__message--user'));
|
|
2314
|
+
console.log(userMessages);
|
|
2315
|
+
if (userMessages.length > 0) {
|
|
2316
|
+
const lastUserMessage = userMessages.pop();
|
|
2317
|
+
lastUserMessage.scrollIntoView({
|
|
2318
|
+
behavior: 'instant',
|
|
2319
|
+
block: 'start',
|
|
2320
|
+
inline: 'start'
|
|
2321
|
+
});
|
|
2322
|
+
/*
|
|
2323
|
+
scroller_.scrollTo(lastUserMessage, {
|
|
2324
|
+
immediate: true,
|
|
2325
|
+
});
|
|
2326
|
+
*/
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
}, 50);
|
|
2330
|
+
}, response => {
|
|
2314
2331
|
if (typeof onMessage === 'function') {
|
|
2315
2332
|
onMessage(response);
|
|
2316
2333
|
}
|
|
2317
2334
|
}, response => {
|
|
2318
|
-
state.actions.scrollToBottom();
|
|
2319
2335
|
if (typeof onEnd === 'function') {
|
|
2320
2336
|
onEnd(response);
|
|
2321
2337
|
}
|
|
@@ -2356,7 +2372,7 @@ const createLlmViewStore = _ref => {
|
|
|
2356
2372
|
}
|
|
2357
2373
|
},
|
|
2358
2374
|
scrollToBottom: () => {
|
|
2359
|
-
if (scroller_
|
|
2375
|
+
if (scroller_) {
|
|
2360
2376
|
scroller_.scrollTo('bottom', {
|
|
2361
2377
|
immediate: true
|
|
2362
2378
|
});
|
|
@@ -2502,7 +2518,7 @@ const createLlmStore = _ref => {
|
|
|
2502
2518
|
locale
|
|
2503
2519
|
}, thread));
|
|
2504
2520
|
}),
|
|
2505
|
-
send: (prompt, onMessage, onEnd) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2521
|
+
send: (prompt, onPrompt, onMessage, onEnd) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2506
2522
|
const state = get();
|
|
2507
2523
|
messageService = new MessageService({
|
|
2508
2524
|
apiKey,
|
|
@@ -2518,6 +2534,9 @@ const createLlmStore = _ref => {
|
|
|
2518
2534
|
prompt: '',
|
|
2519
2535
|
streaming: true
|
|
2520
2536
|
}));
|
|
2537
|
+
if (typeof onPrompt === 'function') {
|
|
2538
|
+
onPrompt();
|
|
2539
|
+
}
|
|
2521
2540
|
const request = yield messageService.getRequest(messages, state.threadId);
|
|
2522
2541
|
const speechReader = speech.getReader();
|
|
2523
2542
|
yield messageService.sendMessage(request,
|
|
@@ -3541,7 +3560,7 @@ const Prompt = () => {
|
|
|
3541
3560
|
const textArea = react.useRef(null);
|
|
3542
3561
|
const app = useLlm(state => state.app);
|
|
3543
3562
|
const prompt = useLlm(state => state.prompt);
|
|
3544
|
-
|
|
3563
|
+
useLlm(state => state.messages);
|
|
3545
3564
|
const streaming = useLlm(state => state.streaming);
|
|
3546
3565
|
const speakEnabled = useLlm(state => state.speakEnabled);
|
|
3547
3566
|
const {
|
|
@@ -3582,7 +3601,7 @@ const Prompt = () => {
|
|
|
3582
3601
|
className: "llm__prompt",
|
|
3583
3602
|
children: jsxRuntime.jsxs("div", {
|
|
3584
3603
|
className: "llm-container",
|
|
3585
|
-
children: [
|
|
3604
|
+
children: [jsxRuntime.jsx("div", {
|
|
3586
3605
|
className: "llm__prompt-suggestions",
|
|
3587
3606
|
children: jsxRuntime.jsx(Suggestions, {})
|
|
3588
3607
|
}), jsxRuntime.jsxs("form", {
|
|
@@ -4061,16 +4080,9 @@ const CardWrapper = _a => {
|
|
|
4061
4080
|
children
|
|
4062
4081
|
} = _a,
|
|
4063
4082
|
props = __rest(_a, ["children"]);
|
|
4064
|
-
const label =
|
|
4083
|
+
// const label = useLabel();
|
|
4065
4084
|
const classNames = bomCore.getClassNames('llm__card', `llm__card--${props.cardType}`);
|
|
4066
|
-
return
|
|
4067
|
-
className: classNames,
|
|
4068
|
-
href: props.cta.url,
|
|
4069
|
-
target: "_blank",
|
|
4070
|
-
rel: "noreferrer",
|
|
4071
|
-
"aria-label": props.cta.label || label('llm.tellMeMore'),
|
|
4072
|
-
children: children
|
|
4073
|
-
}) : jsxRuntime.jsx("div", {
|
|
4085
|
+
return jsxRuntime.jsx("div", {
|
|
4074
4086
|
className: classNames,
|
|
4075
4087
|
children: children
|
|
4076
4088
|
});
|
|
@@ -4078,7 +4090,20 @@ const CardWrapper = _a => {
|
|
|
4078
4090
|
const Card = props => {
|
|
4079
4091
|
const label = bomMixerHooks.useLabel();
|
|
4080
4092
|
return jsxRuntime.jsxs(CardWrapper, Object.assign({}, props, {
|
|
4081
|
-
children: [props.media.type === 'image' && jsxRuntime.jsx("
|
|
4093
|
+
children: [props.media.type === 'image' && props.cta.url && jsxRuntime.jsx("a", {
|
|
4094
|
+
className: "llm__card-media",
|
|
4095
|
+
href: props.cta.url,
|
|
4096
|
+
target: "_blank",
|
|
4097
|
+
rel: "noreferrer",
|
|
4098
|
+
"aria-label": props.cta.label || label('llm.tellMeMore'),
|
|
4099
|
+
children: jsxRuntime.jsx("div", {
|
|
4100
|
+
className: "llm__card-asset",
|
|
4101
|
+
children: jsxRuntime.jsx("img", {
|
|
4102
|
+
src: props.media.src,
|
|
4103
|
+
alt: props.title
|
|
4104
|
+
})
|
|
4105
|
+
})
|
|
4106
|
+
}), props.media.type === 'image' && !props.cta.url && jsxRuntime.jsx("div", {
|
|
4082
4107
|
className: "llm__card-media",
|
|
4083
4108
|
children: jsxRuntime.jsx("div", {
|
|
4084
4109
|
className: "llm__card-asset",
|
|
@@ -5122,6 +5147,7 @@ const LlmComponent = /*#__PURE__*/react.forwardRef((props, ref) => {
|
|
|
5122
5147
|
initIntersection,
|
|
5123
5148
|
open
|
|
5124
5149
|
} = useLlmView(state => state.actions);
|
|
5150
|
+
const skipCustomIntro = useLlmView(state => state.skipCustomIntro);
|
|
5125
5151
|
const idle = useLlmView(state => state.idle);
|
|
5126
5152
|
const opened = useLlmView(state => state.opened);
|
|
5127
5153
|
const introed = useLlmView(state => state.introed);
|
|
@@ -5149,7 +5175,7 @@ const LlmComponent = /*#__PURE__*/react.forwardRef((props, ref) => {
|
|
|
5149
5175
|
const classNames = bomCore.getClassNames('llm', {
|
|
5150
5176
|
'-open': opened,
|
|
5151
5177
|
'-embedded': embedded,
|
|
5152
|
-
'-custom-intro': (app === null || app === void 0 ? void 0 : app.contents.customIntro) != null
|
|
5178
|
+
'-custom-intro': (app === null || app === void 0 ? void 0 : app.contents.customIntro) != null && !skipCustomIntro
|
|
5153
5179
|
});
|
|
5154
5180
|
if (mounted) {
|
|
5155
5181
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|