@digipair/skill-web-chatbot 0.69.2 → 0.70.1

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/index.cjs2.js CHANGED
@@ -37752,14 +37752,14 @@ function indent(str, spaces) {
37752
37752
  var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
37753
37753
  // match is required
37754
37754
  if (!match) {
37755
- return nextMatch = nextMatch1, i = i1, tokens = tokens1, {
37755
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, {
37756
37756
  v: nextMatch1
37757
37757
  };
37758
37758
  }
37759
37759
  var token = match.token, offset = match.offset;
37760
37760
  i1 += offset;
37761
37761
  if (token === " ") {
37762
- return nextMatch = nextMatch1, i = i1, tokens = tokens1, "continue";
37762
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
37763
37763
  }
37764
37764
  tokens1 = _to_consumable_array$c(tokens1).concat([
37765
37765
  token
@@ -37778,7 +37778,7 @@ function indent(str, spaces) {
37778
37778
  if (contextKeys.some(function(el) {
37779
37779
  return el.startsWith(name);
37780
37780
  })) {
37781
- return nextMatch = nextMatch1, i = i1, tokens = tokens1, "continue";
37781
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
37782
37782
  }
37783
37783
  if (dateTimeIdentifiers.some(function(el) {
37784
37784
  return el === name;
@@ -37797,9 +37797,9 @@ function indent(str, spaces) {
37797
37797
  if (dateTimeIdentifiers.some(function(el) {
37798
37798
  return el.startsWith(name);
37799
37799
  })) {
37800
- return nextMatch = nextMatch1, i = i1, tokens = tokens1, "continue";
37800
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
37801
37801
  }
37802
- return nextMatch = nextMatch1, i = i1, tokens = tokens1, {
37802
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, {
37803
37803
  v: nextMatch1
37804
37804
  };
37805
37805
  };
@@ -57878,6 +57878,19 @@ class ChatElement extends r$3 {
57878
57878
  }
57879
57879
  return true;
57880
57880
  }
57881
+ executeBoost(boost) {
57882
+ this.dispatchEvent(new CustomEvent('executeboost', {
57883
+ detail: boost
57884
+ }));
57885
+ }
57886
+ getAvailableBoosts(boosts) {
57887
+ return boosts.filter((boost)=>boost && (boost.standalone || boost.selector) && (boost.standalone || document.querySelectorAll(boost.selector).length === 1)).map((boost)=>_extends({}, boost, {
57888
+ context: {
57889
+ element: boost.standalone ? null : boost.selector
57890
+ },
57891
+ checkUrl: new RegExp(boost.url)
57892
+ })).filter((boost)=>boost.checkUrl.test(window.location.href));
57893
+ }
57881
57894
  pushMessage(message) {
57882
57895
  this.messages.push(message);
57883
57896
  this.requestUpdate();
@@ -57923,7 +57936,9 @@ class ChatElement extends r$3 {
57923
57936
  ${this.messages.filter((message)=>{
57924
57937
  var _this_currentBoost;
57925
57938
  return message.uuid === ((_this_currentBoost = this.currentBoost) == null ? void 0 : _this_currentBoost.parent_history);
57926
- }).map((message)=>x`
57939
+ }).map((message)=>{
57940
+ var _message_sources;
57941
+ return x`
57927
57942
  <ui5-icon
57928
57943
  name="decline"
57929
57944
  class="button action"
@@ -57932,7 +57947,37 @@ class ChatElement extends r$3 {
57932
57947
  }))}
57933
57948
  ></ui5-icon>
57934
57949
  ${o$1(this.converter.makeHtml(message.content.replace(/```markdown([\s\S]*?)```/g, (_, group)=>group)))}
57935
- `)}
57950
+
57951
+ <section class="sources">
57952
+ ${(_message_sources = message.sources) == null ? void 0 : _message_sources.map((source)=>{
57953
+ var _source_document_url;
57954
+ return x`
57955
+ <a
57956
+ class="source ${source.document_url ? 'has-link' : ''}"
57957
+ href=${(_source_document_url = source.document_url) != null ? _source_document_url : 'javascript:'}
57958
+ target="_blank"
57959
+ >
57960
+ ${source.document_name}
57961
+ <div class="trust-bar">
57962
+ <div
57963
+ class="trust-bar-fill"
57964
+ style="width: ${source.rank * 100}%;"
57965
+ ></div>
57966
+ </div>
57967
+ </a>
57968
+ `;
57969
+ })}
57970
+ </section>
57971
+
57972
+ <section class="actions ${this.loading ? 'loading' : ''}">
57973
+ ${this.getAvailableBoosts(message.boosts || []).map((boost)=>x`
57974
+ <span class="action" @click=${()=>this.executeBoost(boost)}
57975
+ >${boost.summary}</span
57976
+ >
57977
+ `)}
57978
+ </section>
57979
+ `;
57980
+ })}
57936
57981
  </section>
57937
57982
  ` : E$1}
57938
57983
  <textarea
@@ -58175,6 +58220,76 @@ ChatElement.styles = [
58175
58220
  .loading img {
58176
58221
  float: left;
58177
58222
  }
58223
+
58224
+ .sources {
58225
+ margin-top: 10px;
58226
+ }
58227
+
58228
+ .sources > .source {
58229
+ background-color: rgba(255, 255, 255, 0.5);
58230
+ font-size: 12px;
58231
+ color: rgb(60, 60, 60);
58232
+ padding: 0px 8px;
58233
+ display: inline-block;
58234
+ transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0s;
58235
+ transform: scale(0.95);
58236
+ margin-bottom: 4px;
58237
+ border-radius: 5px;
58238
+ text-decoration: none;
58239
+ cursor: default;
58240
+ }
58241
+
58242
+ .sources > .source.has-link {
58243
+ background-color: rgba(255, 255, 255, 0.9);
58244
+ cursor: pointer;
58245
+ }
58246
+
58247
+ .sources > .source.has-link:hover {
58248
+ transform: scale(1);
58249
+ }
58250
+
58251
+ .trust-bar {
58252
+ position: relative;
58253
+ width: 100%;
58254
+ height: 3px;
58255
+ background-color: rgba(82, 223, 219, 0.2);
58256
+ border-radius: 5px;
58257
+ overflow: hidden;
58258
+ margin-bottom: 5px;
58259
+ }
58260
+
58261
+ .trust-bar-fill {
58262
+ height: 100%;
58263
+ background-color: green;
58264
+ transition: width 0.3s ease;
58265
+ border-radius: 5px;
58266
+ }
58267
+
58268
+ .boosts {
58269
+ margin-top: 10px;
58270
+ margin-bottom: 5px;
58271
+ }
58272
+
58273
+ .boosts.loading {
58274
+ display: none;
58275
+ }
58276
+
58277
+ .boosts > .boost {
58278
+ background-color: rgba(255, 255, 255, 0.7);
58279
+ border-radius: 20px;
58280
+ font-size: 10px;
58281
+ color: rgb(60, 60, 60);
58282
+ padding: 4px 14px;
58283
+ cursor: pointer;
58284
+ display: inline-block;
58285
+ transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0s;
58286
+ transform: scale(0.95);
58287
+ margin-bottom: 1px;
58288
+ }
58289
+
58290
+ .boosts > .boost:hover {
58291
+ transform: scale(1);
58292
+ }
58178
58293
  `
58179
58294
  ];
58180
58295
  __decorate$3([
@@ -59871,6 +59986,8 @@ class ChatbotElement extends r$3 {
59871
59986
  content: detail.assistant,
59872
59987
  uuid: detail.uuid,
59873
59988
  boost: detail.boost,
59989
+ boosts: detail.boosts,
59990
+ sources: detail.sources,
59874
59991
  parent_conversation: detail.parent_conversation,
59875
59992
  parent_history: detail.parent_history
59876
59993
  });
@@ -59893,6 +60010,10 @@ class ChatbotElement extends r$3 {
59893
60010
  executeBoost(boost) {
59894
60011
  this.execute(boost);
59895
60012
  this.openResult();
60013
+ setTimeout(()=>{
60014
+ var _this_chatbot_shadowRoot, _this_chatbot;
60015
+ ((_this_chatbot = this.chatbot) == null ? void 0 : (_this_chatbot_shadowRoot = _this_chatbot.shadowRoot) == null ? void 0 : _this_chatbot_shadowRoot.querySelector('#messageInput')).focus();
60016
+ }, 1);
59896
60017
  }
59897
60018
  pushMessage(message) {
59898
60019
  this.openResult();
@@ -59948,6 +60069,7 @@ class ChatbotElement extends r$3 {
59948
60069
  }}
59949
60070
  loadingStep=${this.loadingStep}
59950
60071
  @prompt=${(event)=>this.execute(this.currentBoost, event.detail.prompt)}
60072
+ @executeboost=${(event)=>this.executeBoost(event.detail)}
59951
60073
  @boost=${(event)=>this.setBoost(event.detail)}
59952
60074
  ></digipair-chatbot-chat>
59953
60075
  </section>
@@ -60295,6 +60417,8 @@ class DigipairFullElement extends r$3 {
60295
60417
  content: detail.assistant,
60296
60418
  uuid: detail.uuid,
60297
60419
  boost: detail.boost,
60420
+ boosts: detail.boosts,
60421
+ sources: detail.sources,
60298
60422
  parent_conversation: detail.parent_conversation,
60299
60423
  parent_history: detail.parent_history
60300
60424
  });
@@ -60370,6 +60494,7 @@ class DigipairFullElement extends r$3 {
60370
60494
  loadingStep=${this.loadingStep}
60371
60495
  @prompt=${(event)=>this.execute(this.currentBoost, event.detail.prompt)}
60372
60496
  @boost=${(event)=>this.setBoost(event.detail)}
60497
+ @executeboost=${(event)=>this.executeBoost(event.detail)}
60373
60498
  ></digipair-chatbot-chat>
60374
60499
  </section>
60375
60500
 
package/index.esm2.js CHANGED
@@ -37732,14 +37732,14 @@ function indent(str, spaces) {
37732
37732
  var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
37733
37733
  // match is required
37734
37734
  if (!match) {
37735
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
37735
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, {
37736
37736
  v: nextMatch1
37737
37737
  };
37738
37738
  }
37739
37739
  var token = match.token, offset = match.offset;
37740
37740
  i1 += offset;
37741
37741
  if (token === " ") {
37742
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
37742
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
37743
37743
  }
37744
37744
  tokens1 = _to_consumable_array$c(tokens1).concat([
37745
37745
  token
@@ -37758,7 +37758,7 @@ function indent(str, spaces) {
37758
37758
  if (contextKeys.some(function(el) {
37759
37759
  return el.startsWith(name);
37760
37760
  })) {
37761
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
37761
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
37762
37762
  }
37763
37763
  if (dateTimeIdentifiers.some(function(el) {
37764
37764
  return el === name;
@@ -37777,9 +37777,9 @@ function indent(str, spaces) {
37777
37777
  if (dateTimeIdentifiers.some(function(el) {
37778
37778
  return el.startsWith(name);
37779
37779
  })) {
37780
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
37780
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
37781
37781
  }
37782
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
37782
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, {
37783
37783
  v: nextMatch1
37784
37784
  };
37785
37785
  };
@@ -57858,6 +57858,19 @@ class ChatElement extends r$3 {
57858
57858
  }
57859
57859
  return true;
57860
57860
  }
57861
+ executeBoost(boost) {
57862
+ this.dispatchEvent(new CustomEvent('executeboost', {
57863
+ detail: boost
57864
+ }));
57865
+ }
57866
+ getAvailableBoosts(boosts) {
57867
+ return boosts.filter((boost)=>boost && (boost.standalone || boost.selector) && (boost.standalone || document.querySelectorAll(boost.selector).length === 1)).map((boost)=>_extends({}, boost, {
57868
+ context: {
57869
+ element: boost.standalone ? null : boost.selector
57870
+ },
57871
+ checkUrl: new RegExp(boost.url)
57872
+ })).filter((boost)=>boost.checkUrl.test(window.location.href));
57873
+ }
57861
57874
  pushMessage(message) {
57862
57875
  this.messages.push(message);
57863
57876
  this.requestUpdate();
@@ -57903,7 +57916,9 @@ class ChatElement extends r$3 {
57903
57916
  ${this.messages.filter((message)=>{
57904
57917
  var _this_currentBoost;
57905
57918
  return message.uuid === ((_this_currentBoost = this.currentBoost) == null ? void 0 : _this_currentBoost.parent_history);
57906
- }).map((message)=>x`
57919
+ }).map((message)=>{
57920
+ var _message_sources;
57921
+ return x`
57907
57922
  <ui5-icon
57908
57923
  name="decline"
57909
57924
  class="button action"
@@ -57912,7 +57927,37 @@ class ChatElement extends r$3 {
57912
57927
  }))}
57913
57928
  ></ui5-icon>
57914
57929
  ${o$1(this.converter.makeHtml(message.content.replace(/```markdown([\s\S]*?)```/g, (_, group)=>group)))}
57915
- `)}
57930
+
57931
+ <section class="sources">
57932
+ ${(_message_sources = message.sources) == null ? void 0 : _message_sources.map((source)=>{
57933
+ var _source_document_url;
57934
+ return x`
57935
+ <a
57936
+ class="source ${source.document_url ? 'has-link' : ''}"
57937
+ href=${(_source_document_url = source.document_url) != null ? _source_document_url : 'javascript:'}
57938
+ target="_blank"
57939
+ >
57940
+ ${source.document_name}
57941
+ <div class="trust-bar">
57942
+ <div
57943
+ class="trust-bar-fill"
57944
+ style="width: ${source.rank * 100}%;"
57945
+ ></div>
57946
+ </div>
57947
+ </a>
57948
+ `;
57949
+ })}
57950
+ </section>
57951
+
57952
+ <section class="actions ${this.loading ? 'loading' : ''}">
57953
+ ${this.getAvailableBoosts(message.boosts || []).map((boost)=>x`
57954
+ <span class="action" @click=${()=>this.executeBoost(boost)}
57955
+ >${boost.summary}</span
57956
+ >
57957
+ `)}
57958
+ </section>
57959
+ `;
57960
+ })}
57916
57961
  </section>
57917
57962
  ` : E$1}
57918
57963
  <textarea
@@ -58155,6 +58200,76 @@ ChatElement.styles = [
58155
58200
  .loading img {
58156
58201
  float: left;
58157
58202
  }
58203
+
58204
+ .sources {
58205
+ margin-top: 10px;
58206
+ }
58207
+
58208
+ .sources > .source {
58209
+ background-color: rgba(255, 255, 255, 0.5);
58210
+ font-size: 12px;
58211
+ color: rgb(60, 60, 60);
58212
+ padding: 0px 8px;
58213
+ display: inline-block;
58214
+ transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0s;
58215
+ transform: scale(0.95);
58216
+ margin-bottom: 4px;
58217
+ border-radius: 5px;
58218
+ text-decoration: none;
58219
+ cursor: default;
58220
+ }
58221
+
58222
+ .sources > .source.has-link {
58223
+ background-color: rgba(255, 255, 255, 0.9);
58224
+ cursor: pointer;
58225
+ }
58226
+
58227
+ .sources > .source.has-link:hover {
58228
+ transform: scale(1);
58229
+ }
58230
+
58231
+ .trust-bar {
58232
+ position: relative;
58233
+ width: 100%;
58234
+ height: 3px;
58235
+ background-color: rgba(82, 223, 219, 0.2);
58236
+ border-radius: 5px;
58237
+ overflow: hidden;
58238
+ margin-bottom: 5px;
58239
+ }
58240
+
58241
+ .trust-bar-fill {
58242
+ height: 100%;
58243
+ background-color: green;
58244
+ transition: width 0.3s ease;
58245
+ border-radius: 5px;
58246
+ }
58247
+
58248
+ .boosts {
58249
+ margin-top: 10px;
58250
+ margin-bottom: 5px;
58251
+ }
58252
+
58253
+ .boosts.loading {
58254
+ display: none;
58255
+ }
58256
+
58257
+ .boosts > .boost {
58258
+ background-color: rgba(255, 255, 255, 0.7);
58259
+ border-radius: 20px;
58260
+ font-size: 10px;
58261
+ color: rgb(60, 60, 60);
58262
+ padding: 4px 14px;
58263
+ cursor: pointer;
58264
+ display: inline-block;
58265
+ transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0s;
58266
+ transform: scale(0.95);
58267
+ margin-bottom: 1px;
58268
+ }
58269
+
58270
+ .boosts > .boost:hover {
58271
+ transform: scale(1);
58272
+ }
58158
58273
  `
58159
58274
  ];
58160
58275
  __decorate$3([
@@ -59851,6 +59966,8 @@ class ChatbotElement extends r$3 {
59851
59966
  content: detail.assistant,
59852
59967
  uuid: detail.uuid,
59853
59968
  boost: detail.boost,
59969
+ boosts: detail.boosts,
59970
+ sources: detail.sources,
59854
59971
  parent_conversation: detail.parent_conversation,
59855
59972
  parent_history: detail.parent_history
59856
59973
  });
@@ -59873,6 +59990,10 @@ class ChatbotElement extends r$3 {
59873
59990
  executeBoost(boost) {
59874
59991
  this.execute(boost);
59875
59992
  this.openResult();
59993
+ setTimeout(()=>{
59994
+ var _this_chatbot_shadowRoot, _this_chatbot;
59995
+ ((_this_chatbot = this.chatbot) == null ? void 0 : (_this_chatbot_shadowRoot = _this_chatbot.shadowRoot) == null ? void 0 : _this_chatbot_shadowRoot.querySelector('#messageInput')).focus();
59996
+ }, 1);
59876
59997
  }
59877
59998
  pushMessage(message) {
59878
59999
  this.openResult();
@@ -59928,6 +60049,7 @@ class ChatbotElement extends r$3 {
59928
60049
  }}
59929
60050
  loadingStep=${this.loadingStep}
59930
60051
  @prompt=${(event)=>this.execute(this.currentBoost, event.detail.prompt)}
60052
+ @executeboost=${(event)=>this.executeBoost(event.detail)}
59931
60053
  @boost=${(event)=>this.setBoost(event.detail)}
59932
60054
  ></digipair-chatbot-chat>
59933
60055
  </section>
@@ -60275,6 +60397,8 @@ class DigipairFullElement extends r$3 {
60275
60397
  content: detail.assistant,
60276
60398
  uuid: detail.uuid,
60277
60399
  boost: detail.boost,
60400
+ boosts: detail.boosts,
60401
+ sources: detail.sources,
60278
60402
  parent_conversation: detail.parent_conversation,
60279
60403
  parent_history: detail.parent_history
60280
60404
  });
@@ -60350,6 +60474,7 @@ class DigipairFullElement extends r$3 {
60350
60474
  loadingStep=${this.loadingStep}
60351
60475
  @prompt=${(event)=>this.execute(this.currentBoost, event.detail.prompt)}
60352
60476
  @boost=${(event)=>this.setBoost(event.detail)}
60477
+ @executeboost=${(event)=>this.executeBoost(event.detail)}
60353
60478
  ></digipair-chatbot-chat>
60354
60479
  </section>
60355
60480
 
@@ -21,6 +21,8 @@ export declare class ChatElement extends LitElement {
21
21
  private hasInputsValues;
22
22
  private answer;
23
23
  private canAnswerToMessageBoost;
24
+ private executeBoost;
25
+ private getAvailableBoosts;
24
26
  pushMessage(message: any): void;
25
27
  render(): TemplateResult;
26
28
  }
@@ -3,6 +3,8 @@ export interface Message {
3
3
  content: string;
4
4
  uuid?: string;
5
5
  boost?: any;
6
+ boosts?: any[];
7
+ sources?: any[];
6
8
  parent_conversation?: string;
7
9
  parent_history?: string;
8
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-web-chatbot",
3
- "version": "0.69.2",
3
+ "version": "0.70.1",
4
4
  "keywords": [
5
5
  "digipair",
6
6
  "web"