@memori.ai/memori-react 7.4.4 → 7.4.6
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 +17 -0
- package/dist/I18nWrapper.js +6 -5
- package/dist/I18nWrapper.js.map +1 -1
- package/dist/components/ChatBubble/ChatBubble.js +28 -18
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/Header/Header.css +2 -2
- package/dist/components/MemoriWidget/MemoriWidget.js +4 -4
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/icons/Code.js +1 -1
- package/dist/components/icons/Code.js.map +1 -1
- package/dist/components/icons/Copy.js +1 -1
- package/dist/components/icons/Copy.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/esm/I18nWrapper.js +6 -5
- package/esm/I18nWrapper.js.map +1 -1
- package/esm/components/ChatBubble/ChatBubble.js +28 -18
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/Header/Header.css +2 -2
- package/esm/components/MemoriWidget/MemoriWidget.js +4 -4
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/icons/Code.js +1 -1
- package/esm/components/icons/Code.js.map +1 -1
- package/esm/components/icons/Copy.js +1 -1
- package/esm/components/icons/Copy.js.map +1 -1
- package/esm/index.js +3 -2
- package/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/I18nWrapper.tsx +6 -8
- package/src/components/ChatBubble/ChatBubble.stories.tsx +85 -3
- package/src/components/ChatBubble/ChatBubble.tsx +44 -34
- package/src/components/Header/Header.css +2 -2
- package/src/components/MemoriWidget/MemoriWidget.stories.tsx +13 -0
- package/src/components/MemoriWidget/MemoriWidget.tsx +14 -4
- package/src/components/icons/Code.tsx +3 -3
- package/src/components/icons/Copy.tsx +3 -3
- package/src/index.tsx +3 -2
|
@@ -389,8 +389,8 @@ ComplexMarkdownMath5.args = {
|
|
|
389
389
|
},
|
|
390
390
|
};
|
|
391
391
|
|
|
392
|
-
export const
|
|
393
|
-
|
|
392
|
+
export const ComplexMarkdownMath6 = Template.bind({});
|
|
393
|
+
ComplexMarkdownMath6.args = {
|
|
394
394
|
memori,
|
|
395
395
|
tenant,
|
|
396
396
|
apiUrl: 'https://backend.memori.ai',
|
|
@@ -398,6 +398,88 @@ ComplexMarkdownTest.args = {
|
|
|
398
398
|
fromUser: false,
|
|
399
399
|
initial: false,
|
|
400
400
|
generatedByAI: true,
|
|
401
|
-
text:
|
|
401
|
+
text: `La formula per il calcolo della spinta passiva non è riportata precisamente nel documento, ma in base alle informazioni presenti nella Specifica Tecnica per la redazione delle Verifiche Accurate di sicurezza di Livello 4 (ST-VAL4), il contesto del calcolo delle spinte passive può essere richiamato come segue:
|
|
402
|
+
|
|
403
|
+
Il calcolo della spinta passiva in geotecnica solitamente coinvolge il coefficiente di spinta passiva, che può esser calcolato usando diverse formulazioni a seconda delle condizioni (statiche o sismiche).
|
|
404
|
+
|
|
405
|
+
1. **In condizioni statiche**, il calcolo della pressione del terreno avviene considerando il coefficiente passivo $k_p$:$k_p = \frac{1 + sin(\phi)}{1 - sin(\phi)}$
|
|
406
|
+
|
|
407
|
+
2. **In condizioni sismiche**, si può utilizzare la formulazione di Mononobe-Okabe:
|
|
408
|
+
\[
|
|
409
|
+
k_h = \beta \cdot \frac{a_{\max}}{g}
|
|
410
|
+
\]
|
|
411
|
+
dove:
|
|
412
|
+
- $\beta$ è il coefficiente di riduzione della accelerazione massima attesa al sito
|
|
413
|
+
- $a_{\max}$ è l'accelerazione massima
|
|
414
|
+
- $g$ è l'accelerazione di gravità .
|
|
415
|
+
|
|
416
|
+
Se hai bisogno di dettagli più specifici o ulteriori informazioni su un altro argomento, fammi sapere!`,
|
|
417
|
+
},
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
export const ComplexMarkdownMath7 = Template.bind({});
|
|
421
|
+
ComplexMarkdownMath7.args = {
|
|
422
|
+
memori,
|
|
423
|
+
tenant,
|
|
424
|
+
apiUrl: 'https://backend.memori.ai',
|
|
425
|
+
message: {
|
|
426
|
+
fromUser: false,
|
|
427
|
+
initial: false,
|
|
428
|
+
generatedByAI: true,
|
|
429
|
+
text: `Il coefficiente di adeguatezza $𝜁_V$ è definito dalle normative NTC18 come il rapporto tra il valore massimo del sovraccarico verticale variabile sopportabile dalla parte i-esima della costruzione e il valore del sovraccarico verticale variabile che si utilizzerebbe nel progetto di una nuova costruzione.
|
|
430
|
+
|
|
431
|
+
Tale parametro viene calcolato tramite la seguente espressione:
|
|
432
|
+
|
|
433
|
+
$$
|
|
434
|
+
𝜁_V = \frac{𝑅_d - (𝐸_{d,G} + 𝐸_{d,Q𝑡,𝑜𝑟𝑖𝑧𝑧𝑜𝑛𝑡𝑎𝑙𝑖} + 𝐸_{d,Q𝑣𝑎𝑟𝑖𝑎𝑏𝑖𝑙𝑖})}{𝐸_{d,Q𝑡,𝑣𝑒𝑟𝑡𝑖𝑐𝑎𝑙𝑖}}
|
|
435
|
+
$$
|
|
436
|
+
|
|
437
|
+
dove:
|
|
438
|
+
|
|
439
|
+
- $𝑅_d$ è la capacità della sezione resistente;
|
|
440
|
+
- $𝐸_{d,G}$ è l’azione sollecitante derivante dai carichi permanenti;
|
|
441
|
+
- $𝐸_{d,Q𝑣𝑎𝑟𝑖𝑎𝑏𝑖𝑙𝑖}$ è l’azione sollecitante derivante dai carichi accidentali non da traffico (vento, azioni termiche, ecc.);
|
|
442
|
+
- $𝐸_{d,Q𝑡,𝑣𝑒𝑟𝑡𝑖𝑐𝑎𝑙𝑖}$ è l’azione sollecitante derivante dalla componente verticale dei carichi da traffico;
|
|
443
|
+
- $𝐸_{d,Q𝑡,𝑜𝑟𝑖𝑧𝑧𝑜𝑛𝑡𝑎𝑙𝑖}$ è l’azione sollecitante derivante dalla componente orizzontale dei carichi da traffico (frenatura o azione centrifuga).
|
|
444
|
+
|
|
445
|
+
In accordo con il §6.1.5 delle LG20, il coefficiente $𝜁_V$ ha significato solo per il livello di analisi di "Adeguamento" in quanto per i livelli di "Operatività" e "Transitabilità" la domanda per la quale si svolgono le valutazioni di sicurezza è determinata in condizioni differenti da quelle che si avrebbero per nuove costruzioni ($𝑡_{r𝑒𝑓}$ ridotto, restrizioni all’uso, limitazioni di carico).
|
|
446
|
+
|
|
447
|
+
I coefficienti $𝜁_V$ possono essere valutati per le combinazioni che considerano carichi da traffico con componente d’azione verticale .`,
|
|
448
|
+
},
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
export const WithHTML = Template.bind({});
|
|
452
|
+
WithHTML.args = {
|
|
453
|
+
memori,
|
|
454
|
+
tenant,
|
|
455
|
+
apiUrl: 'https://backend.memori.ai',
|
|
456
|
+
message: {
|
|
457
|
+
fromUser: false,
|
|
458
|
+
initial: false,
|
|
459
|
+
generatedByAI: true,
|
|
460
|
+
text: `
|
|
461
|
+
<div>
|
|
462
|
+
<div style="width: 30%; margin-bottom: 20px;">
|
|
463
|
+
<img src="https://www.e-stayon.com/images/thumbs/0244280_lenovo-ideapad-3-chromebook-15-intel-celeron-4gb-64gb_360.jpeg" style="width:100%">
|
|
464
|
+
<h3>Lenovo IdeaPad 3 Chromebook</h3>
|
|
465
|
+
<p>Intel Celeron, 15", 4GB RAM, 64GB</p>
|
|
466
|
+
<p>Prezzo: €194,88 (sconto 12% da €221,59)</p>
|
|
467
|
+
</div>
|
|
468
|
+
|
|
469
|
+
<div style="width: 30%; margin-bottom: 20px;">
|
|
470
|
+
<img src="https://www.e-stayon.com/images/thumbs/0244280_lenovo-ideapad-3-chromebook-15-intel-celeron-4gb-64gb_360.jpeg" style="width:100%">
|
|
471
|
+
<h3>Lenovo IdeaPad 3 Chromebook</h3>
|
|
472
|
+
<p>Intel Celeron, 15", 4GB RAM, 64GB</p>
|
|
473
|
+
<p>Prezzo: €194,88 (sconto 12% da €221,59)</p>
|
|
474
|
+
</div>
|
|
475
|
+
|
|
476
|
+
<div style="width: 30%; margin-bottom: 20px;">
|
|
477
|
+
<img src="https://www.e-stayon.com/images/thumbs/0244280_lenovo-ideapad-3-chromebook-15-intel-celeron-4gb-64gb_360.jpeg" style="width:100%">
|
|
478
|
+
<h3>Lenovo IdeaPad 3 Chromebook</h3>
|
|
479
|
+
<p>Intel Celeron, 15", 4GB RAM, 64GB</p>
|
|
480
|
+
<p>Prezzo: €194,88 (sconto 12% da €221,59)</p>
|
|
481
|
+
</div>
|
|
482
|
+
</div>
|
|
483
|
+
`,
|
|
402
484
|
},
|
|
403
485
|
};
|
|
@@ -72,7 +72,7 @@ marked.use({
|
|
|
72
72
|
marked.use(markedLinkifyIt());
|
|
73
73
|
marked.use(
|
|
74
74
|
markedKatex({
|
|
75
|
-
throwOnError:
|
|
75
|
+
throwOnError: false,
|
|
76
76
|
output: 'htmlAndMathml',
|
|
77
77
|
})
|
|
78
78
|
);
|
|
@@ -102,40 +102,50 @@ const ChatBubble: React.FC<Props> = ({
|
|
|
102
102
|
|
|
103
103
|
const text = message.translatedText || message.text;
|
|
104
104
|
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
105
|
+
const renderMsg = (text: string) => {
|
|
106
|
+
try {
|
|
107
|
+
return (
|
|
108
|
+
DOMPurify.sanitize(
|
|
109
|
+
(
|
|
110
|
+
marked.parse(
|
|
111
|
+
text
|
|
112
|
+
// remove leading and trailing whitespaces
|
|
113
|
+
.trim()
|
|
114
|
+
// remove markdown links
|
|
115
|
+
.replaceAll(
|
|
116
|
+
/\[([^\]]+)\]\(([^\)]+)\)/g,
|
|
117
|
+
'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'
|
|
118
|
+
)
|
|
119
|
+
// remove markdown multiline code blocks but keep the content
|
|
120
|
+
.replaceAll(/```markdown([^```]+)```/g, '$1')
|
|
121
|
+
.replaceAll('($', '( $')
|
|
122
|
+
.replaceAll(':$', ': $')
|
|
123
|
+
.replaceAll('\frac', '\\frac')
|
|
124
|
+
.replaceAll('\beta', '\\beta')
|
|
125
|
+
.replaceAll('cdot', '\\cdot')
|
|
126
|
+
) as string
|
|
127
|
+
)
|
|
128
|
+
.trim()
|
|
129
|
+
.replace(/\n/g, '<br>'),
|
|
130
|
+
{
|
|
131
|
+
ADD_ATTR: ['target'],
|
|
132
|
+
}
|
|
124
133
|
)
|
|
125
|
-
|
|
126
|
-
.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
// remove redundant mathjax delimiters
|
|
135
|
+
.replaceAll(/(?<!\\)\[/g, '\\[')
|
|
136
|
+
.replaceAll(/(?<!\\)\]/g, '\\]')
|
|
137
|
+
// replace consecutive <br> with a single <br>
|
|
138
|
+
.replace(/(<br>)+/g, '<br>')
|
|
139
|
+
// remove empty paragraphs
|
|
140
|
+
.replace(/<p><\/p>/g, '<br>')
|
|
141
|
+
.replace(/<p><br><\/p>/g, '<br>')
|
|
142
|
+
);
|
|
143
|
+
} catch (e) {
|
|
144
|
+
console.error(e);
|
|
145
|
+
return text;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const renderedText = message.fromUser ? text : renderMsg(text);
|
|
139
149
|
|
|
140
150
|
const plainText = message.fromUser
|
|
141
151
|
? text
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
justify-content: center;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.memori-header--button
|
|
28
|
+
.memori-header--button + .memori-header--button {
|
|
29
29
|
margin-left: 0.25rem;
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
.memori-header--button.memori-header--button--experts svg {
|
|
47
|
-
fill:
|
|
47
|
+
fill: currentColor;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
.memori-header--position {
|
|
@@ -149,6 +149,19 @@ WithoutAudio.args = {
|
|
|
149
149
|
AZURE_COGNITIVE_SERVICES_TTS_KEY: 'provide your key here',
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
+
export const WithoutAudioFromIntegrationConfig = Template.bind({});
|
|
153
|
+
WithoutAudioFromIntegrationConfig.args = {
|
|
154
|
+
memori,
|
|
155
|
+
tenant,
|
|
156
|
+
integration: {
|
|
157
|
+
...integration,
|
|
158
|
+
customData: JSON.stringify({
|
|
159
|
+
enableAudio: false,
|
|
160
|
+
}),
|
|
161
|
+
},
|
|
162
|
+
AZURE_COGNITIVE_SERVICES_TTS_KEY: 'provide your key here',
|
|
163
|
+
};
|
|
164
|
+
|
|
152
165
|
export const DefautSpeakerDisabled = Template.bind({});
|
|
153
166
|
DefautSpeakerDisabled.args = {
|
|
154
167
|
memori,
|
|
@@ -496,6 +496,9 @@ const MemoriWidget = ({
|
|
|
496
496
|
|
|
497
497
|
const selectedLayout = layout || integrationConfig?.layout || 'DEFAULT';
|
|
498
498
|
|
|
499
|
+
const defaultEnableAudio =
|
|
500
|
+
enableAudio ?? integrationConfig?.enableAudio ?? false;
|
|
501
|
+
|
|
499
502
|
const [hasUserActivatedSpeak, setHasUserActivatedSpeak] = useState(false);
|
|
500
503
|
const [hasUserActivatedListening, setHasUserActivatedListening] =
|
|
501
504
|
useState(false);
|
|
@@ -504,8 +507,7 @@ const MemoriWidget = ({
|
|
|
504
507
|
const [showKnownFactsDrawer, setShowKnownFactsDrawer] = useState(false);
|
|
505
508
|
const [showExpertsDrawer, setShowExpertsDrawer] = useState(false);
|
|
506
509
|
const [muteSpeaker, setMuteSpeaker] = useState(
|
|
507
|
-
!
|
|
508
|
-
!defaultSpeakerActive
|
|
510
|
+
!defaultEnableAudio || !defaultSpeakerActive
|
|
509
511
|
);
|
|
510
512
|
const [continuousSpeech, setContinuousSpeech] = useState(false);
|
|
511
513
|
const [continuousSpeechTimeout, setContinuousSpeechTimeout] = useState(2);
|
|
@@ -543,8 +545,16 @@ const MemoriWidget = ({
|
|
|
543
545
|
defaultControlsPosition = 'bottom';
|
|
544
546
|
}
|
|
545
547
|
|
|
546
|
-
setMuteSpeaker(
|
|
547
|
-
|
|
548
|
+
setMuteSpeaker(
|
|
549
|
+
getLocalConfig(
|
|
550
|
+
'muteSpeaker',
|
|
551
|
+
!defaultEnableAudio || !defaultSpeakerActive
|
|
552
|
+
)
|
|
553
|
+
);
|
|
554
|
+
speakerMuted = getLocalConfig(
|
|
555
|
+
'muteSpeaker',
|
|
556
|
+
!defaultEnableAudio || !defaultSpeakerActive
|
|
557
|
+
);
|
|
548
558
|
setContinuousSpeech(microphoneMode === 'CONTINUOUS');
|
|
549
559
|
setContinuousSpeechTimeout(getLocalConfig('continuousSpeechTimeout', 2));
|
|
550
560
|
setControlsPosition(
|
|
@@ -7,9 +7,9 @@ const Code = ({ className, title }: { className?: string; title?: string }) => (
|
|
|
7
7
|
viewBox="0 0 24 24"
|
|
8
8
|
fill="none"
|
|
9
9
|
stroke="currentColor"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
strokeWidth="1.5"
|
|
11
|
+
strokeLinecap="round"
|
|
12
|
+
strokeLinejoin="round"
|
|
13
13
|
focusable="false"
|
|
14
14
|
role="img"
|
|
15
15
|
className={className}
|
|
@@ -7,9 +7,9 @@ const Copy = ({ className, title }: { className?: string; title?: string }) => (
|
|
|
7
7
|
viewBox="0 0 24 24"
|
|
8
8
|
fill="none"
|
|
9
9
|
stroke="currentColor"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
strokeWidth="1.5"
|
|
11
|
+
strokeLinecap="round"
|
|
12
|
+
strokeLinejoin="round"
|
|
13
13
|
focusable="false"
|
|
14
14
|
role="img"
|
|
15
15
|
className={className}
|
package/src/index.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import { installMathJax } from './helpers/utils';
|
|
|
15
15
|
|
|
16
16
|
import i18n from './i18n';
|
|
17
17
|
import { I18nextProvider, useTranslation } from 'react-i18next';
|
|
18
|
+
import I18nWrapper from './I18nWrapper';
|
|
18
19
|
|
|
19
20
|
export interface Props {
|
|
20
21
|
memoriName?: string | null;
|
|
@@ -298,10 +299,10 @@ const Memori: React.FC<Props> = ({
|
|
|
298
299
|
);
|
|
299
300
|
|
|
300
301
|
return (
|
|
301
|
-
<
|
|
302
|
+
<I18nWrapper>
|
|
302
303
|
<Toaster position="top-center" reverseOrder={true} />
|
|
303
304
|
{renderer}
|
|
304
|
-
</
|
|
305
|
+
</I18nWrapper>
|
|
305
306
|
);
|
|
306
307
|
};
|
|
307
308
|
|