@websolutespa/bom-llm 0.0.56 → 0.0.58
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 +12 -0
- package/README.md +17 -0
- package/dist/index.d.ts +7 -0
- package/dist/umd/index.css +81 -2
- package/dist/umd/index.js +139 -58
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -131,6 +131,23 @@ decorateUrl method can be a promise.
|
|
|
131
131
|
bomLlm(options);
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
+
### Handling external actions
|
|
135
|
+
|
|
136
|
+
You can handle the click event of the generated cta action with the onAction handler.
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
140
|
+
const options = {
|
|
141
|
+
appKey: 'MY_APP_KEY',
|
|
142
|
+
apiKey: 'MY_API_KEY',
|
|
143
|
+
threadId: searchParams.get('llmThreadId'),
|
|
144
|
+
onAction: (item) => {
|
|
145
|
+
console.log('onAction', item.id, item.title);
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
bomLlm(options);
|
|
149
|
+
```
|
|
150
|
+
|
|
134
151
|
### Supported types
|
|
135
152
|
|
|
136
153
|
Currently available types are:
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ type DeepPartial<T> = T extends object ? {
|
|
|
4
4
|
type LlmItem = Record<string, any> & {
|
|
5
5
|
type: string;
|
|
6
6
|
};
|
|
7
|
+
type LlmAction = Record<string, any> & {
|
|
8
|
+
type: 'action' | 'actionItem';
|
|
9
|
+
id: string | number;
|
|
10
|
+
title: string;
|
|
11
|
+
};
|
|
7
12
|
type LlmTheme = any;
|
|
8
13
|
type IMedia = Record<string, unknown> & {
|
|
9
14
|
abstract?: string;
|
|
@@ -86,6 +91,7 @@ type LlmMock = {
|
|
|
86
91
|
};
|
|
87
92
|
type LlmTest = undefined | boolean | DeepPartial<LlmMock>;
|
|
88
93
|
type LlmDecorateUrl = (item: LlmItem) => (string | void) | Promise<string | void>;
|
|
94
|
+
type LlmOnAction = (item: LlmAction) => (void) | Promise<boolean | void>;
|
|
89
95
|
type LlmViewOptions = {
|
|
90
96
|
threadId?: string;
|
|
91
97
|
preview?: boolean;
|
|
@@ -99,6 +105,7 @@ type LlmOptions = {
|
|
|
99
105
|
apiKey: string;
|
|
100
106
|
appKey: string;
|
|
101
107
|
decorateUrl?: LlmDecorateUrl;
|
|
108
|
+
onAction?: LlmOnAction;
|
|
102
109
|
test?: LlmTest;
|
|
103
110
|
customTheme?: Partial<LlmTheme>;
|
|
104
111
|
locale?: string;
|
package/dist/umd/index.css
CHANGED
|
@@ -511,11 +511,14 @@ llm-embed {
|
|
|
511
511
|
margin: 0;
|
|
512
512
|
padding: 0;
|
|
513
513
|
border: none;
|
|
514
|
+
border-radius: 0;
|
|
514
515
|
text-decoration: none;
|
|
515
516
|
background: none;
|
|
517
|
+
color: inherit;
|
|
516
518
|
appearance: none;
|
|
517
519
|
font-family: inherit;
|
|
518
520
|
font-style: inherit;
|
|
521
|
+
font-size: inherit;
|
|
519
522
|
font-variant-ligatures: inherit;
|
|
520
523
|
font-variant-caps: inherit;
|
|
521
524
|
font-variant-numeric: inherit;
|
|
@@ -628,11 +631,14 @@ llm-embed {
|
|
|
628
631
|
margin: 0;
|
|
629
632
|
padding: 0;
|
|
630
633
|
border: none;
|
|
634
|
+
border-radius: 0;
|
|
631
635
|
text-decoration: none;
|
|
632
636
|
background: none;
|
|
637
|
+
color: inherit;
|
|
633
638
|
appearance: none;
|
|
634
639
|
font-family: inherit;
|
|
635
640
|
font-style: inherit;
|
|
641
|
+
font-size: inherit;
|
|
636
642
|
font-variant-ligatures: inherit;
|
|
637
643
|
font-variant-caps: inherit;
|
|
638
644
|
font-variant-numeric: inherit;
|
|
@@ -934,7 +940,7 @@ llm-embed {
|
|
|
934
940
|
.llm .llm__header-wrapper {
|
|
935
941
|
display: flex;
|
|
936
942
|
justify-content: space-between;
|
|
937
|
-
padding: 0 var(--llm-size-5, 2.5rem);
|
|
943
|
+
padding: 0 min(var(--llm-size-5, 2.5rem), clamp(20px * var(--s, 1), 20px * var(--s, 1) + (var(--u, 1vw) * 100 - 375px) / 1545 * 90 * var(--s, 1), 110px * var(--s, 1)));
|
|
938
944
|
align-items: center;
|
|
939
945
|
height: 70px;
|
|
940
946
|
z-index: 2;
|
|
@@ -995,11 +1001,14 @@ llm-embed {
|
|
|
995
1001
|
margin: 0;
|
|
996
1002
|
padding: 0;
|
|
997
1003
|
border: none;
|
|
1004
|
+
border-radius: 0;
|
|
998
1005
|
text-decoration: none;
|
|
999
1006
|
background: none;
|
|
1007
|
+
color: inherit;
|
|
1000
1008
|
appearance: none;
|
|
1001
1009
|
font-family: inherit;
|
|
1002
1010
|
font-style: inherit;
|
|
1011
|
+
font-size: inherit;
|
|
1003
1012
|
font-variant-ligatures: inherit;
|
|
1004
1013
|
font-variant-caps: inherit;
|
|
1005
1014
|
font-variant-numeric: inherit;
|
|
@@ -1064,11 +1073,14 @@ llm-embed {
|
|
|
1064
1073
|
margin: 0;
|
|
1065
1074
|
padding: 0;
|
|
1066
1075
|
border: none;
|
|
1076
|
+
border-radius: 0;
|
|
1067
1077
|
text-decoration: none;
|
|
1068
1078
|
background: none;
|
|
1079
|
+
color: inherit;
|
|
1069
1080
|
appearance: none;
|
|
1070
1081
|
font-family: inherit;
|
|
1071
1082
|
font-style: inherit;
|
|
1083
|
+
font-size: inherit;
|
|
1072
1084
|
font-variant-ligatures: inherit;
|
|
1073
1085
|
font-variant-caps: inherit;
|
|
1074
1086
|
font-variant-numeric: inherit;
|
|
@@ -1138,11 +1150,14 @@ llm-embed {
|
|
|
1138
1150
|
margin: 0;
|
|
1139
1151
|
padding: 0;
|
|
1140
1152
|
border: none;
|
|
1153
|
+
border-radius: 0;
|
|
1141
1154
|
text-decoration: none;
|
|
1142
1155
|
background: none;
|
|
1156
|
+
color: inherit;
|
|
1143
1157
|
appearance: none;
|
|
1144
1158
|
font-family: inherit;
|
|
1145
1159
|
font-style: inherit;
|
|
1160
|
+
font-size: inherit;
|
|
1146
1161
|
font-variant-ligatures: inherit;
|
|
1147
1162
|
font-variant-caps: inherit;
|
|
1148
1163
|
font-variant-numeric: inherit;
|
|
@@ -1241,6 +1256,16 @@ llm-embed {
|
|
|
1241
1256
|
.llm .llm__intro-blob > div {
|
|
1242
1257
|
height: 100%;
|
|
1243
1258
|
}
|
|
1259
|
+
.llm.-chat .llm__intro-blob {
|
|
1260
|
+
width: 50px;
|
|
1261
|
+
height: 50px;
|
|
1262
|
+
}
|
|
1263
|
+
@media (min-width: 1440px) {
|
|
1264
|
+
.llm.-chat .llm__intro-blob {
|
|
1265
|
+
width: 60px;
|
|
1266
|
+
height: 60px;
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1244
1269
|
@media (min-width: 1024px) {
|
|
1245
1270
|
.llm .llm__intro-wrapper {
|
|
1246
1271
|
justify-content: space-between;
|
|
@@ -1252,6 +1277,9 @@ llm-embed {
|
|
|
1252
1277
|
gap: var(--llm-size-5, 2.5rem);
|
|
1253
1278
|
color: var(--llm-color-title-foreground);
|
|
1254
1279
|
}
|
|
1280
|
+
.llm.-chat .llm__intro-text {
|
|
1281
|
+
gap: var(--llm-size-3, 1.5rem);
|
|
1282
|
+
}
|
|
1255
1283
|
.llm .llm__intro-hints {
|
|
1256
1284
|
margin-top: var(--llm-size-5, 2.5rem);
|
|
1257
1285
|
}
|
|
@@ -1260,6 +1288,9 @@ llm-embed {
|
|
|
1260
1288
|
margin-top: 0;
|
|
1261
1289
|
}
|
|
1262
1290
|
}
|
|
1291
|
+
.llm.-chat .llm__intro-hints {
|
|
1292
|
+
margin-top: var(--llm-size-3, 1.5rem);
|
|
1293
|
+
}
|
|
1263
1294
|
.llm .llm__customIntro {
|
|
1264
1295
|
position: absolute;
|
|
1265
1296
|
top: 0;
|
|
@@ -1286,7 +1317,7 @@ llm-embed {
|
|
|
1286
1317
|
}
|
|
1287
1318
|
}
|
|
1288
1319
|
.llm .llm__hints .swiper-wrapper {
|
|
1289
|
-
padding:
|
|
1320
|
+
padding: 4px 0;
|
|
1290
1321
|
}
|
|
1291
1322
|
.llm .llm__hints .swiper-slide {
|
|
1292
1323
|
height: auto;
|
|
@@ -1295,11 +1326,14 @@ llm-embed {
|
|
|
1295
1326
|
margin: 0;
|
|
1296
1327
|
padding: 0;
|
|
1297
1328
|
border: none;
|
|
1329
|
+
border-radius: 0;
|
|
1298
1330
|
text-decoration: none;
|
|
1299
1331
|
background: none;
|
|
1332
|
+
color: inherit;
|
|
1300
1333
|
appearance: none;
|
|
1301
1334
|
font-family: inherit;
|
|
1302
1335
|
font-style: inherit;
|
|
1336
|
+
font-size: inherit;
|
|
1303
1337
|
font-variant-ligatures: inherit;
|
|
1304
1338
|
font-variant-caps: inherit;
|
|
1305
1339
|
font-variant-numeric: inherit;
|
|
@@ -1357,6 +1391,7 @@ llm-embed {
|
|
|
1357
1391
|
}
|
|
1358
1392
|
.llm .llm__hint-title.column {
|
|
1359
1393
|
flex-direction: column;
|
|
1394
|
+
width: 100%;
|
|
1360
1395
|
}
|
|
1361
1396
|
.llm .llm__hint-title i {
|
|
1362
1397
|
flex-shrink: 0;
|
|
@@ -1369,6 +1404,7 @@ llm-embed {
|
|
|
1369
1404
|
fill: currentColor;
|
|
1370
1405
|
}
|
|
1371
1406
|
.llm .llm__hint-body {
|
|
1407
|
+
width: 100%;
|
|
1372
1408
|
line-height: 140%;
|
|
1373
1409
|
}
|
|
1374
1410
|
|
|
@@ -1480,11 +1516,14 @@ llm-embed {
|
|
|
1480
1516
|
margin: 0;
|
|
1481
1517
|
padding: 0;
|
|
1482
1518
|
border: none;
|
|
1519
|
+
border-radius: 0;
|
|
1483
1520
|
text-decoration: none;
|
|
1484
1521
|
background: none;
|
|
1522
|
+
color: inherit;
|
|
1485
1523
|
appearance: none;
|
|
1486
1524
|
font-family: inherit;
|
|
1487
1525
|
font-style: inherit;
|
|
1526
|
+
font-size: inherit;
|
|
1488
1527
|
font-variant-ligatures: inherit;
|
|
1489
1528
|
font-variant-caps: inherit;
|
|
1490
1529
|
font-variant-numeric: inherit;
|
|
@@ -1575,11 +1614,14 @@ llm-embed {
|
|
|
1575
1614
|
margin: 0;
|
|
1576
1615
|
padding: 0;
|
|
1577
1616
|
border: none;
|
|
1617
|
+
border-radius: 0;
|
|
1578
1618
|
text-decoration: none;
|
|
1579
1619
|
background: none;
|
|
1620
|
+
color: inherit;
|
|
1580
1621
|
appearance: none;
|
|
1581
1622
|
font-family: inherit;
|
|
1582
1623
|
font-style: inherit;
|
|
1624
|
+
font-size: inherit;
|
|
1583
1625
|
font-variant-ligatures: inherit;
|
|
1584
1626
|
font-variant-caps: inherit;
|
|
1585
1627
|
font-variant-numeric: inherit;
|
|
@@ -1626,11 +1668,14 @@ llm-embed {
|
|
|
1626
1668
|
margin: 0;
|
|
1627
1669
|
padding: 0;
|
|
1628
1670
|
border: none;
|
|
1671
|
+
border-radius: 0;
|
|
1629
1672
|
text-decoration: none;
|
|
1630
1673
|
background: none;
|
|
1674
|
+
color: inherit;
|
|
1631
1675
|
appearance: none;
|
|
1632
1676
|
font-family: inherit;
|
|
1633
1677
|
font-style: inherit;
|
|
1678
|
+
font-size: inherit;
|
|
1634
1679
|
font-variant-ligatures: inherit;
|
|
1635
1680
|
font-variant-caps: inherit;
|
|
1636
1681
|
font-variant-numeric: inherit;
|
|
@@ -1706,11 +1751,14 @@ llm-embed {
|
|
|
1706
1751
|
margin: 0;
|
|
1707
1752
|
padding: 0;
|
|
1708
1753
|
border: none;
|
|
1754
|
+
border-radius: 0;
|
|
1709
1755
|
text-decoration: none;
|
|
1710
1756
|
background: none;
|
|
1757
|
+
color: inherit;
|
|
1711
1758
|
appearance: none;
|
|
1712
1759
|
font-family: inherit;
|
|
1713
1760
|
font-style: inherit;
|
|
1761
|
+
font-size: inherit;
|
|
1714
1762
|
font-variant-ligatures: inherit;
|
|
1715
1763
|
font-variant-caps: inherit;
|
|
1716
1764
|
font-variant-numeric: inherit;
|
|
@@ -1837,11 +1885,14 @@ llm-embed {
|
|
|
1837
1885
|
margin: 0;
|
|
1838
1886
|
padding: 0;
|
|
1839
1887
|
border: none;
|
|
1888
|
+
border-radius: 0;
|
|
1840
1889
|
text-decoration: none;
|
|
1841
1890
|
background: none;
|
|
1891
|
+
color: inherit;
|
|
1842
1892
|
appearance: none;
|
|
1843
1893
|
font-family: inherit;
|
|
1844
1894
|
font-style: inherit;
|
|
1895
|
+
font-size: inherit;
|
|
1845
1896
|
font-variant-ligatures: inherit;
|
|
1846
1897
|
font-variant-caps: inherit;
|
|
1847
1898
|
font-variant-numeric: inherit;
|
|
@@ -1908,11 +1959,14 @@ llm-embed {
|
|
|
1908
1959
|
margin: 0;
|
|
1909
1960
|
padding: 0;
|
|
1910
1961
|
border: none;
|
|
1962
|
+
border-radius: 0;
|
|
1911
1963
|
text-decoration: none;
|
|
1912
1964
|
background: none;
|
|
1965
|
+
color: inherit;
|
|
1913
1966
|
appearance: none;
|
|
1914
1967
|
font-family: inherit;
|
|
1915
1968
|
font-style: inherit;
|
|
1969
|
+
font-size: inherit;
|
|
1916
1970
|
font-variant-ligatures: inherit;
|
|
1917
1971
|
font-variant-caps: inherit;
|
|
1918
1972
|
font-variant-numeric: inherit;
|
|
@@ -1971,11 +2025,14 @@ llm-embed {
|
|
|
1971
2025
|
margin: 0;
|
|
1972
2026
|
padding: 0;
|
|
1973
2027
|
border: none;
|
|
2028
|
+
border-radius: 0;
|
|
1974
2029
|
text-decoration: none;
|
|
1975
2030
|
background: none;
|
|
2031
|
+
color: inherit;
|
|
1976
2032
|
appearance: none;
|
|
1977
2033
|
font-family: inherit;
|
|
1978
2034
|
font-style: inherit;
|
|
2035
|
+
font-size: inherit;
|
|
1979
2036
|
font-variant-ligatures: inherit;
|
|
1980
2037
|
font-variant-caps: inherit;
|
|
1981
2038
|
font-variant-numeric: inherit;
|
|
@@ -2049,6 +2106,21 @@ llm-embed {
|
|
|
2049
2106
|
border-radius: 12px;
|
|
2050
2107
|
padding: var(--llm-size-3, 1.5rem) var(--llm-size-4, 2rem);
|
|
2051
2108
|
}
|
|
2109
|
+
.llm.-chat .llm__message--user .llm__text {
|
|
2110
|
+
display: flex;
|
|
2111
|
+
flex-direction: column;
|
|
2112
|
+
}
|
|
2113
|
+
.llm.-chat .llm__message--user .llm__text .llm__text-body {
|
|
2114
|
+
align-self: flex-end;
|
|
2115
|
+
padding: 0.5em 0;
|
|
2116
|
+
padding: var(--llm-pill-padding, 8px);
|
|
2117
|
+
border: var(--llm-pill-border);
|
|
2118
|
+
border-radius: var(--llm-pill-border-radius);
|
|
2119
|
+
background: var(--llm-pill-background);
|
|
2120
|
+
color: var(--llm-pill-foreground);
|
|
2121
|
+
font-family: var(--llm-pill-font-family);
|
|
2122
|
+
text-align: right;
|
|
2123
|
+
}
|
|
2052
2124
|
.llm .llm__message--assistant .llm__inner--text:first-child .llm__text .llm__text-body, .llm .llm__message--assistant .llm__inner--text:first-child .llm__text .llm__text-body > p, .llm .llm__message--assistant .llm__inner--text:first-child .llm__text .llm__text-body > h2,
|
|
2053
2125
|
.llm .llm__message--assistant .llm__inner--string:first-child .llm__text .llm__text-body,
|
|
2054
2126
|
.llm .llm__message--assistant .llm__inner--string:first-child .llm__text .llm__text-body > p,
|
|
@@ -4368,6 +4440,13 @@ llm-embed {
|
|
|
4368
4440
|
transform: rotate(90deg);
|
|
4369
4441
|
}
|
|
4370
4442
|
|
|
4443
|
+
.llm .llm__actions {
|
|
4444
|
+
display: flex;
|
|
4445
|
+
gap: var(--llm-size-4, 2rem);
|
|
4446
|
+
padding-top: var(--llm-size-2, 1rem);
|
|
4447
|
+
margin-top: auto;
|
|
4448
|
+
}
|
|
4449
|
+
|
|
4371
4450
|
/**
|
|
4372
4451
|
* Swiper 8.4.7
|
|
4373
4452
|
* Most modern mobile touch slider and framework with hardware accelerated transitions
|
package/dist/umd/index.js
CHANGED
|
@@ -18016,13 +18016,12 @@
|
|
|
18016
18016
|
error: "#ff4848"
|
|
18017
18017
|
};
|
|
18018
18018
|
var border = "1px solid var(--llm-color-neutral-200)";
|
|
18019
|
-
var
|
|
18020
|
-
|
|
18021
|
-
|
|
18022
|
-
|
|
18023
|
-
|
|
18024
|
-
|
|
18025
|
-
enabled: true
|
|
18019
|
+
var trigger$1 = {
|
|
18020
|
+
position: "bottom",
|
|
18021
|
+
size: "60px",
|
|
18022
|
+
background: "var(--llm-color-base-200)",
|
|
18023
|
+
foreground: "var(--llm-color-base-100)",
|
|
18024
|
+
boxShadow: "var(--llm-shadow-md)"
|
|
18026
18025
|
};
|
|
18027
18026
|
var chat = {
|
|
18028
18027
|
top: "auto",
|
|
@@ -18034,12 +18033,13 @@
|
|
|
18034
18033
|
borderRadius: "8px",
|
|
18035
18034
|
boxShadow: "var(--llm-shadow-sm)"
|
|
18036
18035
|
};
|
|
18037
|
-
var
|
|
18038
|
-
|
|
18039
|
-
|
|
18040
|
-
|
|
18041
|
-
|
|
18042
|
-
|
|
18036
|
+
var main = {
|
|
18037
|
+
background: "var(--llm-color-background)",
|
|
18038
|
+
foreground: "var(--llm-color-foreground)"
|
|
18039
|
+
};
|
|
18040
|
+
var canvas = {
|
|
18041
|
+
opacity: 0.8,
|
|
18042
|
+
enabled: true
|
|
18043
18043
|
};
|
|
18044
18044
|
var popup = {
|
|
18045
18045
|
maxWidth: "210px",
|
|
@@ -18159,10 +18159,10 @@
|
|
|
18159
18159
|
typography: typography,
|
|
18160
18160
|
color: color,
|
|
18161
18161
|
border: border,
|
|
18162
|
+
trigger: trigger$1,
|
|
18163
|
+
chat: chat,
|
|
18162
18164
|
main: main,
|
|
18163
18165
|
canvas: canvas,
|
|
18164
|
-
chat: chat,
|
|
18165
|
-
trigger: trigger$1,
|
|
18166
18166
|
popup: popup,
|
|
18167
18167
|
triggerCta: triggerCta,
|
|
18168
18168
|
hint: hint,
|
|
@@ -18944,15 +18944,17 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
18944
18944
|
};
|
|
18945
18945
|
if (message && message.role === 'assistant') {
|
|
18946
18946
|
message.chunks.forEach(chunk => {
|
|
18947
|
-
|
|
18948
|
-
|
|
18949
|
-
|
|
18950
|
-
|
|
18951
|
-
|
|
18952
|
-
|
|
18947
|
+
{
|
|
18948
|
+
if (typeof chunk === 'string') {
|
|
18949
|
+
chunks.push(...chunk.split(' ').map((x, i, a) => `${x}${i < a.length - 1 ? ' ' : ''}`));
|
|
18950
|
+
} else if (chunk.type === 'string') {
|
|
18951
|
+
const content = chunk.content;
|
|
18952
|
+
if (content) {
|
|
18953
|
+
chunks.push(...content.split(' ').map((x, i, a) => `${x}${i < a.length - 1 ? ' ' : ''}`));
|
|
18954
|
+
}
|
|
18955
|
+
} else {
|
|
18956
|
+
chunks.push(chunk);
|
|
18953
18957
|
}
|
|
18954
|
-
} else {
|
|
18955
|
-
chunks.push(chunk);
|
|
18956
18958
|
}
|
|
18957
18959
|
});
|
|
18958
18960
|
}
|
|
@@ -19188,7 +19190,9 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
19188
19190
|
return chunk.type === 'string';
|
|
19189
19191
|
}
|
|
19190
19192
|
|
|
19191
|
-
//
|
|
19193
|
+
// media
|
|
19194
|
+
|
|
19195
|
+
// actions
|
|
19192
19196
|
|
|
19193
19197
|
// cards
|
|
19194
19198
|
|
|
@@ -19331,7 +19335,7 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
19331
19335
|
chunksToChunkItems(chunks, response) {
|
|
19332
19336
|
const chunkItems = [];
|
|
19333
19337
|
chunks.forEach(x => {
|
|
19334
|
-
|
|
19338
|
+
let lastMessage = chunkItems[chunkItems.length - 1];
|
|
19335
19339
|
if (isObject$3(x)) {
|
|
19336
19340
|
switch (x.type) {
|
|
19337
19341
|
case 'log':
|
|
@@ -19352,6 +19356,17 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
19352
19356
|
// response = { ...response, ...rest };
|
|
19353
19357
|
}
|
|
19354
19358
|
break;
|
|
19359
|
+
case 'action':
|
|
19360
|
+
case 'actionItem':
|
|
19361
|
+
if (lastMessage && lastMessage.type === 'actionGroup') {
|
|
19362
|
+
lastMessage.items.push(x);
|
|
19363
|
+
} else {
|
|
19364
|
+
chunkItems.push({
|
|
19365
|
+
type: 'actionGroup',
|
|
19366
|
+
items: [x]
|
|
19367
|
+
});
|
|
19368
|
+
}
|
|
19369
|
+
break;
|
|
19355
19370
|
case 'cardItem':
|
|
19356
19371
|
if (lastMessage && lastMessage.type === 'cardGroup') {
|
|
19357
19372
|
lastMessage.items.push(x);
|
|
@@ -19414,18 +19429,26 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
19414
19429
|
}
|
|
19415
19430
|
} else if (typeof x === 'string') {
|
|
19416
19431
|
// console.warn('chunksToChunkItems typeof string');
|
|
19417
|
-
if (lastMessage
|
|
19418
|
-
|
|
19432
|
+
if (!lastMessage) {
|
|
19433
|
+
lastMessage = {
|
|
19434
|
+
type: 'text',
|
|
19435
|
+
text: ''
|
|
19436
|
+
};
|
|
19437
|
+
chunkItems.push(lastMessage);
|
|
19438
|
+
}
|
|
19439
|
+
if (isChunkText(lastMessage)) {
|
|
19440
|
+
const lastChunkText = lastMessage;
|
|
19441
|
+
if (chunkItems.indexOf(lastChunkText) > 0) {
|
|
19419
19442
|
// secondary chunk
|
|
19420
|
-
|
|
19421
|
-
} else if (!
|
|
19443
|
+
lastChunkText.text += x;
|
|
19444
|
+
} else if (!lastChunkText.text.includes('\n')) {
|
|
19422
19445
|
// uncompleted first chunk
|
|
19423
19446
|
if (x.includes('\n')) {
|
|
19424
19447
|
const lines = x.split('\n');
|
|
19425
19448
|
lines.forEach((line, i) => {
|
|
19426
19449
|
const lastChar = lines.length > i + 1 ? '\n' : '';
|
|
19427
19450
|
if (i === 0) {
|
|
19428
|
-
|
|
19451
|
+
lastChunkText.text += line + lastChar;
|
|
19429
19452
|
} else if (line.length > 0) {
|
|
19430
19453
|
chunkItems.push({
|
|
19431
19454
|
type: 'text',
|
|
@@ -19435,7 +19458,7 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
19435
19458
|
});
|
|
19436
19459
|
} else {
|
|
19437
19460
|
// uncompleted first chunk
|
|
19438
|
-
|
|
19461
|
+
lastChunkText.text += x;
|
|
19439
19462
|
}
|
|
19440
19463
|
} else {
|
|
19441
19464
|
// completed first chunk
|
|
@@ -22973,6 +22996,7 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
22973
22996
|
apiKey,
|
|
22974
22997
|
threadId,
|
|
22975
22998
|
decorateUrl,
|
|
22999
|
+
onAction,
|
|
22976
23000
|
endpoint,
|
|
22977
23001
|
storage,
|
|
22978
23002
|
test,
|
|
@@ -23303,10 +23327,16 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
23303
23327
|
decorateUrl: async (item, defaultUrl) => {
|
|
23304
23328
|
let url;
|
|
23305
23329
|
if (typeof decorateUrl === 'function') {
|
|
23306
|
-
url = await decorateUrl(item);
|
|
23330
|
+
url = (await decorateUrl(item)) || undefined;
|
|
23307
23331
|
}
|
|
23308
23332
|
return url || defaultUrl || '#';
|
|
23309
23333
|
},
|
|
23334
|
+
onAction: async item => {
|
|
23335
|
+
if (typeof onAction === 'function') {
|
|
23336
|
+
return await onAction(item);
|
|
23337
|
+
}
|
|
23338
|
+
return;
|
|
23339
|
+
},
|
|
23310
23340
|
clear: () => set(state => ({
|
|
23311
23341
|
messages: []
|
|
23312
23342
|
}))
|
|
@@ -30714,6 +30744,70 @@ void main(void) {
|
|
|
30714
30744
|
});
|
|
30715
30745
|
}
|
|
30716
30746
|
|
|
30747
|
+
const Cta = props => {
|
|
30748
|
+
const onClick = event => {
|
|
30749
|
+
if (typeof props.onClick === 'function') {
|
|
30750
|
+
props.onClick(event);
|
|
30751
|
+
}
|
|
30752
|
+
};
|
|
30753
|
+
const bg = props.type == 'button' || props.type == 'submit' ? /*#__PURE__*/jsxRuntimeExports.jsx(Canvas, {}) : '';
|
|
30754
|
+
const icon = props.icon || (props.type == 'text' ? /*#__PURE__*/jsxRuntimeExports.jsx(IconLlmArrowRight, {}) : '');
|
|
30755
|
+
const classNames = getClassNames('llm__cta', `llm__cta--${props.type}`, props.className);
|
|
30756
|
+
return props.url ? /*#__PURE__*/jsxRuntimeExports.jsxs("a", {
|
|
30757
|
+
className: classNames,
|
|
30758
|
+
href: props.url,
|
|
30759
|
+
target: props.target,
|
|
30760
|
+
children: [bg, /*#__PURE__*/jsxRuntimeExports.jsx("span", {
|
|
30761
|
+
children: props.label
|
|
30762
|
+
}), icon]
|
|
30763
|
+
}) : /*#__PURE__*/jsxRuntimeExports.jsxs("button", {
|
|
30764
|
+
className: classNames,
|
|
30765
|
+
onClick: onClick,
|
|
30766
|
+
type: props.type == 'button' || props.type == 'submit' ? props.type : undefined,
|
|
30767
|
+
children: [bg, /*#__PURE__*/jsxRuntimeExports.jsx("span", {
|
|
30768
|
+
children: props.label
|
|
30769
|
+
}), icon]
|
|
30770
|
+
});
|
|
30771
|
+
};
|
|
30772
|
+
|
|
30773
|
+
const Action = props => {
|
|
30774
|
+
const label = useLabel();
|
|
30775
|
+
const {
|
|
30776
|
+
onAction
|
|
30777
|
+
} = useLlm(state => state.actions);
|
|
30778
|
+
const {
|
|
30779
|
+
open
|
|
30780
|
+
} = useLlmView(state => state.actions);
|
|
30781
|
+
const dismissable = useLlmView(state => state.dismissable);
|
|
30782
|
+
const onAction_ = async event => {
|
|
30783
|
+
// console.log('Action.onAction', props.id);
|
|
30784
|
+
const shouldClose = await onAction(props);
|
|
30785
|
+
if (dismissable && shouldClose !== false) {
|
|
30786
|
+
open();
|
|
30787
|
+
}
|
|
30788
|
+
};
|
|
30789
|
+
const classNames = getClassNames('llm__action', {
|
|
30790
|
+
[`llm__action--${props.type}`]: !!props.type
|
|
30791
|
+
});
|
|
30792
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(Cta, {
|
|
30793
|
+
type: "button",
|
|
30794
|
+
className: classNames,
|
|
30795
|
+
label: props.title || label('llm.tellMeMore'),
|
|
30796
|
+
icon: /*#__PURE__*/jsxRuntimeExports.jsx(IconLlmArrowRight, {}),
|
|
30797
|
+
onClick: onAction_
|
|
30798
|
+
});
|
|
30799
|
+
};
|
|
30800
|
+
|
|
30801
|
+
const ActionGroup = props => {
|
|
30802
|
+
const classNames = getClassNames('llm__actions');
|
|
30803
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx("div", {
|
|
30804
|
+
className: classNames,
|
|
30805
|
+
children: props.items.map((item, i) => /*#__PURE__*/jsxRuntimeExports.jsx(Action, {
|
|
30806
|
+
...item
|
|
30807
|
+
}, i))
|
|
30808
|
+
});
|
|
30809
|
+
};
|
|
30810
|
+
|
|
30717
30811
|
const Dialog = _ref => {
|
|
30718
30812
|
let {
|
|
30719
30813
|
children,
|
|
@@ -31131,32 +31225,6 @@ void main(void) {
|
|
|
31131
31225
|
});
|
|
31132
31226
|
};
|
|
31133
31227
|
|
|
31134
|
-
const Cta = props => {
|
|
31135
|
-
const onClick = event => {
|
|
31136
|
-
if (typeof props.onClick === 'function') {
|
|
31137
|
-
props.onClick(event);
|
|
31138
|
-
}
|
|
31139
|
-
};
|
|
31140
|
-
const bg = props.type == 'button' || props.type == 'submit' ? /*#__PURE__*/jsxRuntimeExports.jsx(Canvas, {}) : '';
|
|
31141
|
-
const icon = props.type == 'text' ? /*#__PURE__*/jsxRuntimeExports.jsx(IconLlmArrowRight, {}) : '';
|
|
31142
|
-
const classNames = getClassNames('llm__cta', `llm__cta--${props.type}`);
|
|
31143
|
-
return props.url ? /*#__PURE__*/jsxRuntimeExports.jsxs("a", {
|
|
31144
|
-
className: classNames,
|
|
31145
|
-
href: props.url,
|
|
31146
|
-
target: props.target,
|
|
31147
|
-
children: [bg, /*#__PURE__*/jsxRuntimeExports.jsx("span", {
|
|
31148
|
-
children: props.label
|
|
31149
|
-
}), icon]
|
|
31150
|
-
}) : /*#__PURE__*/jsxRuntimeExports.jsxs("button", {
|
|
31151
|
-
className: classNames,
|
|
31152
|
-
onClick: onClick,
|
|
31153
|
-
type: props.type == 'button' || props.type == 'submit' ? props.type : undefined,
|
|
31154
|
-
children: [bg, /*#__PURE__*/jsxRuntimeExports.jsx("span", {
|
|
31155
|
-
children: props.label
|
|
31156
|
-
}), icon]
|
|
31157
|
-
});
|
|
31158
|
-
};
|
|
31159
|
-
|
|
31160
31228
|
const Event = props => {
|
|
31161
31229
|
const label = useLabel();
|
|
31162
31230
|
const {
|
|
@@ -33679,6 +33747,19 @@ void main(void) {
|
|
|
33679
33747
|
...item
|
|
33680
33748
|
});
|
|
33681
33749
|
}
|
|
33750
|
+
case 'action':
|
|
33751
|
+
case 'actionItem':
|
|
33752
|
+
{
|
|
33753
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(Action, {
|
|
33754
|
+
...item
|
|
33755
|
+
});
|
|
33756
|
+
}
|
|
33757
|
+
case 'actionGroup':
|
|
33758
|
+
{
|
|
33759
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(ActionGroup, {
|
|
33760
|
+
...item
|
|
33761
|
+
});
|
|
33762
|
+
}
|
|
33682
33763
|
case 'card':
|
|
33683
33764
|
case 'cardItem':
|
|
33684
33765
|
{
|