@memori.ai/memori-react 6.7.2 → 6.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/README.md +1 -1
- package/dist/I18nWrapper.js +1 -1
- package/dist/components/ChatBubble/ChatBubble.js +15 -12
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +19 -6
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/helpers/constants.js +3 -0
- package/dist/helpers/constants.js.map +1 -1
- package/dist/helpers/utils.d.ts +2 -0
- package/dist/helpers/utils.js +28 -1
- package/dist/helpers/utils.js.map +1 -1
- package/dist/index.js +1 -1
- package/esm/I18nWrapper.js +1 -1
- package/esm/components/ChatBubble/ChatBubble.js +15 -12
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +20 -7
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/helpers/constants.js +3 -0
- package/esm/helpers/constants.js.map +1 -1
- package/esm/helpers/utils.d.ts +2 -0
- package/esm/helpers/utils.js +25 -0
- package/esm/helpers/utils.js.map +1 -1
- package/esm/index.js +1 -1
- package/package.json +1 -1
- package/src/I18nWrapper.tsx +1 -1
- package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +110 -99
- package/src/components/ChatBubble/ChatBubble.stories.tsx +13 -0
- package/src/components/ChatBubble/ChatBubble.tsx +28 -20
- package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +33 -33
- package/src/components/MemoriWidget/MemoriWidget.tsx +27 -7
- package/src/components/StartPanel/__snapshots__/StartPanel.test.tsx.snap +18 -0
- package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +18 -0
- package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +18 -0
- package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +18 -0
- package/src/helpers/constants.ts +3 -0
- package/src/helpers/utils.test.ts +78 -1
- package/src/helpers/utils.ts +40 -0
- package/src/index.tsx +1 -1
|
@@ -265,3 +265,16 @@ ComplexMarkdownMath2.args = {
|
|
|
265
265
|
text: "Per calcolare le resistenze dei materiali per le verifiche rispetto ad azioni antropiche e ambientali secondo la Specifica Tecnica ST-VAL4, si procede in questo modo:\n\n1. **Determinazione della resistenza dei materiali:**\n La resistenza dei materiali da utilizzare nelle verifiche accurate si determina a partire dalle indagini sull’opera. La caratterizzazione deve essere distinta per tutti i materiali presenti nell'opera, in accordo con la ST-PI. Le resistenze per verifiche rispetto ad azioni antropiche come i carichi da traffico e le azioni ambientali sono definite dalle LG20. Questo include la distinzione rispetto a quelle utilizzate per le azioni sismiche, come dettagliato dalle NTC18 e CIR19 .\n\n2. **Calcolo della resistenza:**\n Il valore della resistenza dei materiali \\( f_d \\) da utilizzare nelle verifiche per carichi gravitazionali si ottiene mediante la seguente espressione:\n\n \\[\n f_d = \\min \\left( \\frac{f_m}{FC \\cdot \\gamma_M}, \\frac{f_k}{FC} \\right)\n \\]\n\n Dove:\n - \\( f_m \\) è il valor medio della resistenza valutato dai risultati delle prove effettuate sui campioni prelevati in situ;\n - \\( f_k \\) è la resistenza caratteristica calcolata sulla base dei risultati delle prove sui campioni prelevati in situ;\n - \\( FC \\) è il Fattore di Confidenza associato al Livello di Conoscenza raggiunto;\n - \\( \\gamma_M \\) è il fattore parziale di sicurezza del materiale .\n\n3. **Caratterizzazione dei materiali:**\n I valori medi, caratteristici e di progetto delle resistenze a compressione e trazione per il calcestruzzo, e delle resistenze a snervamento per l’acciaio ordinario sono determinati a partire dai risultati delle prove. Specifiche espressioni e metodi sono forniti per diversi materiali nell'Appendice 13 della ST-VAL4 .\n\n4. **Stima della resistenza da prove non distruttive:**\n Per valutare le resistenze dei materiali, si possono anche utilizzare prove non distruttive come le prove SonReb per il calcestruzzo e le prove di durezza per l'acciaio ordinario e armonico. Formulazioni specifiche per queste prove si trovano in Appendice al §13.1 della ST-VAL4 .\n\n5. **Analisi dei risultati delle indagini:**\n Gli esiti delle prove devono essere attentamente analizzati per confermare le caratteristiche originarie o rilevare eventuali decadimenti del materiale. Questo processo include anche l'identificazione delle cause di dispersione significative nei risultati delle prove .\n\nSeguendo questi passaggi, si ottiene una stima accurata delle resistenze dei materiali che possono essere utilizzate per le verifiche di sicurezza rispetto ad azioni antropiche e ambientali.",
|
|
266
266
|
},
|
|
267
267
|
};
|
|
268
|
+
|
|
269
|
+
export const ComplexMarkdownMath3 = Template.bind({});
|
|
270
|
+
ComplexMarkdownMath3.args = {
|
|
271
|
+
memori,
|
|
272
|
+
apiUrl: 'https://backend.memori.ai',
|
|
273
|
+
tenant,
|
|
274
|
+
message: {
|
|
275
|
+
fromUser: false,
|
|
276
|
+
initial: false,
|
|
277
|
+
generatedByAI: true,
|
|
278
|
+
text: "Ok. \n\nPer calcolare l'urto su barriere metalliche, il documento *\"Ponti, viadotti e cavalcavia - Specifica Tecnica per la redazione delle Verifiche Accurate di sicurezza di Livello 4 (ST-VAL4)\"* fornisce un metodo specifico. Ecco l'iter riassunto:\n\n1. **Determinazione del sistema di forze orizzontali:** Partendo dal momento di plasticizzazione del montante (§5.1.3.10 delle NTC18). La forza orizzontale che plasticizza il montante può essere determinata con riferimento alla resistenza caratteristica degli elementi strutturali principali della barriera.\n\n2. **Quota di applicazione della forza:** La forza orizzontale deve essere applicata ad una quota h, che è il minimo tra (altezza della barriera - 0,10 m) e 1,00 m.\n\n3. **Amplificazione delle forze orizzontali:** Per il dimensionamento dell'impalcato, le forze orizzontali sono amplificate di un fattore di 1,50, e il coefficiente parziale di sicurezza per la combinazione di carico agli SLU per l’urto di veicolo in svio è assunto unitario.\n\n4. **Calcolo della massima azione tagliante:** Alla base del montante (estradosso cordolo):\n\n \\[\n F_{\\text{urto}} = \\frac{M_{\\text{pl}}}{h^*}\n \\]\n\n Dove:\n - \\(M_{\\text{pl}}\\) è il momento plastico calcolato con la resistenza caratteristica.\n - \\(h^* = h - h_R - h_C\\)\n - \\(h\\) è pari all’altezza della forza di urto sulla superficie di rotolamento (1.00 m), \\(h_B\\) è l’altezza della forza rispetto all’estradosso del cordolo, \\(h_C\\) è l’altezza del cordolo, e \\(h_R\\) è l’altezza dell’irrigidimento del nodo e della piastra di base.\n\n5. **Determinazione del momento trasferito all’estradosso del cordolo:**\n\n \\[\n M_{\\text{urto}} = F_{\\text{urto}} \\cdot h_B = M_{\\text{pl}} \\cdot \\left(1 + \\frac{h_R}{h^*}\\right)\n \\]\n\n6. **Amplificazione per le incertezze:** Il valore caratteristico è amplificato di un fattore parziale pari a 1,50 per tenere conto delle incertezze e possibili deformabilità della lamiera irrigidita.\n\n7. **Considerazione della plasticizzazione:** Nel caso di barriere ordinarie, si considera la piena plasticizzazione di tre montanti consecutivi a seguito dell’urto, salvo diversa valutazione motivata.\n\n8. **Normative alternative:** In assenza di informazioni, si può fare riferimento al valore normativo della forza d’urto di 100 kN (NTC18) da collocarsi a 100 mm sotto la sommità dell’elemento o 1,0 m sopra il livello del piano di marcia【4:0†source】【4:1†source】【4:4†source】【4:9†source】【4:5†source】. \n\nPer ulteriori dettagli o chiarimenti, puoi consultare la sezione del documento ST-VAL4 o scrivere a anna.sganzerla@tecneautostrade.it.",
|
|
279
|
+
},
|
|
280
|
+
};
|
|
@@ -91,26 +91,33 @@ const ChatBubble: React.FC<Props> = ({
|
|
|
91
91
|
const { t } = useTranslation();
|
|
92
92
|
const [showingWhyThisAnswer, setShowingWhyThisAnswer] = useState(false);
|
|
93
93
|
|
|
94
|
-
const renderedText =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
(
|
|
98
|
-
.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
94
|
+
const renderedText = message.fromUser
|
|
95
|
+
? message.translatedText || message.text
|
|
96
|
+
: sanitize(
|
|
97
|
+
(
|
|
98
|
+
marked.parse(
|
|
99
|
+
(message.translatedText || message.text)
|
|
100
|
+
// remove markdown links
|
|
101
|
+
.replaceAll(
|
|
102
|
+
/\[([^\]]+)\]\([^)]+\)/g,
|
|
103
|
+
'<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>'
|
|
104
|
+
)
|
|
105
|
+
.replaceAll('(', '\\(')
|
|
106
|
+
.replaceAll(')', '\\)')
|
|
107
|
+
) as string
|
|
108
|
+
)
|
|
109
|
+
.trim()
|
|
110
|
+
.replace(/\n/g, '<br>')
|
|
111
|
+
// replace consecutive <br> with a <br>
|
|
112
|
+
.replace(/(<br>)+/g, '<br><br>'),
|
|
113
|
+
{
|
|
114
|
+
ADD_ATTR: ['target'],
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
.replaceAll('[', '\\[')
|
|
118
|
+
.replaceAll(']', '\\]')
|
|
119
|
+
// replace consecutive <br> with a single <br>
|
|
120
|
+
.replace(/(<br>)+/g, '<br>');
|
|
114
121
|
|
|
115
122
|
useLayoutEffect(() => {
|
|
116
123
|
if (typeof window !== 'undefined' && !message.fromUser) {
|
|
@@ -231,6 +238,7 @@ const ChatBubble: React.FC<Props> = ({
|
|
|
231
238
|
}`}
|
|
232
239
|
>
|
|
233
240
|
<div
|
|
241
|
+
dir="auto"
|
|
234
242
|
className="memori-chat--bubble-content"
|
|
235
243
|
dangerouslySetInnerHTML={{ __html: renderedText }}
|
|
236
244
|
/>
|
|
@@ -10,10 +10,9 @@ exports[`renders ChatBubble from user with avatar as react element unchanged 1`]
|
|
|
10
10
|
>
|
|
11
11
|
<div
|
|
12
12
|
class="memori-chat--bubble-content"
|
|
13
|
+
dir="auto"
|
|
13
14
|
>
|
|
14
|
-
|
|
15
|
-
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
16
|
-
</p>
|
|
15
|
+
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
17
16
|
</div>
|
|
18
17
|
</div>
|
|
19
18
|
<div
|
|
@@ -37,10 +36,9 @@ exports[`renders ChatBubble from user with avatar unchanged 1`] = `
|
|
|
37
36
|
>
|
|
38
37
|
<div
|
|
39
38
|
class="memori-chat--bubble-content"
|
|
39
|
+
dir="auto"
|
|
40
40
|
>
|
|
41
|
-
|
|
42
|
-
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
43
|
-
</p>
|
|
41
|
+
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
44
42
|
</div>
|
|
45
43
|
</div>
|
|
46
44
|
<picture
|
|
@@ -66,10 +64,9 @@ exports[`renders ChatBubble from user with custom avatar unchanged 1`] = `
|
|
|
66
64
|
>
|
|
67
65
|
<div
|
|
68
66
|
class="memori-chat--bubble-content"
|
|
67
|
+
dir="auto"
|
|
69
68
|
>
|
|
70
|
-
|
|
71
|
-
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
72
|
-
</p>
|
|
69
|
+
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
73
70
|
</div>
|
|
74
71
|
</div>
|
|
75
72
|
<picture
|
|
@@ -105,6 +102,7 @@ exports[`renders ChatBubble unchanged 1`] = `
|
|
|
105
102
|
>
|
|
106
103
|
<div
|
|
107
104
|
class="memori-chat--bubble-content"
|
|
105
|
+
dir="auto"
|
|
108
106
|
>
|
|
109
107
|
<p>
|
|
110
108
|
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
@@ -135,6 +133,7 @@ exports[`renders ChatBubble with complex markdown and math 1 unchanged 1`] = `
|
|
|
135
133
|
>
|
|
136
134
|
<div
|
|
137
135
|
class="memori-chat--bubble-content"
|
|
136
|
+
dir="auto"
|
|
138
137
|
>
|
|
139
138
|
<p>
|
|
140
139
|
Per calcolare l'ipotenusa di un triangolo rettangolo, puoi usare il Teorema di Pitagora. Il teorema afferma che in un triangolo rettangolo, il quadrato dell'ipotenusa (la lato opposto all'angolo retto) è uguale alla somma dei quadrati degli altri due lati.
|
|
@@ -151,9 +150,9 @@ exports[`renders ChatBubble with complex markdown and math 1 unchanged 1`] = `
|
|
|
151
150
|
<p>
|
|
152
151
|
Dove:
|
|
153
152
|
<br />
|
|
154
|
-
- \\(c \\) è l'ipotenusa.
|
|
153
|
+
- \\( c \\) è l'ipotenusa.
|
|
155
154
|
<br />
|
|
156
|
-
- \\(a \\) e \\(b \\) sono i due cateti del triangolo.
|
|
155
|
+
- \\( a \\) e \\( b \\) sono i due cateti del triangolo.
|
|
157
156
|
</p>
|
|
158
157
|
<br />
|
|
159
158
|
<h3>
|
|
@@ -165,7 +164,7 @@ exports[`renders ChatBubble with complex markdown and math 1 unchanged 1`] = `
|
|
|
165
164
|
<li>
|
|
166
165
|
<p>
|
|
167
166
|
<strong>
|
|
168
|
-
Misura o identifica i cateti \\(a \\) e \\(b \\)
|
|
167
|
+
Misura o identifica i cateti \\( a \\) e \\( b \\)
|
|
169
168
|
</strong>
|
|
170
169
|
:
|
|
171
170
|
<br />
|
|
@@ -181,7 +180,7 @@ exports[`renders ChatBubble with complex markdown and math 1 unchanged 1`] = `
|
|
|
181
180
|
</strong>
|
|
182
181
|
:
|
|
183
182
|
<br />
|
|
184
|
-
Eleva al quadrato entrambe le misure dei cateti: \\(a^2 \\) e \\(b^2 \\).
|
|
183
|
+
Eleva al quadrato entrambe le misure dei cateti: \\( a^2 \\) e \\( b^2 \\).
|
|
185
184
|
</p>
|
|
186
185
|
<br />
|
|
187
186
|
</li>
|
|
@@ -193,7 +192,7 @@ exports[`renders ChatBubble with complex markdown and math 1 unchanged 1`] = `
|
|
|
193
192
|
</strong>
|
|
194
193
|
:
|
|
195
194
|
<br />
|
|
196
|
-
Somma i risultati ottenuti: \\(a^2 + b^2 \\).
|
|
195
|
+
Somma i risultati ottenuti: \\( a^2 + b^2 \\).
|
|
197
196
|
</p>
|
|
198
197
|
<br />
|
|
199
198
|
</li>
|
|
@@ -205,7 +204,7 @@ exports[`renders ChatBubble with complex markdown and math 1 unchanged 1`] = `
|
|
|
205
204
|
</strong>
|
|
206
205
|
:
|
|
207
206
|
<br />
|
|
208
|
-
Prendi la radice quadrata della somma per trovare l'ipotenusa: \\(c = \\sqrt{a^2 + b^2} \\).
|
|
207
|
+
Prendi la radice quadrata della somma per trovare l'ipotenusa: \\( c = \\sqrt{a^2 + b^2} \\).
|
|
209
208
|
</p>
|
|
210
209
|
<br />
|
|
211
210
|
</li>
|
|
@@ -224,14 +223,14 @@ exports[`renders ChatBubble with complex markdown and math 1 unchanged 1`] = `
|
|
|
224
223
|
<br />
|
|
225
224
|
<li>
|
|
226
225
|
<strong>
|
|
227
|
-
Cateto \\(a \\)
|
|
226
|
+
Cateto \\( a \\)
|
|
228
227
|
</strong>
|
|
229
228
|
: 3 cm
|
|
230
229
|
</li>
|
|
231
230
|
<br />
|
|
232
231
|
<li>
|
|
233
232
|
<strong>
|
|
234
|
-
Cateto \\(b \\)
|
|
233
|
+
Cateto \\( b \\)
|
|
235
234
|
</strong>
|
|
236
235
|
: 4 cm
|
|
237
236
|
</li>
|
|
@@ -291,6 +290,7 @@ exports[`renders ChatBubble with complex markdown and math 2 unchanged 1`] = `
|
|
|
291
290
|
>
|
|
292
291
|
<div
|
|
293
292
|
class="memori-chat--bubble-content"
|
|
293
|
+
dir="auto"
|
|
294
294
|
>
|
|
295
295
|
<p>
|
|
296
296
|
Per calcolare le resistenze dei materiali per le verifiche rispetto ad azioni antropiche e ambientali secondo la Specifica Tecnica ST-VAL4, si procede in questo modo:
|
|
@@ -315,13 +315,13 @@ exports[`renders ChatBubble with complex markdown and math 2 unchanged 1`] = `
|
|
|
315
315
|
Calcolo della resistenza:
|
|
316
316
|
</strong>
|
|
317
317
|
<br />
|
|
318
|
-
Il valore della resistenza dei materiali \\(f_d \\) da utilizzare nelle verifiche per carichi gravitazionali si ottiene mediante la seguente espressione:
|
|
318
|
+
Il valore della resistenza dei materiali \\( f_d \\) da utilizzare nelle verifiche per carichi gravitazionali si ottiene mediante la seguente espressione:
|
|
319
319
|
</p>
|
|
320
320
|
<br />
|
|
321
321
|
<p>
|
|
322
322
|
\\[
|
|
323
323
|
<br />
|
|
324
|
-
f_d = \\min \\left(\\frac{f_m}{FC \\cdot \\gamma_M}, \\frac{f_k}{FC} \\right)
|
|
324
|
+
f_d = \\min \\left( \\frac{f_m}{FC \\cdot \\gamma_M}, \\frac{f_k}{FC} \\right)
|
|
325
325
|
<br />
|
|
326
326
|
\\]
|
|
327
327
|
</p>
|
|
@@ -333,19 +333,19 @@ exports[`renders ChatBubble with complex markdown and math 2 unchanged 1`] = `
|
|
|
333
333
|
<ul>
|
|
334
334
|
<br />
|
|
335
335
|
<li>
|
|
336
|
-
\\(f_m \\) è il valor medio della resistenza valutato dai risultati delle prove effettuate sui campioni prelevati in situ;
|
|
336
|
+
\\( f_m \\) è il valor medio della resistenza valutato dai risultati delle prove effettuate sui campioni prelevati in situ;
|
|
337
337
|
</li>
|
|
338
338
|
<br />
|
|
339
339
|
<li>
|
|
340
|
-
\\(f_k \\) è la resistenza caratteristica calcolata sulla base dei risultati delle prove sui campioni prelevati in situ;
|
|
340
|
+
\\( f_k \\) è la resistenza caratteristica calcolata sulla base dei risultati delle prove sui campioni prelevati in situ;
|
|
341
341
|
</li>
|
|
342
342
|
<br />
|
|
343
343
|
<li>
|
|
344
|
-
\\(FC \\) è il Fattore di Confidenza associato al Livello di Conoscenza raggiunto;
|
|
344
|
+
\\( FC \\) è il Fattore di Confidenza associato al Livello di Conoscenza raggiunto;
|
|
345
345
|
</li>
|
|
346
346
|
<br />
|
|
347
347
|
<li>
|
|
348
|
-
\\(\\gamma_M \\) è il fattore parziale di sicurezza del materiale .
|
|
348
|
+
\\( \\gamma_M \\) è il fattore parziale di sicurezza del materiale .
|
|
349
349
|
</li>
|
|
350
350
|
<br />
|
|
351
351
|
</ul>
|
|
@@ -419,6 +419,7 @@ exports[`renders ChatBubble with initial msg unchanged 1`] = `
|
|
|
419
419
|
>
|
|
420
420
|
<div
|
|
421
421
|
class="memori-chat--bubble-content"
|
|
422
|
+
dir="auto"
|
|
422
423
|
>
|
|
423
424
|
<p>
|
|
424
425
|
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
@@ -449,6 +450,7 @@ exports[`renders ChatBubble with markdown and breakline unchanged 1`] = `
|
|
|
449
450
|
>
|
|
450
451
|
<div
|
|
451
452
|
class="memori-chat--bubble-content"
|
|
453
|
+
dir="auto"
|
|
452
454
|
>
|
|
453
455
|
<p>
|
|
454
456
|
Per l'avvio di una progettualità è necessario fornire le seguenti informazioni:
|
|
@@ -491,6 +493,7 @@ exports[`renders ChatBubble with markdown unchanged 1`] = `
|
|
|
491
493
|
>
|
|
492
494
|
<div
|
|
493
495
|
class="memori-chat--bubble-content"
|
|
496
|
+
dir="auto"
|
|
494
497
|
>
|
|
495
498
|
<h2>
|
|
496
499
|
Test
|
|
@@ -644,7 +647,7 @@ exports[`renders ChatBubble with markdown unchanged 1`] = `
|
|
|
644
647
|
<br />
|
|
645
648
|
<p>
|
|
646
649
|
<a
|
|
647
|
-
href="
|
|
650
|
+
href="Vedi altro"
|
|
648
651
|
rel="noopener noreferrer"
|
|
649
652
|
target="_blank"
|
|
650
653
|
>
|
|
@@ -667,10 +670,9 @@ exports[`renders ChatBubble with msg from BoE expert unchanged 1`] = `
|
|
|
667
670
|
>
|
|
668
671
|
<div
|
|
669
672
|
class="memori-chat--bubble-content"
|
|
673
|
+
dir="auto"
|
|
670
674
|
>
|
|
671
|
-
|
|
672
|
-
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
673
|
-
</p>
|
|
675
|
+
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
674
676
|
</div>
|
|
675
677
|
<div
|
|
676
678
|
class="memori-chat--bubble-addon"
|
|
@@ -751,10 +753,9 @@ exports[`renders ChatBubble with msg generated by AI unchanged 1`] = `
|
|
|
751
753
|
>
|
|
752
754
|
<div
|
|
753
755
|
class="memori-chat--bubble-content"
|
|
756
|
+
dir="auto"
|
|
754
757
|
>
|
|
755
|
-
|
|
756
|
-
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
757
|
-
</p>
|
|
758
|
+
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
758
759
|
</div>
|
|
759
760
|
<div
|
|
760
761
|
class="memori-chat--bubble-addon"
|
|
@@ -835,10 +836,9 @@ exports[`renders ChatBubble with user msg unchanged 1`] = `
|
|
|
835
836
|
>
|
|
836
837
|
<div
|
|
837
838
|
class="memori-chat--bubble-content"
|
|
839
|
+
dir="auto"
|
|
838
840
|
>
|
|
839
|
-
|
|
840
|
-
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
841
|
-
</p>
|
|
841
|
+
Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
|
|
842
842
|
</div>
|
|
843
843
|
</div>
|
|
844
844
|
<div
|
|
@@ -71,6 +71,8 @@ import {
|
|
|
71
71
|
hasTouchscreen,
|
|
72
72
|
stripDuplicates,
|
|
73
73
|
stripEmojis,
|
|
74
|
+
escapeHTML,
|
|
75
|
+
stripMarkdown,
|
|
74
76
|
} from '../../helpers/utils';
|
|
75
77
|
import { anonTag } from '../../helpers/constants';
|
|
76
78
|
import { getErrori18nKey } from '../../helpers/error';
|
|
@@ -1622,6 +1624,21 @@ const MemoriWidget = ({
|
|
|
1622
1624
|
voiceType === 'MALE' ? 'el-GR-NestorasNeural' : 'el-GR-AthinaNeural'
|
|
1623
1625
|
}`;
|
|
1624
1626
|
break;
|
|
1627
|
+
case 'AR':
|
|
1628
|
+
voice = `${
|
|
1629
|
+
voiceType === 'MALE' ? 'ar-SA-HamedNeural' : 'ar-SA-ZariyahNeural'
|
|
1630
|
+
}`;
|
|
1631
|
+
break;
|
|
1632
|
+
case 'ZH':
|
|
1633
|
+
voice = `${
|
|
1634
|
+
voiceType === 'MALE' ? 'zh-CN-YunxiNeural' : 'zh-CN-XiaoxiaoNeural'
|
|
1635
|
+
}`;
|
|
1636
|
+
break;
|
|
1637
|
+
case 'JA':
|
|
1638
|
+
voice = `${
|
|
1639
|
+
voiceType === 'MALE' ? 'ja-JP-KeitaNeural' : 'ja-JP-NanamiNeural'
|
|
1640
|
+
}`;
|
|
1641
|
+
break;
|
|
1625
1642
|
default:
|
|
1626
1643
|
voice = `${
|
|
1627
1644
|
voiceType === 'MALE' ? 'it-IT-DiegoNeural' : 'it-IT-IsabellaNeural'
|
|
@@ -1681,6 +1698,15 @@ const MemoriWidget = ({
|
|
|
1681
1698
|
case 'EL':
|
|
1682
1699
|
voice = 'el-GR';
|
|
1683
1700
|
break;
|
|
1701
|
+
case 'AR':
|
|
1702
|
+
voice = 'ar-SA';
|
|
1703
|
+
break;
|
|
1704
|
+
case 'ZH':
|
|
1705
|
+
voice = 'zh-CN';
|
|
1706
|
+
break;
|
|
1707
|
+
case 'JA':
|
|
1708
|
+
voice = 'ja-JP';
|
|
1709
|
+
break;
|
|
1684
1710
|
default:
|
|
1685
1711
|
voice = 'it-IT';
|
|
1686
1712
|
break;
|
|
@@ -1717,12 +1743,6 @@ const MemoriWidget = ({
|
|
|
1717
1743
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1718
1744
|
}, []);
|
|
1719
1745
|
|
|
1720
|
-
const escapeHTML = (text: string) => {
|
|
1721
|
-
const el = document.createElement('textarea');
|
|
1722
|
-
el.textContent = text;
|
|
1723
|
-
return el.innerHTML;
|
|
1724
|
-
};
|
|
1725
|
-
|
|
1726
1746
|
const replaceTextWithPhonemes = (text: string, lang: string) => {
|
|
1727
1747
|
if (!phonemesMap) return text;
|
|
1728
1748
|
|
|
@@ -1846,7 +1866,7 @@ const MemoriWidget = ({
|
|
|
1846
1866
|
`<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="https://www.w3.org/2001/mstts" xmlns:emo="http://www.w3.org/2009/10/emotionml" xml:lang="${getCultureCodeByLanguage(
|
|
1847
1867
|
userLang
|
|
1848
1868
|
)}"><voice name="${getTTSVoice(userLang)}"><s>${replaceTextWithPhonemes(
|
|
1849
|
-
escapeHTML(stripEmojis(text)),
|
|
1869
|
+
escapeHTML(stripMarkdown(stripEmojis(text))),
|
|
1850
1870
|
userLang.toLowerCase()
|
|
1851
1871
|
)}</s></voice></speak>`,
|
|
1852
1872
|
result => {
|
|
@@ -1335,6 +1335,24 @@ exports[`renders StartPanel with integrationConfig unchanged 1`] = `
|
|
|
1335
1335
|
>
|
|
1336
1336
|
Ελληνικά
|
|
1337
1337
|
</option>
|
|
1338
|
+
<option
|
|
1339
|
+
aria-label="العربية"
|
|
1340
|
+
value="AR"
|
|
1341
|
+
>
|
|
1342
|
+
العربية
|
|
1343
|
+
</option>
|
|
1344
|
+
<option
|
|
1345
|
+
aria-label="中文"
|
|
1346
|
+
value="ZH"
|
|
1347
|
+
>
|
|
1348
|
+
中文
|
|
1349
|
+
</option>
|
|
1350
|
+
<option
|
|
1351
|
+
aria-label="日本語"
|
|
1352
|
+
value="JA"
|
|
1353
|
+
>
|
|
1354
|
+
日本語
|
|
1355
|
+
</option>
|
|
1338
1356
|
</select>
|
|
1339
1357
|
</div>
|
|
1340
1358
|
<button
|
|
@@ -317,6 +317,24 @@ exports[`renders Chat layout unchanged 1`] = `
|
|
|
317
317
|
>
|
|
318
318
|
Ελληνικά
|
|
319
319
|
</option>
|
|
320
|
+
<option
|
|
321
|
+
aria-label="العربية"
|
|
322
|
+
value="AR"
|
|
323
|
+
>
|
|
324
|
+
العربية
|
|
325
|
+
</option>
|
|
326
|
+
<option
|
|
327
|
+
aria-label="中文"
|
|
328
|
+
value="ZH"
|
|
329
|
+
>
|
|
330
|
+
中文
|
|
331
|
+
</option>
|
|
332
|
+
<option
|
|
333
|
+
aria-label="日本語"
|
|
334
|
+
value="JA"
|
|
335
|
+
>
|
|
336
|
+
日本語
|
|
337
|
+
</option>
|
|
320
338
|
</select>
|
|
321
339
|
</div>
|
|
322
340
|
<button
|
|
@@ -356,6 +356,24 @@ exports[`renders FullPage layout unchanged 1`] = `
|
|
|
356
356
|
>
|
|
357
357
|
Ελληνικά
|
|
358
358
|
</option>
|
|
359
|
+
<option
|
|
360
|
+
aria-label="العربية"
|
|
361
|
+
value="AR"
|
|
362
|
+
>
|
|
363
|
+
العربية
|
|
364
|
+
</option>
|
|
365
|
+
<option
|
|
366
|
+
aria-label="中文"
|
|
367
|
+
value="ZH"
|
|
368
|
+
>
|
|
369
|
+
中文
|
|
370
|
+
</option>
|
|
371
|
+
<option
|
|
372
|
+
aria-label="日本語"
|
|
373
|
+
value="JA"
|
|
374
|
+
>
|
|
375
|
+
日本語
|
|
376
|
+
</option>
|
|
359
377
|
</select>
|
|
360
378
|
</div>
|
|
361
379
|
<button
|
|
@@ -410,6 +410,24 @@ exports[`renders Totem layout unchanged 1`] = `
|
|
|
410
410
|
>
|
|
411
411
|
Ελληνικά
|
|
412
412
|
</option>
|
|
413
|
+
<option
|
|
414
|
+
aria-label="العربية"
|
|
415
|
+
value="AR"
|
|
416
|
+
>
|
|
417
|
+
العربية
|
|
418
|
+
</option>
|
|
419
|
+
<option
|
|
420
|
+
aria-label="中文"
|
|
421
|
+
value="ZH"
|
|
422
|
+
>
|
|
423
|
+
中文
|
|
424
|
+
</option>
|
|
425
|
+
<option
|
|
426
|
+
aria-label="日本語"
|
|
427
|
+
value="JA"
|
|
428
|
+
>
|
|
429
|
+
日本語
|
|
430
|
+
</option>
|
|
413
431
|
</select>
|
|
414
432
|
</div>
|
|
415
433
|
<button
|
package/src/helpers/constants.ts
CHANGED
|
@@ -10,6 +10,9 @@ export const chatLanguages = [
|
|
|
10
10
|
{ value: 'PL', label: 'Polski' },
|
|
11
11
|
{ value: 'FI', label: 'Suomi' },
|
|
12
12
|
{ value: 'EL', label: 'Ελληνικά' },
|
|
13
|
+
{ value: 'AR', label: 'العربية' },
|
|
14
|
+
{ value: 'ZH', label: '中文' },
|
|
15
|
+
{ value: 'JA', label: '日本語' },
|
|
13
16
|
];
|
|
14
17
|
|
|
15
18
|
export const allowedMediaTypes = [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { difference, stripEmojis } from './utils';
|
|
1
|
+
import { difference, stripEmojis, stripMarkdown } from './utils';
|
|
2
2
|
|
|
3
3
|
describe('Utils/difference', () => {
|
|
4
4
|
it('should return the difference between two objects with numeric values', () => {
|
|
@@ -43,3 +43,80 @@ describe('utils/stripEmojis', () => {
|
|
|
43
43
|
expect(result).toEqual('Hello');
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
|
+
|
|
47
|
+
describe('utils/stripMarkdown', () => {
|
|
48
|
+
it('should strip markdown headings from a string', () => {
|
|
49
|
+
const result = stripMarkdown('# Hello');
|
|
50
|
+
expect(result).toEqual('Hello');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should strip markdown bold and italic from a string', () => {
|
|
54
|
+
const result = stripMarkdown('**Hello** _world_');
|
|
55
|
+
expect(result).toEqual('Hello world');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should strip markdown links from a string', () => {
|
|
59
|
+
const result = stripMarkdown('[example.com](https://example.com)');
|
|
60
|
+
expect(result).toEqual('example.com');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should strip markdown images from a string', () => {
|
|
64
|
+
const result = stripMarkdown('');
|
|
65
|
+
expect(result).toEqual('');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should strip markdown blockquotes from a string', () => {
|
|
69
|
+
const result = stripMarkdown('> Hello');
|
|
70
|
+
expect(result).toEqual('Hello');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should strip markdown horizontal rules from a string', () => {
|
|
74
|
+
const result = stripMarkdown('---');
|
|
75
|
+
expect(result).toEqual('');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should strip markdown strikethrough from a string', () => {
|
|
79
|
+
const result = stripMarkdown('~~Hello~~');
|
|
80
|
+
expect(result).toEqual('Hello');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should strip markdown code blocks from a string', () => {
|
|
84
|
+
const result = stripMarkdown('```Hello```');
|
|
85
|
+
expect(result).toEqual('');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('should strip markdown multiline code blocks from a string', () => {
|
|
89
|
+
const result = stripMarkdown('```\nHello\n```');
|
|
90
|
+
expect(result).toEqual('');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should strip markdown inline code from a string', () => {
|
|
94
|
+
const result = stripMarkdown('`Hello`');
|
|
95
|
+
expect(result).toEqual('');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('should strip markdown lists from a string', () => {
|
|
99
|
+
const result = stripMarkdown('- Hello');
|
|
100
|
+
expect(result).toEqual('Hello');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should strip markdown tables from a string', () => {
|
|
104
|
+
const result = stripMarkdown('| Hello |');
|
|
105
|
+
expect(result).toEqual('');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('should strip block mathjax from a string', () => {
|
|
109
|
+
const result = stripMarkdown('\\[ c = \\sqrt{a^2 + b^2} \\]');
|
|
110
|
+
expect(result).toEqual('');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('should strip block mathjax from a string with multiple lines', () => {
|
|
114
|
+
const result = stripMarkdown('$$\nHello\n$$');
|
|
115
|
+
expect(result).toEqual('');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should strip inline mathjax from a string', () => {
|
|
119
|
+
const result = stripMarkdown('\\( f_m \\)');
|
|
120
|
+
expect(result).toEqual('');
|
|
121
|
+
});
|
|
122
|
+
});
|
package/src/helpers/utils.ts
CHANGED
|
@@ -146,6 +146,46 @@ export const stripEmojis = (text: string) => {
|
|
|
146
146
|
return text.replaceAll(/[^\p{L}\p{N}\p{P}\p{Z}^$\n]/gu, '').trim();
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
+
export const stripMarkdown = (text: string) => {
|
|
150
|
+
// Remove code blocks
|
|
151
|
+
text = text.replaceAll(/```[\s\S]*?```/g, '');
|
|
152
|
+
// Remove inline code
|
|
153
|
+
text = text.replaceAll(/`[^`]*`/g, '');
|
|
154
|
+
// Remove images
|
|
155
|
+
text = text.replaceAll(/!\[[^\]]*\]\([^)]*\)/g, '');
|
|
156
|
+
// Remove links but keep the text
|
|
157
|
+
text = text.replaceAll(/\[([^\]]*)\]\([^)]*\)/g, '$1');
|
|
158
|
+
// Remove blockquotes but keep the text
|
|
159
|
+
text = text.replaceAll(/^> /gm, '');
|
|
160
|
+
// Remove headings but keep the text
|
|
161
|
+
text = text.replaceAll(/^#+ /gm, '');
|
|
162
|
+
// Remove bold and italic symbols and keep the text
|
|
163
|
+
text = text.replaceAll(/[*_]/g, '');
|
|
164
|
+
// Remove horizontal rules
|
|
165
|
+
text = text.replaceAll(/---/g, '');
|
|
166
|
+
// Remove strikethrough and keep the text
|
|
167
|
+
text = text.replaceAll(/~~/g, '');
|
|
168
|
+
// Remove lists
|
|
169
|
+
text = text.replaceAll(/^\s*[-*+] /gm, '');
|
|
170
|
+
text = text.replaceAll(/^\s*\d+\.\s+/gm, '');
|
|
171
|
+
// Remove tables
|
|
172
|
+
text = text.replaceAll(/^\|.*\|$/gm, '');
|
|
173
|
+
// Remove MathJax
|
|
174
|
+
text = text.replaceAll(/\$\$[\s\S]*?\$\$/g, '');
|
|
175
|
+
text = text.replaceAll(/\$[\s\S]*?\$/g, '');
|
|
176
|
+
text = text.replaceAll(/\\\([\s\S]*?\\\)/g, '');
|
|
177
|
+
text = text.replaceAll(/\\\[[\s\S]*?\\\]/g, '');
|
|
178
|
+
// Remove extra spaces and newlines
|
|
179
|
+
text = text.replaceAll(/\s+/g, ' ').trim();
|
|
180
|
+
return text;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const escapeHTML = (text: string) => {
|
|
184
|
+
const el = document.createElement('textarea');
|
|
185
|
+
el.textContent = text;
|
|
186
|
+
return el.innerHTML;
|
|
187
|
+
};
|
|
188
|
+
|
|
149
189
|
export const getFieldFromCustomData = (
|
|
150
190
|
fieldName: string,
|
|
151
191
|
data: string | undefined
|
package/src/index.tsx
CHANGED
|
@@ -294,7 +294,7 @@ const Memori: React.FC<Props> = ({
|
|
|
294
294
|
processHtmlClass: 'memori-chat--bubble-content',
|
|
295
295
|
},
|
|
296
296
|
tex: {
|
|
297
|
-
inlineMath: [['$', '$'], ['\\$', '\\$'], ['(',')'], ['
|
|
297
|
+
inlineMath: [['$', '$'], ['\\$', '\\$'], ['(',')'], ['(','\\)'], ['\[', '\]'], ['[', '\\]'], ['[', ']'], ['\\(', '\\)'], ['\\[', '\\]'], ['((','))']],
|
|
298
298
|
displayMath: [['$$', '$$'], ['\\[[', '\\]]']],
|
|
299
299
|
processEscapes: true,
|
|
300
300
|
},
|