@memori.ai/memori-react 8.30.0 → 8.31.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 +15 -0
- package/dist/components/Header/Header.css +45 -0
- package/dist/components/Header/Header.d.ts +1 -0
- package/dist/components/Header/Header.js +74 -3
- package/dist/components/Header/Header.js.map +1 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js +5 -17
- package/dist/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +1 -0
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/PositionPopover/PositionPopover.css +194 -0
- package/dist/components/PositionPopover/PositionPopover.d.ts +15 -0
- package/dist/components/PositionPopover/PositionPopover.js +181 -0
- package/dist/components/PositionPopover/PositionPopover.js.map +1 -0
- package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.d.ts +4 -0
- package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.js +37 -0
- package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.js.map +1 -0
- package/dist/components/layouts/WebsiteAssistant/website-assistant.css +671 -0
- package/dist/components/layouts/chat.css +14 -0
- package/dist/components/layouts/fullpage.css +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/esm/components/Header/Header.css +45 -0
- package/esm/components/Header/Header.d.ts +1 -0
- package/esm/components/Header/Header.js +75 -4
- package/esm/components/Header/Header.js.map +1 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js +5 -17
- package/esm/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +1 -0
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/PositionPopover/PositionPopover.css +194 -0
- package/esm/components/PositionPopover/PositionPopover.d.ts +15 -0
- package/esm/components/PositionPopover/PositionPopover.js +178 -0
- package/esm/components/PositionPopover/PositionPopover.js.map +1 -0
- package/esm/components/layouts/WebsiteAssistant/WebsiteAssistant.d.ts +4 -0
- package/esm/components/layouts/WebsiteAssistant/WebsiteAssistant.js +34 -0
- package/esm/components/layouts/WebsiteAssistant/WebsiteAssistant.js.map +1 -0
- package/esm/components/layouts/WebsiteAssistant/website-assistant.css +671 -0
- package/esm/components/layouts/chat.css +14 -0
- package/esm/components/layouts/fullpage.css +2 -0
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/package.json +3 -4
- package/src/components/Header/Header.css +45 -0
- package/src/components/Header/Header.stories.tsx +46 -0
- package/src/components/Header/Header.tsx +151 -2
- package/src/components/MemoriArtifactSystem/ArtifactDrawer.stories.tsx +71 -0
- package/src/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.tsx +10 -24
- package/src/components/MemoriWidget/MemoriWidget.tsx +1 -0
- package/src/components/layouts/chat.css +14 -0
- package/src/components/layouts/layouts.stories.tsx +14 -14
- package/src/version.ts +1 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "8.
|
|
2
|
+
"version": "8.31.0",
|
|
3
3
|
"name": "@memori.ai/memori-react",
|
|
4
4
|
"author": "Memori Srl",
|
|
5
5
|
"main": "dist/index.js",
|
|
@@ -234,7 +234,6 @@
|
|
|
234
234
|
"@release-it/conventional-changelog": "5.1.1",
|
|
235
235
|
"@size-limit/preset-small-lib": "8.1.0",
|
|
236
236
|
"@storybook/addon-essentials": "7.4.0",
|
|
237
|
-
"@storybook/addon-info": "5.3.21",
|
|
238
237
|
"@storybook/addon-links": "7.4.0",
|
|
239
238
|
"@storybook/addon-mdx-gfm": "7.4.0",
|
|
240
239
|
"@storybook/addons": "7.4.0",
|
|
@@ -279,7 +278,7 @@
|
|
|
279
278
|
"release-it": "15.5.0",
|
|
280
279
|
"rimraf": "3.0.2",
|
|
281
280
|
"size-limit": "8.1.0",
|
|
282
|
-
"storybook": "7.
|
|
281
|
+
"storybook": "7.6.21",
|
|
283
282
|
"stylelint": "14.15.0",
|
|
284
283
|
"stylelint-config-idiomatic-order": "9.0.0",
|
|
285
284
|
"stylelint-config-prettier": "9.0.4",
|
|
@@ -298,7 +297,7 @@
|
|
|
298
297
|
"@react-three/drei": "8.20.2",
|
|
299
298
|
"@react-three/fiber": "7.0.25",
|
|
300
299
|
"classnames": "2.5.1",
|
|
301
|
-
"dompurify": "^3.
|
|
300
|
+
"dompurify": "^3.3.3",
|
|
302
301
|
"ellipsed": "1.6.0",
|
|
303
302
|
"i18next": "22.0.6",
|
|
304
303
|
"katex": "^0.16.11",
|
|
@@ -124,3 +124,48 @@
|
|
|
124
124
|
.memori-dropdown--avatar-initial:hover + .memori-dropdown--avatar-input,.memori-dropdown--avatar:hover + .memori-dropdown--avatar-input{
|
|
125
125
|
display: block;
|
|
126
126
|
}
|
|
127
|
+
|
|
128
|
+
.memori-dropdown--sustainability {
|
|
129
|
+
min-width: 260px;
|
|
130
|
+
padding: 0.625rem 0.75rem;
|
|
131
|
+
border-radius: 8px;
|
|
132
|
+
background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(247, 249, 252, 0.96) 100%);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.memori-dropdown--sustainability-title {
|
|
136
|
+
margin: 0 0 0.5rem 0;
|
|
137
|
+
font-size: 0.95rem;
|
|
138
|
+
font-weight: 700;
|
|
139
|
+
line-height: 1.2;
|
|
140
|
+
text-align: center;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.memori-dropdown--sustainability-metrics {
|
|
144
|
+
display: flex;
|
|
145
|
+
flex-direction: column;
|
|
146
|
+
gap: 0.35rem;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.memori-dropdown--sustainability-row {
|
|
150
|
+
display: flex;
|
|
151
|
+
align-items: center;
|
|
152
|
+
justify-content: space-between;
|
|
153
|
+
padding: 0.4rem 0.5rem;
|
|
154
|
+
border-radius: 6px;
|
|
155
|
+
background: rgba(255, 255, 255, 0.8);
|
|
156
|
+
gap: 1rem;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.memori-dropdown--sustainability-label {
|
|
160
|
+
display: inline-flex;
|
|
161
|
+
align-items: center;
|
|
162
|
+
font-size: 0.82rem;
|
|
163
|
+
font-weight: 500;
|
|
164
|
+
gap: 0.35rem;
|
|
165
|
+
opacity: 0.9;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.memori-dropdown--sustainability-value {
|
|
169
|
+
font-size: 0.85rem;
|
|
170
|
+
white-space: nowrap;
|
|
171
|
+
}
|
|
@@ -26,6 +26,31 @@ const meta: Meta = {
|
|
|
26
26
|
|
|
27
27
|
export default meta;
|
|
28
28
|
|
|
29
|
+
const historyWithConsumption = [
|
|
30
|
+
...history,
|
|
31
|
+
{
|
|
32
|
+
...history[history.length - 1],
|
|
33
|
+
llmUsage: {
|
|
34
|
+
energyImpact: {
|
|
35
|
+
energy: { parsedValue: 0.0012 },
|
|
36
|
+
gwp: { parsedValue: 0.00045 },
|
|
37
|
+
wcf: { parsedValue: 0.0021 },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
...history[history.length - 1],
|
|
43
|
+
text: 'Second sustainability sample',
|
|
44
|
+
llmUsage: {
|
|
45
|
+
energyImpact: {
|
|
46
|
+
energy: 0.0008,
|
|
47
|
+
gwp: { source: '0.00035' },
|
|
48
|
+
wcf: { source: '0.0014' },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
] as any;
|
|
53
|
+
|
|
29
54
|
const Template: Story<Props> = args => {
|
|
30
55
|
const [speakerMuted, setSpeakerMuted] = React.useState(args.speakerMuted);
|
|
31
56
|
const [showSettingsDrawer, setShowSettingsDrawer] = React.useState(false);
|
|
@@ -283,3 +308,24 @@ WithLogin.args = {
|
|
|
283
308
|
hasUserActivatedSpeak: false,
|
|
284
309
|
showLogin: true,
|
|
285
310
|
};
|
|
311
|
+
|
|
312
|
+
export const WithSustainabilityPopover = Template.bind({});
|
|
313
|
+
WithSustainabilityPopover.args = {
|
|
314
|
+
memori,
|
|
315
|
+
history: historyWithConsumption,
|
|
316
|
+
setShowPositionDrawer: () => {},
|
|
317
|
+
setShowSettingsDrawer: () => {},
|
|
318
|
+
setShowChatHistoryDrawer: () => {},
|
|
319
|
+
setShowKnownFactsDrawer: () => {},
|
|
320
|
+
setShowExpertsDrawer: () => {},
|
|
321
|
+
setShowLoginDrawer: () => {},
|
|
322
|
+
clearHistory: () => {},
|
|
323
|
+
speakerMuted: false,
|
|
324
|
+
hasUserActivatedSpeak: true,
|
|
325
|
+
showShare: false,
|
|
326
|
+
showSettings: false,
|
|
327
|
+
showMessageConsumption: true,
|
|
328
|
+
apiClient: {
|
|
329
|
+
backend: {},
|
|
330
|
+
} as any,
|
|
331
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import cx from 'classnames';
|
|
3
3
|
import {
|
|
4
4
|
Memori,
|
|
@@ -23,11 +23,13 @@ import DeepThought from '../icons/DeepThought';
|
|
|
23
23
|
import Group from '../icons/Group';
|
|
24
24
|
import UserIcon from '../icons/User';
|
|
25
25
|
import MessageIcon from '../icons/Message';
|
|
26
|
+
import Info from '../icons/Info';
|
|
26
27
|
import Logout from '../icons/Logout';
|
|
27
28
|
import { getErrori18nKey } from '../../helpers/error';
|
|
28
29
|
import toast from 'react-hot-toast';
|
|
29
30
|
import memoriApiClient from '@memori.ai/memori-api-client';
|
|
30
31
|
import { Props as WidgetProps } from '../MemoriWidget/MemoriWidget';
|
|
32
|
+
import { BADGE_EMOJI } from '../../helpers/llmUsage';
|
|
31
33
|
|
|
32
34
|
const imgMimeTypes = ['image/jpeg', 'image/png', 'image/jpg', 'image/gif'];
|
|
33
35
|
|
|
@@ -63,6 +65,7 @@ export interface Props {
|
|
|
63
65
|
apiClient: ReturnType<typeof memoriApiClient>;
|
|
64
66
|
layout?: WidgetProps['layout'];
|
|
65
67
|
additionalSettings?: WidgetProps['additionalSettings'];
|
|
68
|
+
showMessageConsumption?: boolean;
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
const Header: React.FC<Props> = ({
|
|
@@ -97,11 +100,96 @@ const Header: React.FC<Props> = ({
|
|
|
97
100
|
apiClient,
|
|
98
101
|
layout,
|
|
99
102
|
additionalSettings,
|
|
103
|
+
showMessageConsumption = false,
|
|
100
104
|
}) => {
|
|
101
|
-
const { t } = useTranslation();
|
|
105
|
+
const { t, i18n } = useTranslation();
|
|
102
106
|
const { uploadAsset, pwlUpdateUser } = apiClient.backend;
|
|
103
107
|
const [fullScreenAvailable, setFullScreenAvailable] = useState(false);
|
|
104
108
|
const [fullScreen, setFullScreen] = useState(false);
|
|
109
|
+
|
|
110
|
+
type ImpactMetricType = 'energy' | 'co2' | 'water';
|
|
111
|
+
|
|
112
|
+
type LlmUsageEnergyImpact = {
|
|
113
|
+
energy?: number | { source?: string; parsedValue?: number };
|
|
114
|
+
gwp?: number | { source?: string; parsedValue?: number };
|
|
115
|
+
wcf?: number | { source?: string; parsedValue?: number };
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const getMetricValue = (
|
|
119
|
+
metric?: number | { source?: string; parsedValue?: number },
|
|
120
|
+
): number | undefined => {
|
|
121
|
+
if (typeof metric === 'number' && Number.isFinite(metric)) return metric;
|
|
122
|
+
if (!metric || typeof metric !== 'object') return undefined;
|
|
123
|
+
if (
|
|
124
|
+
typeof metric.parsedValue === 'number' &&
|
|
125
|
+
Number.isFinite(metric.parsedValue)
|
|
126
|
+
) {
|
|
127
|
+
return metric.parsedValue;
|
|
128
|
+
}
|
|
129
|
+
if (typeof metric.source === 'string') {
|
|
130
|
+
const parsed = Number(metric.source);
|
|
131
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
132
|
+
}
|
|
133
|
+
return undefined;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const formatMetricValue = (value: number, locale: string): string =>
|
|
137
|
+
new Intl.NumberFormat(locale, {
|
|
138
|
+
minimumFractionDigits: 0,
|
|
139
|
+
maximumFractionDigits: Math.abs(value) >= 1 ? 3 : 4,
|
|
140
|
+
}).format(value);
|
|
141
|
+
|
|
142
|
+
const formatImpactInReadableUnit = (
|
|
143
|
+
value: number,
|
|
144
|
+
metricType: ImpactMetricType,
|
|
145
|
+
locale: string,
|
|
146
|
+
): string => {
|
|
147
|
+
const absValue = Math.abs(value);
|
|
148
|
+
|
|
149
|
+
if (metricType === 'energy') {
|
|
150
|
+
if (absValue >= 1) return `${formatMetricValue(value, locale)} kWh`;
|
|
151
|
+
const wh = value * 1000;
|
|
152
|
+
if (Math.abs(wh) >= 1) return `${formatMetricValue(wh, locale)} Wh`;
|
|
153
|
+
return `${formatMetricValue(wh * 1000, locale)} mWh`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (metricType === 'co2') {
|
|
157
|
+
if (absValue >= 1) return `${formatMetricValue(value, locale)} kg`;
|
|
158
|
+
const g = value * 1000;
|
|
159
|
+
if (Math.abs(g) >= 1) return `${formatMetricValue(g, locale)} g`;
|
|
160
|
+
return `${formatMetricValue(g * 1000, locale)} mg`;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (absValue >= 1) return `${formatMetricValue(value, locale)} L`;
|
|
164
|
+
const ml = value * 1000;
|
|
165
|
+
if (Math.abs(ml) >= 1) return `${formatMetricValue(ml, locale)} mL`;
|
|
166
|
+
return `${formatMetricValue(ml * 1000, locale)} μL`;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const currentLocale = i18n.language || navigator.language || 'en';
|
|
170
|
+
const chatLog = useMemo(() => ({ lines: history }), [history]);
|
|
171
|
+
const sustainabilityTotals = useMemo(() => {
|
|
172
|
+
const totals = { energy: 0, gwp: 0, wcf: 0 };
|
|
173
|
+
(chatLog?.lines ?? []).forEach(line => {
|
|
174
|
+
const energyImpact = (line as Message & {
|
|
175
|
+
llmUsage?: { energyImpact?: LlmUsageEnergyImpact };
|
|
176
|
+
}).llmUsage?.energyImpact;
|
|
177
|
+
if (!energyImpact) return;
|
|
178
|
+
totals.energy += getMetricValue(energyImpact.energy) ?? 0;
|
|
179
|
+
totals.gwp += getMetricValue(energyImpact.gwp) ?? 0;
|
|
180
|
+
totals.wcf += getMetricValue(energyImpact.wcf) ?? 0;
|
|
181
|
+
});
|
|
182
|
+
return totals;
|
|
183
|
+
}, [chatLog]);
|
|
184
|
+
const hasSustainabilityData = useMemo(
|
|
185
|
+
() =>
|
|
186
|
+
(chatLog?.lines ?? []).some(
|
|
187
|
+
line =>
|
|
188
|
+
!!(line as Message & { llmUsage?: { energyImpact?: LlmUsageEnergyImpact } })
|
|
189
|
+
.llmUsage?.energyImpact
|
|
190
|
+
),
|
|
191
|
+
[chatLog]
|
|
192
|
+
);
|
|
105
193
|
useEffect(() => {
|
|
106
194
|
if (document.fullscreenEnabled) {
|
|
107
195
|
setFullScreenAvailable(true);
|
|
@@ -219,6 +307,67 @@ const Header: React.FC<Props> = ({
|
|
|
219
307
|
onClick={() => setShowChatHistoryDrawer(true)}
|
|
220
308
|
/>
|
|
221
309
|
)}
|
|
310
|
+
{showMessageConsumption && hasSustainabilityData && (
|
|
311
|
+
<Dropdown
|
|
312
|
+
placement="bottom-right"
|
|
313
|
+
trigger={
|
|
314
|
+
<Button
|
|
315
|
+
primary
|
|
316
|
+
shape="circle"
|
|
317
|
+
className={cx('memori-header--button', 'memori-header--button--sustainability', hasSpacedButtons && 'memori-header--button-spaced')}
|
|
318
|
+
title={t('write_and_speak.showMessageConsumptionLabel') || 'LLM consumption'}
|
|
319
|
+
icon={<Info />}
|
|
320
|
+
/>
|
|
321
|
+
}
|
|
322
|
+
>
|
|
323
|
+
<div className="memori-dropdown--sustainability">
|
|
324
|
+
<h4 className="memori-dropdown--sustainability-title">
|
|
325
|
+
Consumo Totale Chat
|
|
326
|
+
</h4>
|
|
327
|
+
<div className="memori-dropdown--sustainability-metrics">
|
|
328
|
+
<div className="memori-dropdown--sustainability-row">
|
|
329
|
+
<span className="memori-dropdown--sustainability-label">
|
|
330
|
+
<span aria-hidden="true">{BADGE_EMOJI.energy}</span>{' '}
|
|
331
|
+
{t('energy') || 'Energy'}
|
|
332
|
+
</span>
|
|
333
|
+
<strong className="memori-dropdown--sustainability-value">
|
|
334
|
+
{formatImpactInReadableUnit(
|
|
335
|
+
sustainabilityTotals.energy,
|
|
336
|
+
'energy',
|
|
337
|
+
currentLocale
|
|
338
|
+
)}
|
|
339
|
+
</strong>
|
|
340
|
+
</div>
|
|
341
|
+
<div className="memori-dropdown--sustainability-row">
|
|
342
|
+
<span className="memori-dropdown--sustainability-label">
|
|
343
|
+
<span aria-hidden="true">{BADGE_EMOJI.co2}</span>{' '}
|
|
344
|
+
{t('co2') || 'CO2'}
|
|
345
|
+
</span>
|
|
346
|
+
<strong className="memori-dropdown--sustainability-value">
|
|
347
|
+
{formatImpactInReadableUnit(
|
|
348
|
+
sustainabilityTotals.gwp,
|
|
349
|
+
'co2',
|
|
350
|
+
currentLocale
|
|
351
|
+
)}
|
|
352
|
+
</strong>
|
|
353
|
+
</div>
|
|
354
|
+
<div className="memori-dropdown--sustainability-row">
|
|
355
|
+
<span className="memori-dropdown--sustainability-label">
|
|
356
|
+
<span aria-hidden="true">{BADGE_EMOJI.water}</span>{' '}
|
|
357
|
+
{t('water') || 'Water'}
|
|
358
|
+
</span>
|
|
359
|
+
<strong className="memori-dropdown--sustainability-value">
|
|
360
|
+
{formatImpactInReadableUnit(
|
|
361
|
+
sustainabilityTotals.wcf,
|
|
362
|
+
'water',
|
|
363
|
+
currentLocale
|
|
364
|
+
)}
|
|
365
|
+
</strong>
|
|
366
|
+
</div>
|
|
367
|
+
</div>
|
|
368
|
+
</div>
|
|
369
|
+
</Dropdown>
|
|
370
|
+
)}
|
|
222
371
|
{fullScreenAvailable && (
|
|
223
372
|
<Button
|
|
224
373
|
primary
|
|
@@ -790,6 +790,43 @@ function hello() {
|
|
|
790
790
|
This project helps you build amazing applications.
|
|
791
791
|
</output>`;
|
|
792
792
|
|
|
793
|
+
const markdownCustomArtifact = `<output class="memori-artifact" data-mimetype="markdown" data-title="CUSTOM_MARKDOWN_TEST.md">
|
|
794
|
+
# Custom Markdown Rendering Test
|
|
795
|
+
|
|
796
|
+
## Text formatting
|
|
797
|
+
Use **bold**, *italic*, and \`inline code\` in the same sentence.
|
|
798
|
+
|
|
799
|
+
## Checklist
|
|
800
|
+
- [x] Parse headings
|
|
801
|
+
- [x] Render lists
|
|
802
|
+
- [ ] Verify custom table support
|
|
803
|
+
|
|
804
|
+
## Table
|
|
805
|
+
| Feature | Expected |
|
|
806
|
+
| --- | --- |
|
|
807
|
+
| Link rendering | Opens in a new tab |
|
|
808
|
+
| Code block | Preserves indentation |
|
|
809
|
+
| Blockquote | Styled correctly |
|
|
810
|
+
|
|
811
|
+
## Blockquote
|
|
812
|
+
> This is a quoted note to verify markdown styling in preview mode.
|
|
813
|
+
|
|
814
|
+
## Code block
|
|
815
|
+
\`\`\`ts
|
|
816
|
+
type User = {
|
|
817
|
+
id: string;
|
|
818
|
+
name: string;
|
|
819
|
+
active: boolean;
|
|
820
|
+
};
|
|
821
|
+
|
|
822
|
+
const toLabel = (user: User) => \`\${user.name} (\${user.id})\`;
|
|
823
|
+
\`\`\`
|
|
824
|
+
|
|
825
|
+
## Links
|
|
826
|
+
- [Memori website](https://memori.ai)
|
|
827
|
+
- [Example docs](https://example.com/docs)
|
|
828
|
+
</output>`;
|
|
829
|
+
|
|
793
830
|
const cssArtifact = `<output class="memori-artifact" data-mimetype="css">
|
|
794
831
|
/* Modern CSS Grid Layout */
|
|
795
832
|
.container {
|
|
@@ -1112,6 +1149,40 @@ This includes all the essential sections for a project README with proper format
|
|
|
1112
1149
|
),
|
|
1113
1150
|
};
|
|
1114
1151
|
|
|
1152
|
+
export const MarkdownCustomRendering: Story = {
|
|
1153
|
+
args: {},
|
|
1154
|
+
render: () => (
|
|
1155
|
+
<Chat
|
|
1156
|
+
memori={mockMemori}
|
|
1157
|
+
tenant={mockTenant}
|
|
1158
|
+
sessionID="test-session"
|
|
1159
|
+
history={[
|
|
1160
|
+
{
|
|
1161
|
+
text: `I generated a custom markdown artifact to validate rendering behavior:
|
|
1162
|
+
|
|
1163
|
+
${markdownCustomArtifact}
|
|
1164
|
+
|
|
1165
|
+
Please check preview and code tabs to verify the output.`,
|
|
1166
|
+
fromUser: false,
|
|
1167
|
+
timestamp: new Date().toISOString(),
|
|
1168
|
+
},
|
|
1169
|
+
]}
|
|
1170
|
+
pushMessage={mockPushMessage}
|
|
1171
|
+
simulateUserPrompt={mockSimulateUserPrompt}
|
|
1172
|
+
onChangeUserMessage={mockOnChangeUserMessage}
|
|
1173
|
+
sendMessage={mockSendMessage}
|
|
1174
|
+
setEnableFocusChatInput={mockSetEnableFocusChatInput}
|
|
1175
|
+
stopAudio={mockStopAudio}
|
|
1176
|
+
startListening={mockStartListening}
|
|
1177
|
+
stopListening={mockStopListening}
|
|
1178
|
+
setSendOnEnter={mockSetSendOnEnter}
|
|
1179
|
+
setAttachmentsMenuOpen={mockSetAttachmentsMenuOpen}
|
|
1180
|
+
showInputs={false}
|
|
1181
|
+
isChatlogPanel={false}
|
|
1182
|
+
/>
|
|
1183
|
+
),
|
|
1184
|
+
};
|
|
1185
|
+
|
|
1115
1186
|
export const CSSStyles: Story = {
|
|
1116
1187
|
args: {},
|
|
1117
1188
|
render: () => (
|
|
@@ -13,6 +13,7 @@ import Code from '../../../icons/Code';
|
|
|
13
13
|
import { PreviewIcon } from '../../../icons/Preview';
|
|
14
14
|
import Snippet from '../../../Snippet/Snippet';
|
|
15
15
|
import { Medium } from '@memori.ai/memori-api-client/dist/types';
|
|
16
|
+
import { renderMsg } from '../../../../helpers/message';
|
|
16
17
|
|
|
17
18
|
const ArtifactPreview: React.FC<{
|
|
18
19
|
artifact: ArtifactData;
|
|
@@ -41,15 +42,22 @@ const ArtifactPreview: React.FC<{
|
|
|
41
42
|
/>
|
|
42
43
|
);
|
|
43
44
|
|
|
44
|
-
case 'markdown':
|
|
45
|
+
case 'markdown': {
|
|
46
|
+
const { text: renderedMarkdown } = renderMsg(
|
|
47
|
+
artifact.content,
|
|
48
|
+
false,
|
|
49
|
+
'Reasoning...',
|
|
50
|
+
false
|
|
51
|
+
);
|
|
45
52
|
return (
|
|
46
53
|
<div
|
|
47
54
|
className="memori-artifact-preview-markdown"
|
|
48
55
|
dangerouslySetInnerHTML={{
|
|
49
|
-
__html:
|
|
56
|
+
__html: renderedMarkdown,
|
|
50
57
|
}}
|
|
51
58
|
/>
|
|
52
59
|
);
|
|
60
|
+
}
|
|
53
61
|
|
|
54
62
|
default:
|
|
55
63
|
return (
|
|
@@ -63,28 +71,6 @@ const ArtifactPreview: React.FC<{
|
|
|
63
71
|
}
|
|
64
72
|
}, [artifact]);
|
|
65
73
|
|
|
66
|
-
/**
|
|
67
|
-
* Basic markdown rendering
|
|
68
|
-
*/
|
|
69
|
-
const renderMarkdown = useCallback((markdown: string): string => {
|
|
70
|
-
return markdown
|
|
71
|
-
.replace(/^# (.*$)/gim, '<h1>$1</h1>')
|
|
72
|
-
.replace(/^## (.*$)/gim, '<h2>$1</h2>')
|
|
73
|
-
.replace(/^### (.*$)/gim, '<h3>$1</h3>')
|
|
74
|
-
.replace(/^#### (.*$)/gim, '<h4>$1</h4>')
|
|
75
|
-
.replace(/^##### (.*$)/gim, '<h5>$1</h5>')
|
|
76
|
-
.replace(/^###### (.*$)/gim, '<h6>$1</h6>')
|
|
77
|
-
.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
|
|
78
|
-
.replace(/\*(.*?)\*/g, '<em>$1</em>')
|
|
79
|
-
.replace(/`(.*?)`/g, '<code>$1</code>')
|
|
80
|
-
.replace(/```([\s\S]*?)```/g, '<pre><code>$1</code></pre>')
|
|
81
|
-
.replace(
|
|
82
|
-
/\[([^\]]+)\]\(([^)]+)\)/g,
|
|
83
|
-
'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'
|
|
84
|
-
)
|
|
85
|
-
.replace(/\n/g, '<br>');
|
|
86
|
-
}, []);
|
|
87
|
-
|
|
88
74
|
const mapArtifactMimeTypeToSnippetMimeType = useCallback(
|
|
89
75
|
(mimeType: string) => {
|
|
90
76
|
switch (mimeType) {
|
|
@@ -2896,6 +2896,7 @@ const MemoriWidget = ({
|
|
|
2896
2896
|
showSettings: showSettings ?? integrationConfig?.showSettings ?? true,
|
|
2897
2897
|
showChatHistory:
|
|
2898
2898
|
showChatHistory ?? integrationConfig?.showChatHistory ?? true,
|
|
2899
|
+
showMessageConsumption: enableMessageConsumption,
|
|
2899
2900
|
hasUserActivatedSpeak,
|
|
2900
2901
|
showReload: selectedLayout === 'TOTEM',
|
|
2901
2902
|
showClear: showClear ?? integrationConfig?.showClear ?? false,
|
|
@@ -18,6 +18,16 @@
|
|
|
18
18
|
transition: all 0.05s ease-in-out;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
.memori-chat-layout--header .memori-header {
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
width: calc(50% - 1rem);
|
|
24
|
+
max-width: 100%;
|
|
25
|
+
flex-wrap: wrap;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: flex-end;
|
|
28
|
+
gap: 0.2rem;
|
|
29
|
+
}
|
|
30
|
+
|
|
21
31
|
.memori-chat-layout--header-with-artifact {
|
|
22
32
|
display: none;
|
|
23
33
|
}
|
|
@@ -144,6 +154,10 @@
|
|
|
144
154
|
}
|
|
145
155
|
|
|
146
156
|
@media (max-width: 870px) {
|
|
157
|
+
.memori-chat-layout--header .memori-header {
|
|
158
|
+
width: 100%;
|
|
159
|
+
}
|
|
160
|
+
|
|
147
161
|
.memori-chat-layout .memori--powered-by {
|
|
148
162
|
top: 3.5rem;
|
|
149
163
|
bottom: auto;
|
|
@@ -52,6 +52,7 @@ DefaultLayout.args = {
|
|
|
52
52
|
showLogin: true,
|
|
53
53
|
multilingual: true,
|
|
54
54
|
avatar3dHidden: true,
|
|
55
|
+
showMessageConsumption: true,
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
|
|
@@ -227,18 +228,17 @@ HiddenChat.args = {
|
|
|
227
228
|
export const ZoomedFullBody = Template.bind({});
|
|
228
229
|
ZoomedFullBody.args = {
|
|
229
230
|
...DefaultLayout.args,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
layout: 'ZOOMED_FULL_BODY',
|
|
231
|
+
memoriName: "Layout Storybook",
|
|
232
|
+
ownerUserName: "Andrea-Patini",
|
|
233
|
+
memoriID: "ae20fc5a-cc15-4db9-b7dd-2cd4a621b85e",
|
|
234
|
+
ownerUserID: "91dbc9ba-b684-4fbe-9828-b5980af6cda9",
|
|
235
|
+
tenantID: "aisuru-staging.aclambda.online",
|
|
236
|
+
engineURL: "https://engine-staging.memori.ai/memori/v2",
|
|
237
|
+
apiURL: "https://backend-staging.memori.ai/api/v2",
|
|
238
|
+
baseURL: "http://localhost:3000",
|
|
239
|
+
layout: "FULLPAGE",
|
|
240
|
+
uiLang: "IT",
|
|
241
|
+
spokenLang: "IT",
|
|
242
|
+
integrationID: "32922e14-24d6-4f5f-a06b-d963da14a658",
|
|
243
|
+
showSettings: true
|
|
244
244
|
};
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is auto-generated. Do not edit manually.
|
|
2
|
-
export const version = '8.
|
|
2
|
+
export const version = '8.31.0';
|