@websolutespa/bom-mixer-llm 1.8.1 → 1.8.2

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @websolutespa/bom-mixer-llm
2
2
 
3
+ ## 1.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: markdown llm_pill click handler
8
+
3
9
  ## 1.8.1
4
10
 
5
11
  ### Patch Changes
@@ -1337,6 +1337,14 @@ llm-embed {
1337
1337
  background: var(--llm-input-background);
1338
1338
  width: 100%;
1339
1339
  }
1340
+ .llm .llm__prompt-input.-speech-supported > .llm__prompt-textarea {
1341
+ padding: 10px 40px;
1342
+ }
1343
+ @media (min-width: 1024px) {
1344
+ .llm .llm__prompt-input.-speech-supported > .llm__prompt-textarea {
1345
+ padding: 18px 40px;
1346
+ }
1347
+ }
1340
1348
  .llm .llm__prompt-textarea {
1341
1349
  appearance: none;
1342
1350
  display: block;
@@ -1374,14 +1382,6 @@ llm-embed {
1374
1382
  max-height: 220px;
1375
1383
  }
1376
1384
  }
1377
- .-speech-supported .llm .llm__prompt-textarea {
1378
- padding: 10px 40px;
1379
- }
1380
- @media (min-width: 1024px) {
1381
- .-speech-supported .llm .llm__prompt-textarea {
1382
- padding: 18px 40px;
1383
- }
1384
- }
1385
1385
  .llm .llm__prompt-speak, .llm .llm__prompt-microphone {
1386
1386
  position: absolute;
1387
1387
  display: flex;
@@ -1683,6 +1683,10 @@ llm-embed {
1683
1683
  height: 320px;
1684
1684
  object-fit: cover;
1685
1685
  }
1686
+ .llm .llm__message--assistant .llm__inner--string .llm__text .llm__text-body .llm__pill {
1687
+ max-width: max(400px, 30vw);
1688
+ margin-bottom: 1em;
1689
+ }
1686
1690
  .llm .llm__text-disclaimer {
1687
1691
  line-height: 1;
1688
1692
  font-family: var(--llm-font-secondary);
package/dist/cjs/index.js CHANGED
@@ -1455,7 +1455,7 @@ class MessageService {
1455
1455
  mockMessage(request, onMessage, onEnd, onChunk) {
1456
1456
  return __awaiter(this, void 0, void 0, function* () {
1457
1457
  var _a, e_2, _b, _c;
1458
- console.log('mockMessage', request);
1458
+ // console.log('mockMessage', request);
1459
1459
  this.abort();
1460
1460
  const aborter = new AbortController();
1461
1461
  const {
@@ -2311,7 +2311,7 @@ const createLlmViewStore = _ref => {
2311
2311
  */
2312
2312
  if (scroller_) {
2313
2313
  const userMessages = Array.from(document.querySelectorAll('.llm.-open .llm__message.llm__message--user'));
2314
- console.log(userMessages);
2314
+ // console.log(userMessages);
2315
2315
  if (userMessages.length > 0) {
2316
2316
  const lastUserMessage = userMessages.pop();
2317
2317
  lastUserMessage.scrollIntoView({
@@ -3560,7 +3560,7 @@ const Prompt = () => {
3560
3560
  const textArea = react.useRef(null);
3561
3561
  const app = useLlm(state => state.app);
3562
3562
  const prompt = useLlm(state => state.prompt);
3563
- useLlm(state => state.messages);
3563
+ const messages = useLlm(state => state.messages);
3564
3564
  const streaming = useLlm(state => state.streaming);
3565
3565
  const speakEnabled = useLlm(state => state.speakEnabled);
3566
3566
  const {
@@ -3601,7 +3601,7 @@ const Prompt = () => {
3601
3601
  className: "llm__prompt",
3602
3602
  children: jsxRuntime.jsxs("div", {
3603
3603
  className: "llm-container",
3604
- children: [jsxRuntime.jsx("div", {
3604
+ children: [messages.length === 0 && jsxRuntime.jsx("div", {
3605
3605
  className: "llm__prompt-suggestions",
3606
3606
  children: jsxRuntime.jsx(Suggestions, {})
3607
3607
  }), jsxRuntime.jsxs("form", {
@@ -4600,7 +4600,12 @@ function getEmailHtml(data, app) {
4600
4600
  const Text = props => {
4601
4601
  const label = bomMixerHooks.useLabel();
4602
4602
  const app = useLlm(state => state.app);
4603
+ const {
4604
+ send
4605
+ } = useLlmView(state => state.actions);
4603
4606
  const appDisclaimer = app === null || app === void 0 ? void 0 : app.contents.disclaimer;
4607
+ const disclaimer = props.disclaimer ? appDisclaimer || label('llm.disclaimer') : '';
4608
+ const htmlRef = react.useRef(null);
4604
4609
  const html = react.useMemo(() => {
4605
4610
  marked.marked.use({
4606
4611
  renderer: {
@@ -4617,14 +4622,39 @@ const Text = props => {
4617
4622
  <img src="${href}"${title ? ` title="${title}"` : ''} alt="${text}" />
4618
4623
  </a>`;
4619
4624
  }
4625
+ /*
4626
+ html(html: string, block?: boolean) {
4627
+ console.log('html', html);
4628
+ return html;
4629
+ },
4630
+ */
4620
4631
  }
4621
4632
  });
4622
4633
  return marked.marked.parse(props.body);
4623
4634
  }, [props.body]);
4624
- const disclaimer = props.disclaimer ? appDisclaimer || label('llm.disclaimer') : '';
4635
+ react.useEffect(() => {
4636
+ let pills = [];
4637
+ if (htmlRef.current) {
4638
+ pills = Array.from(htmlRef.current.querySelectorAll('.llm__pill'));
4639
+ }
4640
+ const pillClickHandler = event => __awaiter(void 0, void 0, void 0, function* () {
4641
+ if (event.currentTarget) {
4642
+ yield send(event.currentTarget.innerText, response => {
4643
+ // console.log('Suggestions.onMessage', response.chunks);
4644
+ }, response => {
4645
+ // console.log('Suggestions.onEnd', response);
4646
+ });
4647
+ }
4648
+ });
4649
+ pills.forEach(x => x.addEventListener('click', pillClickHandler));
4650
+ return () => {
4651
+ pills.forEach(x => x.removeEventListener('click', pillClickHandler));
4652
+ };
4653
+ }, [props.body, send]);
4625
4654
  return jsxRuntime.jsxs("div", {
4626
4655
  className: "llm__text",
4627
4656
  children: [jsxRuntime.jsx("div", {
4657
+ ref: htmlRef,
4628
4658
  className: "llm__text-body",
4629
4659
  dangerouslySetInnerHTML: {
4630
4660
  __html: html