@memori.ai/memori-react 6.4.0 → 6.4.2

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.
@@ -8,19 +8,22 @@ import toast from 'react-hot-toast';
8
8
  import { getErrori18nKey } from '../../helpers/error';
9
9
  import { useTranslation } from 'react-i18next';
10
10
  import Snippet from '../Snippet/Snippet';
11
+ import MediaWidget from '../MediaWidget/MediaWidget';
11
12
  const addQuestionMark = (question) => question.endsWith('?') ? question : `${question}?`;
12
- const WhyThisAnswer = ({ message, apiURL, sessionID, visible = true, initialMatches = [], closeDrawer, }) => {
13
+ const WhyThisAnswer = ({ message, apiURL, sessionID, visible = true, initialMatches = [], closeDrawer, _TEST_loading = false, }) => {
13
14
  const { t } = useTranslation();
14
15
  const client = memoriApiClient(apiURL);
15
16
  const searchMemory = client.search.searchMemory;
16
17
  const [matches, setMatches] = useState(initialMatches);
17
- const [loading, setLoading] = useState(false);
18
+ const [loading, setLoading] = useState(_TEST_loading);
18
19
  const fetchMemories = useCallback(async () => {
19
20
  setLoading(true);
21
+ if (_TEST_loading)
22
+ return;
20
23
  try {
21
24
  const { matches, ...response } = await searchMemory(sessionID, {
22
25
  searchType: 'Semantic',
23
- numberOfResults: 5,
26
+ numberOfResults: 3,
24
27
  text: message.questionAnswered,
25
28
  date: message.date,
26
29
  placeName: message.placeName,
@@ -28,6 +31,7 @@ const WhyThisAnswer = ({ message, apiURL, sessionID, visible = true, initialMatc
28
31
  placeLongitude: message.placeLongitude,
29
32
  placeUncertaintyKm: message.placeUncertaintyKm,
30
33
  contextVars: message.contextVars,
34
+ tag: message.tag,
31
35
  });
32
36
  if (response.resultCode !== 0) {
33
37
  console.error(response);
@@ -46,13 +50,9 @@ const WhyThisAnswer = ({ message, apiURL, sessionID, visible = true, initialMatc
46
50
  useEffect(() => {
47
51
  fetchMemories();
48
52
  }, [fetchMemories, message, sessionID]);
49
- return (_jsxs(Drawer, { open: visible, width: "80%", animated: false, className: "memori-whythisanswer-drawer", onClose: () => closeDrawer(), title: t('whyThisAnswer'), children: [_jsx("p", { children: t('whyThisAnswerHelper') }), message.questionAnswered && (_jsxs("p", { className: "memori--whythisanswer-question-answered", children: [_jsxs("strong", { children: [t('question') || 'Question', ":"] }), ' ', message.questionAnswered] })), _jsxs(Spin, { spinning: loading, children: [!loading && matches.length === 0 && (_jsx("p", { role: "info", className: "memori--whythisanswer-no-results", children: t('nothingFound') })), matches.length > 0 && (_jsx("ul", { className: "memori--whythisanswer-list", children: matches.map(m => {
50
- var _a, _b, _c, _d, _e, _f;
51
- return (_jsxs("li", { children: [_jsxs("div", { className: "memori--whythisanswer-title", children: [_jsx("span", { className: "memori--whythisanswer-confidence", children: m.confidenceLevel }), _jsxs("div", { className: "memori--whythisanswer-title-text", children: [_jsx("p", { children: _jsx("strong", { children: addQuestionMark((_a = m.memory.title) !== null && _a !== void 0 ? _a : '') }) }), _jsx("p", { children: (_c = (_b = m.memory.titleVariants) === null || _b === void 0 ? void 0 : _b.map(t => addQuestionMark(t))) === null || _c === void 0 ? void 0 : _c.join(' | ') })] })] }), (_d = m.memory.answers) === null || _d === void 0 ? void 0 : _d.map((a, i) => (_jsx("p", { className: "memori--whythisanswer-answer", children: _jsx(Expandable, { rows: 3, children: a.text }) }, i))), !!((_f = (_e = m.memory.media) === null || _e === void 0 ? void 0 : _e.filter(m => m.mimeType === 'text/plain')) === null || _f === void 0 ? void 0 : _f.length) && (_jsx(Snippet, { medium: {
52
- mediumID: m.memory.memoryID,
53
- mimeType: 'text/plain',
54
- content: m.memory.media.filter(m => m.mimeType === 'text/plain')[0].content,
55
- }, showCopyButton: false, showLineNumbers: false }))] }, m.memory.memoryID));
53
+ return (_jsxs(Drawer, { open: visible, width: "80%", animated: false, className: "memori-whythisanswer-drawer", onClose: () => closeDrawer(), title: t('whyThisAnswer'), children: [_jsx("p", { children: t('whyThisAnswerHelper') }), message.questionAnswered && (_jsxs("p", { className: "memori--whythisanswer-question-answered", children: [_jsxs("strong", { children: [t('question') || 'Question', ":"] }), ' ', message.questionAnswered] })), _jsxs(Spin, { primary: true, spinning: loading, children: [!loading && matches.length === 0 && (_jsx("p", { role: "info", className: "memori--whythisanswer-no-results", children: t('nothingFound') })), loading && matches.length === 0 && (_jsxs("ul", { className: "memori--whythisanswer-list memori--whythisanswer-skeleton", children: [_jsxs("li", { children: [_jsxs("div", { className: "memori--whythisanswer-title", children: [_jsx("span", { className: "memori--whythisanswer-confidence", children: _jsx("span", { className: "memori--whythisanswer-skeleton-text" }) }), _jsx("div", { className: "memori--whythisanswer-title-text", children: _jsx("p", { className: "memori--whythisanswer-skeleton-text" }) })] }), _jsxs("p", { children: [_jsx("div", { className: "memori--whythisanswer-skeleton-text" }), _jsx("div", { className: "memori--whythisanswer-skeleton-text" }), _jsx("div", { className: "memori--whythisanswer-skeleton-text" })] }), _jsx("div", { className: "memori--whythisanswer-skeleton-block" })] }), _jsxs("li", { children: [_jsxs("div", { className: "memori--whythisanswer-title", children: [_jsx("span", { className: "memori--whythisanswer-confidence", children: _jsx("span", { className: "memori--whythisanswer-skeleton-text" }) }), _jsxs("div", { className: "memori--whythisanswer-title-text", children: [_jsx("p", { className: "memori--whythisanswer-skeleton-text" }), _jsx("p", { className: "memori--whythisanswer-skeleton-text" })] })] }), _jsxs("p", { children: [_jsx("div", { className: "memori--whythisanswer-skeleton-text" }), _jsx("div", { className: "memori--whythisanswer-skeleton-text" })] }), _jsx("div", { className: "memori--whythisanswer-skeleton-block" })] })] })), matches.length > 0 && (_jsx("ul", { className: "memori--whythisanswer-list", children: matches.map(m => {
54
+ var _a, _b, _c, _d, _e, _f, _g;
55
+ return (_jsxs("li", { children: [_jsxs("div", { className: "memori--whythisanswer-title", children: [_jsx("span", { className: "memori--whythisanswer-confidence", children: m.confidenceLevel }), _jsxs("div", { className: "memori--whythisanswer-title-text", children: [_jsx("p", { children: _jsx("strong", { children: addQuestionMark((_a = m.memory.title) !== null && _a !== void 0 ? _a : '') }) }), _jsx("p", { children: (_c = (_b = m.memory.titleVariants) === null || _b === void 0 ? void 0 : _b.map(t => addQuestionMark(t))) === null || _c === void 0 ? void 0 : _c.join(' | ') })] })] }), (_d = m.memory.answers) === null || _d === void 0 ? void 0 : _d.map((a, i) => (_jsx("p", { className: "memori--whythisanswer-answer", children: _jsx(Expandable, { rows: 3, children: a.text }) }, i))), _jsx(MediaWidget, { links: (_e = m.memory.media) === null || _e === void 0 ? void 0 : _e.filter(m => m.mimeType === 'text/html') }), (_g = (_f = m.memory.media) === null || _f === void 0 ? void 0 : _f.filter(m => m.mimeType === 'text/plain')) === null || _g === void 0 ? void 0 : _g.map(m => (_jsx(Expandable, { rows: 2, lineHeightMultiplier: 2, innerClassName: "memori--whythisanswer-snippet-expandable", children: _jsx(Snippet, { medium: m, showCopyButton: false, showLineNumbers: false }, m.mediumID) }, m.mediumID)))] }, m.memory.memoryID));
56
56
  }) }))] })] }));
57
57
  };
58
58
  export default WhyThisAnswer;
@@ -1 +1 @@
1
- {"version":3,"file":"WhyThisAnswer.js","sourceRoot":"","sources":["../../../src/components/WhyThisAnswer/WhyThisAnswer.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAWzC,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAE,EAAE,CAC3C,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,C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,CAC3B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,WAAW,CAChC,GACD,EAED,MAAA,MAAA,CAAC,CAAC,MAAM,CAAC,KAAK,0CACX,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,YAAY,CAAC,0CACxC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CACT,KAAC,UAAU,IACT,IAAI,EAAE,CAAC,EAEP,oBAAoB,EAAE,CAAC,EACvB,cAAc,EAAC,0CAA0C,YAEzD,KAAC,OAAO,IAEN,MAAM,EAAE,CAAC,EACT,cAAc,EAAE,KAAK,EACrB,eAAe,EAAE,KAAK,IAHjB,CAAC,CAAC,QAAQ,CAIf,IATG,CAAC,CAAC,QAAQ,CAUJ,CACd,CAAC,KA5CG,CAAC,CAAC,MAAM,CAAC,QAAQ,CA6CrB,CACN,CAAA;yBAAA,CAAC,GACC,CACN,IACI,IACA,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -4,10 +4,11 @@ export interface Props {
4
4
  className?: string;
5
5
  innerClassName?: string;
6
6
  btnClassName?: string;
7
+ lineHeightMultiplier?: number;
7
8
  defaultExpanded?: boolean;
8
9
  expandSymbol?: (lang: string) => React.ReactNode;
9
10
  collapseSymbol?: (lang: string) => React.ReactNode;
10
11
  children: React.ReactNode;
11
12
  }
12
- declare const Expandable: ({ rows, className, innerClassName, btnClassName, defaultExpanded, expandSymbol, collapseSymbol, children, }: Props) => JSX.Element;
13
+ declare const Expandable: ({ rows, className, innerClassName, btnClassName, lineHeightMultiplier, defaultExpanded, expandSymbol, collapseSymbol, children, }: Props) => JSX.Element;
13
14
  export default Expandable;
@@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from 'react';
3
3
  import Button from './Button';
4
4
  import cx from 'classnames';
5
5
  import { useTranslation } from 'react-i18next';
6
- const Expandable = ({ rows, className, innerClassName, btnClassName, defaultExpanded = false, expandSymbol = () => '...', collapseSymbol = (lang) => lang === 'it' ? 'Mostra meno' : 'Show less', children, }) => {
6
+ const Expandable = ({ rows, className, innerClassName, btnClassName, lineHeightMultiplier = 1.2, defaultExpanded = false, expandSymbol = () => '...', collapseSymbol = (lang) => lang === 'it' ? 'Mostra meno' : 'Show less', children, }) => {
7
7
  const { i18n } = useTranslation();
8
8
  const lang = i18n.language;
9
9
  const collapseSymbolText = collapseSymbol(lang);
@@ -18,7 +18,7 @@ const Expandable = ({ rows, className, innerClassName, btnClassName, defaultExpa
18
18
  let computedStyle = getComputedStyle(ref.current);
19
19
  let elLineHeight = computedStyle.lineHeight;
20
20
  let lineHeight = elLineHeight === 'normal' || !(elLineHeight === null || elLineHeight === void 0 ? void 0 : elLineHeight.length)
21
- ? 1.2 * parseInt(computedStyle.fontSize, 10)
21
+ ? lineHeightMultiplier * parseInt(computedStyle.fontSize, 10)
22
22
  : parseInt(elLineHeight, 10);
23
23
  console.table({
24
24
  rows,
@@ -1 +1 @@
1
- {"version":3,"file":"Expandable.js","sourceRoot":"","sources":["../../../src/components/ui/Expandable.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAa/C,MAAM,UAAU,GAAG,CAAC,EAClB,IAAI,EACJ,SAAS,EACT,cAAc,EACd,YAAY,EACZ,eAAe,GAAG,KAAK,EACvB,YAAY,GAAG,GAAG,EAAE,CAAC,KAAK,EAC1B,cAAc,GAAG,CAAC,IAAY,EAAE,EAAE,CAChC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,EAC7C,QAAQ,GACF,EAAE,EAAE;IACV,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,EAAE,CAAC;IA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AAU,CAAC"}
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "6.4.0",
2
+ "version": "6.4.2",
3
3
  "name": "@memori.ai/memori-react",
4
4
  "author": "Memori Srl",
5
5
  "main": "dist/index.js",
@@ -291,7 +291,7 @@
291
291
  },
292
292
  "dependencies": {
293
293
  "@headlessui/react": "1.7.4",
294
- "@memori.ai/memori-api-client": "^4.1.2",
294
+ "@memori.ai/memori-api-client": "^4.1.3",
295
295
  "@react-three/drei": "8.20.2",
296
296
  "@react-three/fiber": "7.0.25",
297
297
  "classnames": "2.3.2",
@@ -695,6 +695,8 @@ const MemoriWidget = ({
695
695
  placeLatitude: currentState.currentLatitude,
696
696
  placeLongitude: currentState.currentLongitude,
697
697
  placeUncertaintyKm: currentState.currentUncertaintyKm,
698
+ tag: currentState.currentTag,
699
+ // memoryTags: currentState.memoryTags,
698
700
  });
699
701
  speak(emission);
700
702
  }
@@ -731,6 +733,8 @@ const MemoriWidget = ({
731
733
  placeLatitude: currentState.currentLatitude,
732
734
  placeLongitude: currentState.currentLongitude,
733
735
  placeUncertaintyKm: currentState.currentUncertaintyKm,
736
+ tag: currentState.currentTag,
737
+ // memoryTags: currentState.memoryTags,
734
738
  });
735
739
  speak(emission);
736
740
  }
@@ -775,6 +779,8 @@ const MemoriWidget = ({
775
779
  placeLatitude: currentState.currentLatitude,
776
780
  placeLongitude: currentState.currentLongitude,
777
781
  placeUncertaintyKm: currentState.currentUncertaintyKm,
782
+ tag: currentState.currentTag,
783
+ // memoryTags: currentState.memoryTags,
778
784
  });
779
785
  speak(emission);
780
786
  }
@@ -845,6 +851,8 @@ const MemoriWidget = ({
845
851
  placeLatitude: state.currentLatitude,
846
852
  placeLongitude: state.currentLongitude,
847
853
  placeUncertaintyKm: state.currentUncertaintyKm,
854
+ tag: state.currentTag,
855
+ // memoryTags: currentState.memoryTags,
848
856
  };
849
857
  }
850
858
  } else {
@@ -893,6 +901,8 @@ const MemoriWidget = ({
893
901
  placeLatitude: state.currentLatitude,
894
902
  placeLongitude: state.currentLongitude,
895
903
  placeUncertaintyKm: state.currentUncertaintyKm,
904
+ tag: state.currentTag,
905
+ // memoryTags: currentState.memoryTags,
896
906
  };
897
907
  }
898
908
 
@@ -1131,6 +1141,8 @@ const MemoriWidget = ({
1131
1141
  placeLatitude: currentState.currentLatitude,
1132
1142
  placeLongitude: currentState.currentLongitude,
1133
1143
  placeUncertaintyKm: currentState.currentUncertaintyKm,
1144
+ tag: currentState.currentTag,
1145
+ // memoryTags: currentState.memoryTags,
1134
1146
  },
1135
1147
  ])
1136
1148
  : pushMessage({
@@ -1145,6 +1157,8 @@ const MemoriWidget = ({
1145
1157
  placeLatitude: currentState.currentLatitude,
1146
1158
  placeLongitude: currentState.currentLongitude,
1147
1159
  placeUncertaintyKm: currentState.currentUncertaintyKm,
1160
+ tag: currentState.currentTag,
1161
+ // memoryTags: currentState.memoryTags,
1148
1162
  });
1149
1163
  }
1150
1164
  }
@@ -1430,6 +1444,8 @@ const MemoriWidget = ({
1430
1444
  placeLatitude: currentState.currentLatitude,
1431
1445
  placeLongitude: currentState.currentLongitude,
1432
1446
  placeUncertaintyKm: currentState.currentUncertaintyKm,
1447
+ tag: currentState.currentTag,
1448
+ // memoryTags: currentState.memoryTags,
1433
1449
  });
1434
1450
  speak(emission);
1435
1451
  setCurrentDialogState({
@@ -2326,6 +2342,8 @@ const MemoriWidget = ({
2326
2342
  placeLatitude: currentState.currentLatitude,
2327
2343
  placeLongitude: currentState.currentLongitude,
2328
2344
  placeUncertaintyKm: currentState.currentUncertaintyKm,
2345
+ tag: currentState.currentTag,
2346
+ // memoryTags: currentState.memoryTags,
2329
2347
  });
2330
2348
  }
2331
2349
  } else {
@@ -2346,6 +2364,8 @@ const MemoriWidget = ({
2346
2364
  placeLatitude: currentState.currentLatitude,
2347
2365
  placeLongitude: currentState.currentLongitude,
2348
2366
  placeUncertaintyKm: currentState.currentUncertaintyKm,
2367
+ tag: currentState.currentTag,
2368
+ // memoryTags: currentState.memoryTags,
2349
2369
  });
2350
2370
  }
2351
2371
  }
@@ -64,10 +64,65 @@ ul.memori--whythisanswer-list li:last-child {
64
64
  margin: 0;
65
65
  }
66
66
 
67
- .memori-whythisanswer-drawer .memori-media-items--grid {
67
+ .memori-whythisanswer-drawer .memori-snippet--content {
68
+ font-size: 0.75rem;
69
+ }
70
+
71
+ .memori-whythisanswer-drawer .memori-card--content {
72
+ padding: 1rem;
73
+ }
74
+
75
+ .memori-whythisanswer-drawer .memori-card--cover {
68
76
  display: none;
69
77
  }
70
78
 
71
- .memori-whythisanswer-drawer .memori-snippet--content {
72
- font-size: 0.75rem;
79
+ .memori-whythisanswer-drawer .memori-card--title {
80
+ margin-bottom: 0;
81
+ font-size: 1rem;
82
+ }
83
+
84
+ .memori--whythisanswer-snippet-expandable {
85
+ min-height: 54px;
86
+ line-height: 40px;
87
+ }
88
+
89
+ .memori-whythisanswer-drawer .memori-card--description {
90
+ display: none;
91
+ }
92
+
93
+ .memori--whythisanswer-skeleton {
94
+ min-height: 12rem;
95
+ }
96
+
97
+ .memori--whythisanswer-skeleton-text {
98
+ padding: 0.5rem;
99
+ border-radius: var(--memori-border-radius);
100
+ margin-bottom: 0.5rem;
101
+ background: #ccc;
102
+ }
103
+
104
+ span.memori--whythisanswer-skeleton-text {
105
+ display: inline;
106
+ width: 3rem;
107
+ padding: 0 1rem;
108
+ }
109
+
110
+ p.memori--whythisanswer-skeleton-text {
111
+ display: block;
112
+ width: 100%;
113
+ min-width: 6rem;
114
+ margin-bottom: 0.5rem;
115
+ }
116
+
117
+ div.memori--whythisanswer-skeleton-text {
118
+ display: block;
119
+ width: 75%;
120
+ }
121
+
122
+ .memori--whythisanswer-skeleton-block {
123
+ height: 3rem;
124
+ padding: 0.5rem;
125
+ border-radius: var(--memori-border-radius);
126
+ margin-bottom: 0.5rem;
127
+ background: #ccc;
73
128
  }
@@ -54,6 +54,12 @@ Default.args = {
54
54
  visible: true,
55
55
  };
56
56
 
57
+ export const Loading = Template.bind({});
58
+ Loading.args = {
59
+ visible: true,
60
+ _TEST_loading: true,
61
+ };
62
+
57
63
  export const WithData = Template.bind({});
58
64
  WithData.args = {
59
65
  visible: true,
@@ -62,7 +68,7 @@ WithData.args = {
62
68
  confidence: 0.8,
63
69
  confidenceLevel: 'HIGH',
64
70
  memory: {
65
- ...memoryQuestion,
71
+ memoryID: '1',
66
72
  title: 'This is the title of the content',
67
73
  titleVariants: [
68
74
  "This is a variant of the content's title",
@@ -72,24 +78,22 @@ WithData.args = {
72
78
  {
73
79
  text: 'This is a test answer',
74
80
  },
81
+ {
82
+ text: 'This is another answer',
83
+ },
75
84
  ],
76
- memoryID: '1',
77
85
  },
78
86
  } as SearchMatches,
79
87
  {
80
- confidence: 0.7,
81
- confidenceLevel: 'MEDIUM',
88
+ confidence: 0.5,
89
+ confidenceLevel: 'LOW',
82
90
  memory: {
83
- ...memoryQuestion,
84
91
  memoryID: '2',
85
- title: 'This is a test title',
92
+ title: 'Content with a long answer',
86
93
  titleVariants: undefined,
87
94
  answers: [
88
95
  {
89
- text: 'This is a an answer',
90
- },
91
- {
92
- text: 'This is another answer',
96
+ text: 'Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi.',
93
97
  },
94
98
  ],
95
99
  },
@@ -98,36 +102,55 @@ WithData.args = {
98
102
  confidence: 0.5,
99
103
  confidenceLevel: 'LOW',
100
104
  memory: {
101
- ...memoryQuestion,
102
105
  memoryID: '3',
103
- title: 'Content with a long answer',
106
+ title: 'Content with sources',
104
107
  titleVariants: undefined,
105
108
  answers: [
106
109
  {
107
- text: 'Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi.',
110
+ text: 'This is a test answer',
111
+ },
112
+ ],
113
+ media: [
114
+ {
115
+ mediumID: '1',
116
+ mimeType: 'text/plain',
117
+ content:
118
+ 'This is a source. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi.',
119
+ },
120
+ {
121
+ mediumID: '2',
122
+ mimeType: 'text/plain',
123
+ content:
124
+ 'This is a source.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit.\nCras lobortis volutpat nunc.\nProin tincidunt enim in felis aliquet, a ultricies purus bibendum.\n\nQuisque in ultrices lectus.\nNulla at urna diam.\n\nProin sodales lobortis libero eu facilisis.',
108
125
  },
109
126
  ],
110
127
  },
111
128
  } as SearchMatches,
112
129
  {
113
- confidence: 0.5,
114
- confidenceLevel: 'LOW',
130
+ confidence: 0.7,
131
+ confidenceLevel: 'MEDIUM',
115
132
  memory: {
116
133
  ...memoryQuestion,
117
134
  memoryID: '4',
118
- title: 'Content with a source',
135
+ title: 'Content with links',
119
136
  titleVariants: undefined,
120
137
  answers: [
121
138
  {
122
- text: 'This is a test answer',
139
+ text: 'This is a an answer',
123
140
  },
124
141
  ],
125
142
  media: [
126
143
  {
127
144
  mediumID: '1',
128
- mimeType: 'text/plain',
129
- content:
130
- 'This is a source. Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
145
+ mimeType: 'text/html',
146
+ url: 'https://memori.ai',
147
+ title: 'Memori.AI',
148
+ },
149
+ {
150
+ mediumID: '2',
151
+ mimeType: 'text/html',
152
+ url: 'https://nzambello.dev',
153
+ title: 'Nicola Zambello',
131
154
  },
132
155
  ],
133
156
  },
@@ -11,6 +11,7 @@ import toast from 'react-hot-toast';
11
11
  import { getErrori18nKey } from '../../helpers/error';
12
12
  import { useTranslation } from 'react-i18next';
13
13
  import Snippet from '../Snippet/Snippet';
14
+ import MediaWidget from '../MediaWidget/MediaWidget';
14
15
 
15
16
  export interface Props {
16
17
  apiURL: string;
@@ -19,6 +20,7 @@ export interface Props {
19
20
  initialMatches?: SearchMatches[];
20
21
  visible?: boolean;
21
22
  closeDrawer: () => void;
23
+ _TEST_loading?: boolean;
22
24
  }
23
25
 
24
26
  const addQuestionMark = (question: string) =>
@@ -31,6 +33,7 @@ const WhyThisAnswer = ({
31
33
  visible = true,
32
34
  initialMatches = [],
33
35
  closeDrawer,
36
+ _TEST_loading = false,
34
37
  }: Props) => {
35
38
  const { t } = useTranslation();
36
39
 
@@ -38,7 +41,7 @@ const WhyThisAnswer = ({
38
41
  const searchMemory = client.search.searchMemory;
39
42
 
40
43
  const [matches, setMatches] = useState<SearchMatches[]>(initialMatches);
41
- const [loading, setLoading] = useState(false);
44
+ const [loading, setLoading] = useState(_TEST_loading);
42
45
 
43
46
  /**
44
47
  * Fetch matching memories
@@ -46,10 +49,12 @@ const WhyThisAnswer = ({
46
49
  const fetchMemories = useCallback(async () => {
47
50
  setLoading(true);
48
51
 
52
+ if (_TEST_loading) return;
53
+
49
54
  try {
50
55
  const { matches, ...response } = await searchMemory(sessionID, {
51
56
  searchType: 'Semantic',
52
- numberOfResults: 5,
57
+ numberOfResults: 3,
53
58
  text: message.questionAnswered,
54
59
  date: message.date,
55
60
  placeName: message.placeName,
@@ -57,6 +62,8 @@ const WhyThisAnswer = ({
57
62
  placeLongitude: message.placeLongitude,
58
63
  placeUncertaintyKm: message.placeUncertaintyKm,
59
64
  contextVars: message.contextVars,
65
+ tag: message.tag,
66
+ // memoryTags: message.memoryTags,
60
67
  });
61
68
 
62
69
  if (response.resultCode !== 0) {
@@ -94,12 +101,48 @@ const WhyThisAnswer = ({
94
101
  </p>
95
102
  )}
96
103
 
97
- <Spin spinning={loading}>
104
+ <Spin primary spinning={loading}>
98
105
  {!loading && matches.length === 0 && (
99
106
  <p role="info" className="memori--whythisanswer-no-results">
100
107
  {t('nothingFound')}
101
108
  </p>
102
109
  )}
110
+ {loading && matches.length === 0 && (
111
+ <ul className="memori--whythisanswer-list memori--whythisanswer-skeleton">
112
+ <li>
113
+ <div className="memori--whythisanswer-title">
114
+ <span className="memori--whythisanswer-confidence">
115
+ <span className="memori--whythisanswer-skeleton-text"></span>
116
+ </span>
117
+ <div className="memori--whythisanswer-title-text">
118
+ <p className="memori--whythisanswer-skeleton-text"></p>
119
+ </div>
120
+ </div>
121
+ <p>
122
+ <div className="memori--whythisanswer-skeleton-text"></div>
123
+ <div className="memori--whythisanswer-skeleton-text"></div>
124
+ <div className="memori--whythisanswer-skeleton-text"></div>
125
+ </p>
126
+ <div className="memori--whythisanswer-skeleton-block"></div>
127
+ </li>
128
+ <li>
129
+ <div className="memori--whythisanswer-title">
130
+ <span className="memori--whythisanswer-confidence">
131
+ <span className="memori--whythisanswer-skeleton-text"></span>
132
+ </span>
133
+ <div className="memori--whythisanswer-title-text">
134
+ <p className="memori--whythisanswer-skeleton-text"></p>
135
+ <p className="memori--whythisanswer-skeleton-text"></p>
136
+ </div>
137
+ </div>
138
+ <p>
139
+ <div className="memori--whythisanswer-skeleton-text"></div>
140
+ <div className="memori--whythisanswer-skeleton-text"></div>
141
+ </p>
142
+ <div className="memori--whythisanswer-skeleton-block"></div>
143
+ </li>
144
+ </ul>
145
+ )}
103
146
  {matches.length > 0 && (
104
147
  <ul className="memori--whythisanswer-list">
105
148
  {matches.map(m => (
@@ -125,20 +168,29 @@ const WhyThisAnswer = ({
125
168
  </p>
126
169
  ))}
127
170
 
128
- {!!m.memory.media?.filter(m => m.mimeType === 'text/plain')
129
- ?.length && (
130
- <Snippet
131
- medium={{
132
- mediumID: m.memory.memoryID,
133
- mimeType: 'text/plain',
134
- content: m.memory.media.filter(
135
- m => m.mimeType === 'text/plain'
136
- )[0].content,
137
- }}
138
- showCopyButton={false}
139
- showLineNumbers={false}
140
- />
141
- )}
171
+ <MediaWidget
172
+ links={m.memory.media?.filter(
173
+ m => m.mimeType === 'text/html'
174
+ )}
175
+ />
176
+
177
+ {m.memory.media
178
+ ?.filter(m => m.mimeType === 'text/plain')
179
+ ?.map(m => (
180
+ <Expandable
181
+ rows={2}
182
+ key={m.mediumID}
183
+ lineHeightMultiplier={2}
184
+ innerClassName="memori--whythisanswer-snippet-expandable"
185
+ >
186
+ <Snippet
187
+ key={m.mediumID}
188
+ medium={m}
189
+ showCopyButton={false}
190
+ showLineNumbers={false}
191
+ />
192
+ </Expandable>
193
+ ))}
142
194
  </li>
143
195
  ))}
144
196
  </ul>
@@ -8,6 +8,7 @@ export interface Props {
8
8
  className?: string;
9
9
  innerClassName?: string;
10
10
  btnClassName?: string;
11
+ lineHeightMultiplier?: number;
11
12
  defaultExpanded?: boolean;
12
13
  expandSymbol?: (lang: string) => React.ReactNode;
13
14
  collapseSymbol?: (lang: string) => React.ReactNode;
@@ -19,6 +20,7 @@ const Expandable = ({
19
20
  className,
20
21
  innerClassName,
21
22
  btnClassName,
23
+ lineHeightMultiplier = 1.2,
22
24
  defaultExpanded = false,
23
25
  expandSymbol = () => '...',
24
26
  collapseSymbol = (lang: string) =>
@@ -41,7 +43,7 @@ const Expandable = ({
41
43
  let elLineHeight = computedStyle.lineHeight;
42
44
  let lineHeight =
43
45
  elLineHeight === 'normal' || !elLineHeight?.length
44
- ? 1.2 * parseInt(computedStyle.fontSize, 10)
46
+ ? lineHeightMultiplier * parseInt(computedStyle.fontSize, 10)
45
47
  : parseInt(elLineHeight, 10);
46
48
 
47
49
  console.table({