cozy-viewer 26.6.2 → 26.6.4
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 +13 -0
- package/dist/Panel/AI/AIAssistantPanel.js +18 -10
- package/dist/Panel/AI/prompts.d.ts +3 -1
- package/dist/Panel/AI/prompts.js +7 -3
- package/dist/Panel/PanelContent.js +2 -1
- package/dist/Panel/Summary.js +8 -9
- package/dist/Panel/getPanelBlocks.d.ts +1 -1
- package/dist/Panel/getPanelBlocks.js +17 -6
- package/dist/ViewerContainer.js +2 -1
- package/dist/ViewerInformationsWrapper.d.ts +2 -1
- package/dist/ViewerInformationsWrapper.js +12 -4
- package/dist/actions/index.d.ts +2 -2
- package/dist/actions/index.js +6 -6
- package/dist/actions/{expand.d.ts → makeSummaryLonger.d.ts} +4 -5
- package/dist/actions/{expand.js → makeSummaryLonger.js} +20 -11
- package/dist/actions/{shorter.d.ts → makeSummaryShorter.d.ts} +4 -5
- package/dist/actions/{shorter.js → makeSummaryShorter.js} +20 -11
- package/dist/locales/index.js +4 -0
- package/package.json +5 -5
- package/src/Panel/AI/AIAssistantPanel.jsx +16 -4
- package/src/Panel/AI/prompts.js +36 -0
- package/src/Panel/PanelContent.jsx +2 -1
- package/src/Panel/Summary.jsx +9 -7
- package/src/Panel/getPanelBlocks.jsx +11 -4
- package/src/ViewerContainer.jsx +1 -0
- package/src/ViewerInformationsWrapper.jsx +11 -4
- package/src/actions/index.js +2 -2
- package/src/actions/{expand.js → makeSummaryLonger.js} +13 -5
- package/src/actions/{shorter.js → makeSummaryShorter.js} +13 -5
- package/src/locales/en.json +1 -0
- package/src/locales/fr.json +1 -0
- package/src/locales/ru.json +1 -0
- package/src/locales/vi.json +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [26.6.4](https://github.com/cozy/cozy-libs/compare/cozy-viewer@26.6.3...cozy-viewer@26.6.4) (2026-02-02)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- Add missing translation key :bug: ([48751e2](https://github.com/cozy/cozy-libs/commit/48751e255b5939c94ddf288722a2a4cb89a20265))
|
|
11
|
+
- Adjust actions change summarization content :bug: ([23c041a](https://github.com/cozy/cozy-libs/commit/23c041a39ed37219a548f1c1bb3da055489918e2))
|
|
12
|
+
- Hide antivirus block if display condition is false :bug: ([3bf6d1b](https://github.com/cozy/cozy-libs/commit/3bf6d1bc174f1b604825672bedffe537f8abfae5))
|
|
13
|
+
- Toogle details panel by using action :bug: ([6c5d7ee](https://github.com/cozy/cozy-libs/commit/6c5d7ee63f70e96172fd2264e202655b32a14c2f))
|
|
14
|
+
|
|
15
|
+
## [26.6.3](https://github.com/cozy/cozy-libs/compare/cozy-viewer@26.6.2...cozy-viewer@26.6.3) (2026-02-02)
|
|
16
|
+
|
|
17
|
+
**Note:** Version bump only for package cozy-viewer
|
|
18
|
+
|
|
6
19
|
## [26.6.2](https://github.com/cozy/cozy-libs/compare/cozy-viewer@26.6.1...cozy-viewer@26.6.2) (2026-01-29)
|
|
7
20
|
|
|
8
21
|
**Note:** Version bump only for package cozy-viewer
|
|
@@ -119,13 +119,13 @@ var AIAssistantPanel = function AIAssistantPanel(_ref) {
|
|
|
119
119
|
setIsOpenAiAssistant(false);
|
|
120
120
|
|
|
121
121
|
if (location !== null && location !== void 0 && (_location$state = location.state) !== null && _location$state !== void 0 && _location$state.showAIAssistant) {
|
|
122
|
-
navigate(
|
|
122
|
+
navigate(location.pathname);
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
var summarizeFile = /*#__PURE__*/function () {
|
|
127
127
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref2) {
|
|
128
|
-
var client, file, _ref2$stream, stream, model, fileBlob, rawTextContent, textContent, summaryConfig, _error, messages, summaryResponse;
|
|
128
|
+
var client, file, _ref2$stream, stream, model, _location$state2, _location$state3, fileBlob, rawTextContent, textContent, summaryConfig, _error, systemPrompt, messages, summaryResponse;
|
|
129
129
|
|
|
130
130
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
131
131
|
while (1) {
|
|
@@ -159,37 +159,45 @@ var AIAssistantPanel = function AIAssistantPanel(_ref) {
|
|
|
159
159
|
throw _error;
|
|
160
160
|
|
|
161
161
|
case 14:
|
|
162
|
+
systemPrompt = _prompts.SUMMARY_SYSTEM_PROMPT;
|
|
163
|
+
|
|
164
|
+
if (((_location$state2 = location.state) === null || _location$state2 === void 0 ? void 0 : _location$state2.type) === 'makeSummaryLonger') {
|
|
165
|
+
systemPrompt = _prompts.LONG_SUMMARY_SYSTEM_PROMPT;
|
|
166
|
+
} else if (((_location$state3 = location.state) === null || _location$state3 === void 0 ? void 0 : _location$state3.type) === 'makeSummaryShorter') {
|
|
167
|
+
systemPrompt = _prompts.SHORT_SUMMARY_SYSTEM_PROMPT;
|
|
168
|
+
}
|
|
169
|
+
|
|
162
170
|
messages = [{
|
|
163
171
|
role: 'system',
|
|
164
|
-
content:
|
|
172
|
+
content: systemPrompt
|
|
165
173
|
}, {
|
|
166
174
|
role: 'user',
|
|
167
175
|
content: (0, _prompts.getSummaryUserPrompt)(textContent)
|
|
168
176
|
}];
|
|
169
|
-
_context.next =
|
|
177
|
+
_context.next = 19;
|
|
170
178
|
return (0, _ai.chatCompletion)(client, messages, {
|
|
171
179
|
stream: stream,
|
|
172
180
|
model: model
|
|
173
181
|
});
|
|
174
182
|
|
|
175
|
-
case
|
|
183
|
+
case 19:
|
|
176
184
|
summaryResponse = _context.sent;
|
|
177
185
|
return _context.abrupt("return", summaryResponse);
|
|
178
186
|
|
|
179
|
-
case
|
|
180
|
-
_context.prev =
|
|
187
|
+
case 23:
|
|
188
|
+
_context.prev = 23;
|
|
181
189
|
_context.t0 = _context["catch"](1);
|
|
182
190
|
|
|
183
191
|
_cozyLogger.default.error('Error when summarizing file:', _context.t0);
|
|
184
192
|
|
|
185
193
|
throw _context.t0;
|
|
186
194
|
|
|
187
|
-
case
|
|
195
|
+
case 27:
|
|
188
196
|
case "end":
|
|
189
197
|
return _context.stop();
|
|
190
198
|
}
|
|
191
199
|
}
|
|
192
|
-
}, _callee, null, [[1,
|
|
200
|
+
}, _callee, null, [[1, 23]]);
|
|
193
201
|
}));
|
|
194
202
|
|
|
195
203
|
return function summarizeFile(_x) {
|
|
@@ -331,7 +339,7 @@ var AIAssistantPanel = function AIAssistantPanel(_ref) {
|
|
|
331
339
|
}
|
|
332
340
|
}
|
|
333
341
|
}, _callee3, null, [[9, 22, 25, 29]]);
|
|
334
|
-
})), [client, file, t]);
|
|
342
|
+
})), [client, file, t, location]);
|
|
335
343
|
|
|
336
344
|
var handleRefresh = function handleRefresh() {
|
|
337
345
|
fetchedFileIdRef.current = null;
|
|
@@ -2,5 +2,7 @@
|
|
|
2
2
|
* AI prompts for document summarization
|
|
3
3
|
* These will be externalized in the future
|
|
4
4
|
*/
|
|
5
|
-
export const SUMMARY_SYSTEM_PROMPT: "You are a concise and reliable text summarizer.\n\nYour goal:\n- Produce a clear and accurate summary of the provided content\n- Keep the original meaning and key information only\n- Remove redundancy, examples, anecdotes, and minor details\n\nWriting rules:\n- Keep the same language as the provided input. For example, if it's french, keep french\n- Be concise and use simple phrasing\n- Do not add new information\n- Do not guess what is not explicitly stated\n\nOutput:\n- A single coherent paragraph unless otherwise specified\n- Do not add any extra information or interpret anything beyond the explicit task";
|
|
5
|
+
export const SUMMARY_SYSTEM_PROMPT: "You are a concise and reliable text summarizer.\n\nYour goal:\n- Produce a clear and accurate summary of the provided content\n- Keep the original meaning and key information only\n- Remove redundancy, examples, anecdotes, and minor details\n\nWriting rules:\n- Keep the same language as the provided input. For example, if it's french, keep french\n- Be concise and use simple phrasing\n- Do not add new information\n- Do not guess what is not explicitly stated\n\n\nOutput:\n- A single coherent paragraph unless otherwise specified\n- Do not add any extra information or interpret anything beyond the explicit task";
|
|
6
|
+
export const LONG_SUMMARY_SYSTEM_PROMPT: "You are a comprehensive and detailed text summarizer.\n\nYour goal:\n- Produce a detailed and extensive summary of the provided content\n- Capture all key information, main points, and supporting details\n- Maintain the original meaning and context\n- Ensure the summary is significantly longer and more detailed than a standard summary\n\nWriting rules:\n- Keep the same language as the provided input. For example, if it's french, keep french\n- Use clear and professional phrasing\n- Organize the summary logically, using paragraphs if necessary\n- Do not add new information not present in the text\n- Do not guess what is not explicitly stated\n\nOutput:\n- A structured and detailed summary\n- Do not add any extra information or interpret anything beyond the explicit task";
|
|
7
|
+
export const SHORT_SUMMARY_SYSTEM_PROMPT: "You are an extremely concise text summarizer.\n\nYour goal:\n- Produce a very short summary (TL;DR) of the provided content\n- Limit the summary to 1-2 sentences maximum\n- Capture only the single most important point\n\nWriting rules:\n- Keep the same language as the provided input. For example, if it's french, keep french\n- Be direct and to the point\n- No fluff, no introductory phrases\n\nOutput:\n- A single short paragraph (1-2 sentences)\n- Do not add any extra information or interpret anything beyond the explicit task";
|
|
6
8
|
export function getSummaryUserPrompt(textContent: string): string;
|
package/dist/Panel/AI/prompts.js
CHANGED
|
@@ -3,20 +3,24 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getSummaryUserPrompt = exports.SUMMARY_SYSTEM_PROMPT = void 0;
|
|
6
|
+
exports.getSummaryUserPrompt = exports.SUMMARY_SYSTEM_PROMPT = exports.SHORT_SUMMARY_SYSTEM_PROMPT = exports.LONG_SUMMARY_SYSTEM_PROMPT = void 0;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* AI prompts for document summarization
|
|
10
10
|
* These will be externalized in the future
|
|
11
11
|
*/
|
|
12
|
-
var SUMMARY_SYSTEM_PROMPT = "You are a concise and reliable text summarizer.\n\nYour goal:\n- Produce a clear and accurate summary of the provided content\n- Keep the original meaning and key information only\n- Remove redundancy, examples, anecdotes, and minor details\n\nWriting rules:\n- Keep the same language as the provided input. For example, if it's french, keep french\n- Be concise and use simple phrasing\n- Do not add new information\n- Do not guess what is not explicitly stated\n\nOutput:\n- A single coherent paragraph unless otherwise specified\n- Do not add any extra information or interpret anything beyond the explicit task";
|
|
12
|
+
var SUMMARY_SYSTEM_PROMPT = "You are a concise and reliable text summarizer.\n\nYour goal:\n- Produce a clear and accurate summary of the provided content\n- Keep the original meaning and key information only\n- Remove redundancy, examples, anecdotes, and minor details\n\nWriting rules:\n- Keep the same language as the provided input. For example, if it's french, keep french\n- Be concise and use simple phrasing\n- Do not add new information\n- Do not guess what is not explicitly stated\n\n\nOutput:\n- A single coherent paragraph unless otherwise specified\n- Do not add any extra information or interpret anything beyond the explicit task";
|
|
13
|
+
exports.SUMMARY_SYSTEM_PROMPT = SUMMARY_SYSTEM_PROMPT;
|
|
14
|
+
var LONG_SUMMARY_SYSTEM_PROMPT = "You are a comprehensive and detailed text summarizer.\n\nYour goal:\n- Produce a detailed and extensive summary of the provided content\n- Capture all key information, main points, and supporting details\n- Maintain the original meaning and context\n- Ensure the summary is significantly longer and more detailed than a standard summary\n\nWriting rules:\n- Keep the same language as the provided input. For example, if it's french, keep french\n- Use clear and professional phrasing\n- Organize the summary logically, using paragraphs if necessary\n- Do not add new information not present in the text\n- Do not guess what is not explicitly stated\n\nOutput:\n- A structured and detailed summary\n- Do not add any extra information or interpret anything beyond the explicit task";
|
|
15
|
+
exports.LONG_SUMMARY_SYSTEM_PROMPT = LONG_SUMMARY_SYSTEM_PROMPT;
|
|
16
|
+
var SHORT_SUMMARY_SYSTEM_PROMPT = "You are an extremely concise text summarizer.\n\nYour goal:\n- Produce a very short summary (TL;DR) of the provided content\n- Limit the summary to 1-2 sentences maximum\n- Capture only the single most important point\n\nWriting rules:\n- Keep the same language as the provided input. For example, if it's french, keep french\n- Be direct and to the point\n- No fluff, no introductory phrases\n\nOutput:\n- A single short paragraph (1-2 sentences)\n- Do not add any extra information or interpret anything beyond the explicit task";
|
|
13
17
|
/**
|
|
14
18
|
* Generate user prompt for document summarization
|
|
15
19
|
* @param {string} textContent - The text content to summarize
|
|
16
20
|
* @returns {string} The formatted user prompt
|
|
17
21
|
*/
|
|
18
22
|
|
|
19
|
-
exports.
|
|
23
|
+
exports.SHORT_SUMMARY_SYSTEM_PROMPT = SHORT_SUMMARY_SYSTEM_PROMPT;
|
|
20
24
|
|
|
21
25
|
var getSummaryUserPrompt = function getSummaryUserPrompt(textContent) {
|
|
22
26
|
return "Summarize the following content:\n\n".concat(textContent);
|
|
@@ -53,7 +53,8 @@ var PanelContent = function PanelContent() {
|
|
|
53
53
|
var navigate = (0, _reactRouterDom.useNavigate)();
|
|
54
54
|
var panelBlocks = (0, _getPanelBlocks.default)({
|
|
55
55
|
panelBlocksSpecs: (0, _getPanelBlocks.getPanelBlocksSpecs)(isPublic, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.panel),
|
|
56
|
-
file: file
|
|
56
|
+
file: file,
|
|
57
|
+
t: t
|
|
57
58
|
});
|
|
58
59
|
|
|
59
60
|
var closePanel = function closePanel() {
|
package/dist/Panel/Summary.js
CHANGED
|
@@ -19,6 +19,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
19
19
|
|
|
20
20
|
var _react = _interopRequireWildcard(require("react"));
|
|
21
21
|
|
|
22
|
+
var _reactRouterDom = require("react-router-dom");
|
|
23
|
+
|
|
22
24
|
var _cozyFlags = _interopRequireDefault(require("cozy-flags"));
|
|
23
25
|
|
|
24
26
|
var _Accordion = _interopRequireDefault(require("cozy-ui/transpiled/react/Accordion"));
|
|
@@ -105,19 +107,16 @@ var Summary = function Summary(_ref) {
|
|
|
105
107
|
var _useAlert = (0, _Alert.useAlert)(),
|
|
106
108
|
showAlert = _useAlert.showAlert;
|
|
107
109
|
|
|
110
|
+
var location = (0, _reactRouterDom.useLocation)();
|
|
111
|
+
var navigate = (0, _reactRouterDom.useNavigate)();
|
|
108
112
|
var label = t('Viewer.panel.summary');
|
|
109
113
|
var value = (_file$metadata = file.metadata) === null || _file$metadata === void 0 ? void 0 : _file$metadata.description;
|
|
110
|
-
var actions = (0, _Actions.makeActions)([_Actions.copyToClipboard, !isReadOnly && _Actions.editAttribute, (0, _cozyFlags.default)('drive.new-file-viewer-ui.enabled') && _Actions.divider, (0, _cozyFlags.default)('drive.new-file-viewer-ui.enabled') && _Actions.exportToText, (0, _cozyFlags.default)('drive.new-file-viewer-ui.enabled') && _Actions.divider, (0, _cozyFlags.default)('drive.new-file-viewer-ui.enabled') && _actions.
|
|
114
|
+
var actions = (0, _Actions.makeActions)([_Actions.copyToClipboard, !isReadOnly && _Actions.editAttribute, (0, _cozyFlags.default)('drive.new-file-viewer-ui.enabled') && _Actions.divider, (0, _cozyFlags.default)('drive.new-file-viewer-ui.enabled') && _Actions.exportToText, (0, _cozyFlags.default)('drive.new-file-viewer-ui.enabled') && _Actions.divider, (0, _cozyFlags.default)('drive.new-file-viewer-ui.enabled') && _actions.makeSummaryShorter, (0, _cozyFlags.default)('drive.new-file-viewer-ui.enabled') && _actions.makeSummaryLonger], {
|
|
111
115
|
t: t,
|
|
112
116
|
exportedText: value,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
makeLonger: function makeLonger() {
|
|
117
|
-
return setIsExpanded(true);
|
|
118
|
-
},
|
|
119
|
-
isExpanded: isExpanded,
|
|
120
|
-
file: file
|
|
117
|
+
file: file,
|
|
118
|
+
location: location,
|
|
119
|
+
navigate: navigate
|
|
121
120
|
});
|
|
122
121
|
|
|
123
122
|
var handleClick = /*#__PURE__*/function () {
|
|
@@ -20,7 +20,7 @@ export type PanelBlocksSpecs = {
|
|
|
20
20
|
* @param {import('cozy-client/types/types').FileDocument} options.file - File object
|
|
21
21
|
* @returns {Array.<React.Component>}
|
|
22
22
|
*/
|
|
23
|
-
declare function getPanelBlocks({ panelBlocksSpecs, file }: {
|
|
23
|
+
declare function getPanelBlocks({ panelBlocksSpecs, file, t }: {
|
|
24
24
|
panelBlocksSpecs: PanelBlocksSpecs;
|
|
25
25
|
file: import("cozy-client/types/types").FileDocument;
|
|
26
26
|
}): Array<React.Component>;
|
|
@@ -23,6 +23,8 @@ var _Sharing = _interopRequireDefault(require("./Sharing"));
|
|
|
23
23
|
|
|
24
24
|
var _Summary = _interopRequireDefault(require("./Summary"));
|
|
25
25
|
|
|
26
|
+
var _helpers = require("./helpers");
|
|
27
|
+
|
|
26
28
|
/**
|
|
27
29
|
* @typedef {Object} PanelBlockSpec
|
|
28
30
|
* @property {Function} condition - Function that returns true if the block should be displayed
|
|
@@ -43,10 +45,14 @@ var getPanelBlocksSpecs = function getPanelBlocksSpecs() {
|
|
|
43
45
|
var panelProps = arguments.length > 1 ? arguments[1] : undefined;
|
|
44
46
|
return (0, _cozyFlags.default)('drive.new-file-viewer-ui.enabled') ? {
|
|
45
47
|
antivirus: {
|
|
46
|
-
condition: function condition() {
|
|
48
|
+
condition: function condition(file, t) {
|
|
47
49
|
var _panelProps$antivirus;
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
var _getAntivirusStatus = (0, _helpers.getAntivirusStatus)(file, t),
|
|
52
|
+
icon = _getAntivirusStatus.icon,
|
|
53
|
+
text = _getAntivirusStatus.text;
|
|
54
|
+
|
|
55
|
+
return !(panelProps !== null && panelProps !== void 0 && (_panelProps$antivirus = panelProps.antivirus) !== null && _panelProps$antivirus !== void 0 && _panelProps$antivirus.disabled) && icon && text;
|
|
50
56
|
},
|
|
51
57
|
component: _Antivirus.default
|
|
52
58
|
},
|
|
@@ -92,10 +98,14 @@ var getPanelBlocksSpecs = function getPanelBlocksSpecs() {
|
|
|
92
98
|
}
|
|
93
99
|
} : {
|
|
94
100
|
antivirus: {
|
|
95
|
-
condition: function condition() {
|
|
101
|
+
condition: function condition(file, t) {
|
|
96
102
|
var _panelProps$antivirus2;
|
|
97
103
|
|
|
98
|
-
|
|
104
|
+
var _getAntivirusStatus2 = (0, _helpers.getAntivirusStatus)(file, t),
|
|
105
|
+
icon = _getAntivirusStatus2.icon,
|
|
106
|
+
text = _getAntivirusStatus2.text;
|
|
107
|
+
|
|
108
|
+
return !(panelProps !== null && panelProps !== void 0 && (_panelProps$antivirus2 = panelProps.antivirus) !== null && _panelProps$antivirus2 !== void 0 && _panelProps$antivirus2.disabled) && icon && text;
|
|
99
109
|
},
|
|
100
110
|
component: _Antivirus.default
|
|
101
111
|
},
|
|
@@ -154,10 +164,11 @@ exports.getPanelBlocksSpecs = getPanelBlocksSpecs;
|
|
|
154
164
|
|
|
155
165
|
var getPanelBlocks = function getPanelBlocks(_ref) {
|
|
156
166
|
var panelBlocksSpecs = _ref.panelBlocksSpecs,
|
|
157
|
-
file = _ref.file
|
|
167
|
+
file = _ref.file,
|
|
168
|
+
t = _ref.t;
|
|
158
169
|
var panelBlocks = [];
|
|
159
170
|
Object.values(panelBlocksSpecs).forEach(function (panelBlock) {
|
|
160
|
-
panelBlock.condition(file) && panelBlocks.push(panelBlock.component);
|
|
171
|
+
panelBlock.condition(file, t) && panelBlocks.push(panelBlock.component);
|
|
161
172
|
});
|
|
162
173
|
return panelBlocks;
|
|
163
174
|
};
|
package/dist/ViewerContainer.js
CHANGED
|
@@ -186,7 +186,8 @@ var ViewerContainer = function ViewerContainer(props) {
|
|
|
186
186
|
}), children)), /*#__PURE__*/_react.default.createElement(_ViewerInformationsWrapper.default, {
|
|
187
187
|
disableFooter: disableFooter,
|
|
188
188
|
validForPanel: validForPanel,
|
|
189
|
-
toolbarRef: toolbarRef
|
|
189
|
+
toolbarRef: toolbarRef,
|
|
190
|
+
currentIndex: currentIndex
|
|
190
191
|
}, children))))));
|
|
191
192
|
};
|
|
192
193
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export default ViewerInformationsWrapper;
|
|
2
|
-
declare function ViewerInformationsWrapper({ disableFooter, validForPanel, toolbarRef, children }: {
|
|
2
|
+
declare function ViewerInformationsWrapper({ disableFooter, validForPanel, toolbarRef, children, currentIndex }: {
|
|
3
3
|
disableFooter: any;
|
|
4
4
|
validForPanel: any;
|
|
5
5
|
toolbarRef: any;
|
|
6
6
|
children: any;
|
|
7
|
+
currentIndex: any;
|
|
7
8
|
}): JSX.Element;
|
|
8
9
|
declare namespace ViewerInformationsWrapper {
|
|
9
10
|
namespace propTypes {
|
|
@@ -39,7 +39,8 @@ var ViewerInformationsWrapper = function ViewerInformationsWrapper(_ref) {
|
|
|
39
39
|
var disableFooter = _ref.disableFooter,
|
|
40
40
|
validForPanel = _ref.validForPanel,
|
|
41
41
|
toolbarRef = _ref.toolbarRef,
|
|
42
|
-
children = _ref.children
|
|
42
|
+
children = _ref.children,
|
|
43
|
+
currentIndex = _ref.currentIndex;
|
|
43
44
|
var theme = (0, _styles.useTheme)();
|
|
44
45
|
|
|
45
46
|
var _useCozyTheme = (0, _CozyTheme.useCozyTheme)(),
|
|
@@ -60,10 +61,17 @@ var ViewerInformationsWrapper = function ViewerInformationsWrapper(_ref) {
|
|
|
60
61
|
setIsOpenAiAssistant(true);
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
if (location
|
|
64
|
-
setIsOpenFileViewerPanel(
|
|
64
|
+
if ((location === null || location === void 0 ? void 0 : (_location$state2 = location.state) === null || _location$state2 === void 0 ? void 0 : _location$state2.triggerDetailPanelTime) !== undefined) {
|
|
65
|
+
setIsOpenFileViewerPanel(function (prev) {
|
|
66
|
+
return !prev;
|
|
67
|
+
});
|
|
65
68
|
}
|
|
66
69
|
}, [location, setIsOpenAiAssistant, setIsOpenFileViewerPanel]);
|
|
70
|
+
(0, _react.useEffect)(function () {
|
|
71
|
+
if (!isOpenAiAssistant) {
|
|
72
|
+
setIsOpenFileViewerPanel(true);
|
|
73
|
+
}
|
|
74
|
+
}, [isOpenAiAssistant, currentIndex, setIsOpenFileViewerPanel]);
|
|
67
75
|
(0, _useSetFlagshipUI.useSetFlagshipUI)({
|
|
68
76
|
bottomBackground: theme.palette.background.paper,
|
|
69
77
|
bottomTheme: isLight ? 'dark' : 'light'
|
|
@@ -73,7 +81,7 @@ var ViewerInformationsWrapper = function ViewerInformationsWrapper(_ref) {
|
|
|
73
81
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isOpenAiAssistant && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !disableFooter && /*#__PURE__*/_react.default.createElement(_Footer.default, null, /*#__PURE__*/_react.default.createElement(_FooterContent.default, {
|
|
74
82
|
toolbarRef: toolbarRef,
|
|
75
83
|
isDisplayChildrenDirectly: true
|
|
76
|
-
}, /*#__PURE__*/_react.default.createElement(_AIAssistantPanel.default, null))), validForPanel && /*#__PURE__*/_react.default.createElement(_InformationPanel.default, null, /*#__PURE__*/_react.default.createElement(_AIAssistantPanel.default, null))), isOpenFileViewerPanel && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !disableFooter && /*#__PURE__*/_react.default.createElement(_Footer.default, null, /*#__PURE__*/_react.default.createElement(_FooterContent.default, {
|
|
84
|
+
}, /*#__PURE__*/_react.default.createElement(_AIAssistantPanel.default, null))), validForPanel && /*#__PURE__*/_react.default.createElement(_InformationPanel.default, null, /*#__PURE__*/_react.default.createElement(_AIAssistantPanel.default, null))), isOpenFileViewerPanel && !isOpenAiAssistant && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !disableFooter && /*#__PURE__*/_react.default.createElement(_Footer.default, null, /*#__PURE__*/_react.default.createElement(_FooterContent.default, {
|
|
77
85
|
toolbarRef: toolbarRef
|
|
78
86
|
}, children)), validForPanel && /*#__PURE__*/_react.default.createElement(_InformationPanel.default, null, /*#__PURE__*/_react.default.createElement(_PanelContent.default, null))));
|
|
79
87
|
};
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { makeSummaryLonger } from "./makeSummaryLonger";
|
|
2
|
+
export { makeSummaryShorter } from "./makeSummaryShorter";
|
package/dist/actions/index.js
CHANGED
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "makeSummaryLonger", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function get() {
|
|
9
|
-
return
|
|
9
|
+
return _makeSummaryLonger.makeSummaryLonger;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "makeSummaryShorter", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function get() {
|
|
15
|
-
return
|
|
15
|
+
return _makeSummaryShorter.makeSummaryShorter;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _makeSummaryLonger = require("./makeSummaryLonger");
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _makeSummaryShorter = require("./makeSummaryShorter");
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function makeSummaryLonger({ t, navigate, location }: {
|
|
2
2
|
t: any;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
navigate: any;
|
|
4
|
+
location: any;
|
|
5
5
|
}): {
|
|
6
6
|
name: string;
|
|
7
7
|
icon: typeof ExpandIcon;
|
|
8
8
|
label: any;
|
|
9
9
|
Component: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
10
|
-
|
|
11
|
-
action: () => any;
|
|
10
|
+
action: () => void;
|
|
12
11
|
};
|
|
13
12
|
import ExpandIcon from 'cozy-ui/transpiled/react/Icons/Expand';
|
|
14
13
|
import React from 'react';
|
|
@@ -5,7 +5,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.makeSummaryLonger = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
11
|
|
|
10
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
13
|
|
|
@@ -25,6 +27,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
25
27
|
|
|
26
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
29
|
|
|
30
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
+
|
|
32
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
|
+
|
|
28
34
|
var makeComponent = function makeComponent(label, icon) {
|
|
29
35
|
var Component = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
30
36
|
return /*#__PURE__*/_react.default.createElement(_ActionsMenuItem.default, (0, _extends2.default)({}, props, {
|
|
@@ -35,28 +41,31 @@ var makeComponent = function makeComponent(label, icon) {
|
|
|
35
41
|
primary: label
|
|
36
42
|
}));
|
|
37
43
|
});
|
|
38
|
-
Component.displayName = '
|
|
44
|
+
Component.displayName = 'makeSummaryLonger';
|
|
39
45
|
return Component;
|
|
40
46
|
};
|
|
41
47
|
|
|
42
|
-
var
|
|
48
|
+
var makeSummaryLonger = function makeSummaryLonger(_ref) {
|
|
43
49
|
var t = _ref.t,
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
navigate = _ref.navigate,
|
|
51
|
+
location = _ref.location;
|
|
46
52
|
var icon = _Expand.default;
|
|
47
53
|
var label = t('Viewer.panel.expand');
|
|
48
54
|
return {
|
|
49
|
-
name: '
|
|
55
|
+
name: 'makeSummaryLonger',
|
|
50
56
|
icon: icon,
|
|
51
57
|
label: label,
|
|
52
58
|
Component: makeComponent(label, icon),
|
|
53
|
-
displayCondition: function displayCondition() {
|
|
54
|
-
return !isExpanded;
|
|
55
|
-
},
|
|
56
59
|
action: function action() {
|
|
57
|
-
|
|
60
|
+
navigate(location.pathname, {
|
|
61
|
+
replace: true,
|
|
62
|
+
state: _objectSpread(_objectSpread({}, location.state), {}, {
|
|
63
|
+
showAIAssistant: true,
|
|
64
|
+
type: 'makeSummaryLonger'
|
|
65
|
+
})
|
|
66
|
+
});
|
|
58
67
|
}
|
|
59
68
|
};
|
|
60
69
|
};
|
|
61
70
|
|
|
62
|
-
exports.
|
|
71
|
+
exports.makeSummaryLonger = makeSummaryLonger;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function makeSummaryShorter({ t, location, navigate }: {
|
|
2
2
|
t: any;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
location: any;
|
|
4
|
+
navigate: any;
|
|
5
5
|
}): {
|
|
6
6
|
name: string;
|
|
7
7
|
icon: typeof NarrowIcon;
|
|
8
8
|
label: any;
|
|
9
9
|
Component: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
10
|
-
|
|
11
|
-
action: () => any;
|
|
10
|
+
action: () => void;
|
|
12
11
|
};
|
|
13
12
|
import NarrowIcon from 'cozy-ui/transpiled/react/Icons/Narrow';
|
|
14
13
|
import React from 'react';
|
|
@@ -5,7 +5,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.makeSummaryShorter = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
11
|
|
|
10
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
13
|
|
|
@@ -25,6 +27,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
25
27
|
|
|
26
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
29
|
|
|
30
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
+
|
|
32
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
|
+
|
|
28
34
|
var makeComponent = function makeComponent(label, icon) {
|
|
29
35
|
var Component = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
30
36
|
return /*#__PURE__*/_react.default.createElement(_ActionsMenuItem.default, (0, _extends2.default)({}, props, {
|
|
@@ -35,28 +41,31 @@ var makeComponent = function makeComponent(label, icon) {
|
|
|
35
41
|
primary: label
|
|
36
42
|
}));
|
|
37
43
|
});
|
|
38
|
-
Component.displayName = '
|
|
44
|
+
Component.displayName = 'makeSummaryShorter';
|
|
39
45
|
return Component;
|
|
40
46
|
};
|
|
41
47
|
|
|
42
|
-
var
|
|
48
|
+
var makeSummaryShorter = function makeSummaryShorter(_ref) {
|
|
43
49
|
var t = _ref.t,
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
location = _ref.location,
|
|
51
|
+
navigate = _ref.navigate;
|
|
46
52
|
var icon = _Narrow.default;
|
|
47
53
|
var label = t('Viewer.panel.shorter');
|
|
48
54
|
return {
|
|
49
|
-
name: '
|
|
55
|
+
name: 'makeSummaryShorter',
|
|
50
56
|
icon: icon,
|
|
51
57
|
label: label,
|
|
52
58
|
Component: makeComponent(label, icon),
|
|
53
|
-
displayCondition: function displayCondition() {
|
|
54
|
-
return isExpanded;
|
|
55
|
-
},
|
|
56
59
|
action: function action() {
|
|
57
|
-
|
|
60
|
+
navigate(location.pathname, {
|
|
61
|
+
replace: true,
|
|
62
|
+
state: _objectSpread(_objectSpread({}, location.state), {}, {
|
|
63
|
+
showAIAssistant: true,
|
|
64
|
+
type: 'makeSummaryShorter'
|
|
65
|
+
})
|
|
66
|
+
});
|
|
58
67
|
}
|
|
59
68
|
};
|
|
60
69
|
};
|
|
61
70
|
|
|
62
|
-
exports.
|
|
71
|
+
exports.makeSummaryShorter = makeSummaryShorter;
|
package/dist/locales/index.js
CHANGED
|
@@ -36,6 +36,7 @@ var en = {
|
|
|
36
36
|
openWith: "Open with...",
|
|
37
37
|
openInOnlyOffice: "Open with Only Office",
|
|
38
38
|
panel: {
|
|
39
|
+
collapse: "Collapse",
|
|
39
40
|
header: "Details",
|
|
40
41
|
summary: "Summary",
|
|
41
42
|
edit_summary: "Edit summary",
|
|
@@ -151,6 +152,7 @@ var fr = {
|
|
|
151
152
|
openWith: "Ouvrir avec...",
|
|
152
153
|
openInOnlyOffice: "Ouvrir avec Only Office",
|
|
153
154
|
panel: {
|
|
155
|
+
collapse: "R\xE9duire",
|
|
154
156
|
header: "D\xE9tails",
|
|
155
157
|
summary: "R\xE9sum\xE9",
|
|
156
158
|
edit_summary: "Modifier le r\xE9sum\xE9",
|
|
@@ -266,6 +268,7 @@ var ru = {
|
|
|
266
268
|
openWith: "\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0441 \u043F\u043E\u043C\u043E\u0449\u044C\u044E...",
|
|
267
269
|
openInOnlyOffice: "\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432 Only Office",
|
|
268
270
|
panel: {
|
|
271
|
+
collapse: "\u0421\u0432\u0435\u0440\u043D\u0443\u0442\u044C",
|
|
269
272
|
header: "\u0421\u0432\u0435\u0434\u0435\u043D\u0438\u044F",
|
|
270
273
|
summary: "\u0421\u0432\u043E\u0434\u043A\u0430",
|
|
271
274
|
edit_summary: "\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C",
|
|
@@ -381,6 +384,7 @@ var vi = {
|
|
|
381
384
|
openWith: "M\u1EDF b\u1EB1ng...",
|
|
382
385
|
openInOnlyOffice: "M\u1EDF b\u1EB1ng Only Office",
|
|
383
386
|
panel: {
|
|
387
|
+
collapse: "Thu g\u1ECDn",
|
|
384
388
|
header: "Chi ti\u1EBFt",
|
|
385
389
|
summary: "T\xF3m t\u1EAFt",
|
|
386
390
|
edit_summary: "Ch\u1EC9nh s\u1EEDa t\xF3m t\u1EAFt",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-viewer",
|
|
3
|
-
"version": "26.6.
|
|
3
|
+
"version": "26.6.4",
|
|
4
4
|
"description": "Cozy-Viewer provides a component to show files in a viewer.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"babel-preset-cozy-app": "^2.8.3",
|
|
32
32
|
"cozy-client": "^60.20.0",
|
|
33
33
|
"cozy-device-helper": "2.0.0",
|
|
34
|
-
"cozy-harvest-lib": "^36.0.
|
|
34
|
+
"cozy-harvest-lib": "^36.0.26",
|
|
35
35
|
"cozy-intent": "^2.30.2",
|
|
36
36
|
"cozy-logger": "^1.17.0",
|
|
37
|
-
"cozy-sharing": "^28.3.
|
|
37
|
+
"cozy-sharing": "^28.3.2",
|
|
38
38
|
"cozy-ui": "^135.6.0",
|
|
39
|
-
"cozy-ui-plus": "^4.
|
|
39
|
+
"cozy-ui-plus": "^4.5.0",
|
|
40
40
|
"identity-obj-proxy": "3.0.0",
|
|
41
41
|
"jest": "26.6.3",
|
|
42
42
|
"jest-canvas-mock": "2.3.1",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react-router-dom": ">=6.14.2",
|
|
71
71
|
"twake-i18n": ">=0.3.0"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "4bb7a5eb222d52f816f2f970d7f0d32ee2d0c719"
|
|
74
74
|
}
|
|
@@ -21,7 +21,12 @@ import Stack from 'cozy-ui/transpiled/react/Stack'
|
|
|
21
21
|
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
22
22
|
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
SUMMARY_SYSTEM_PROMPT,
|
|
26
|
+
LONG_SUMMARY_SYSTEM_PROMPT,
|
|
27
|
+
SHORT_SUMMARY_SYSTEM_PROMPT,
|
|
28
|
+
getSummaryUserPrompt
|
|
29
|
+
} from './prompts'
|
|
25
30
|
import styles from './styles.styl'
|
|
26
31
|
import { roughTokensEstimation, sanitizeText } from '../../helpers'
|
|
27
32
|
import { useViewer } from '../../providers/ViewerProvider'
|
|
@@ -45,7 +50,7 @@ const AIAssistantPanel = ({ className }) => {
|
|
|
45
50
|
const handleClose = () => {
|
|
46
51
|
setIsOpenAiAssistant(false)
|
|
47
52
|
if (location?.state?.showAIAssistant) {
|
|
48
|
-
navigate(
|
|
53
|
+
navigate(location.pathname)
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
|
|
@@ -71,8 +76,15 @@ const AIAssistantPanel = ({ className }) => {
|
|
|
71
76
|
throw error
|
|
72
77
|
}
|
|
73
78
|
|
|
79
|
+
let systemPrompt = SUMMARY_SYSTEM_PROMPT
|
|
80
|
+
if (location.state?.type === 'makeSummaryLonger') {
|
|
81
|
+
systemPrompt = LONG_SUMMARY_SYSTEM_PROMPT
|
|
82
|
+
} else if (location.state?.type === 'makeSummaryShorter') {
|
|
83
|
+
systemPrompt = SHORT_SUMMARY_SYSTEM_PROMPT
|
|
84
|
+
}
|
|
85
|
+
|
|
74
86
|
const messages = [
|
|
75
|
-
{ role: 'system', content:
|
|
87
|
+
{ role: 'system', content: systemPrompt },
|
|
76
88
|
{
|
|
77
89
|
role: 'user',
|
|
78
90
|
content: getSummaryUserPrompt(textContent)
|
|
@@ -159,7 +171,7 @@ const AIAssistantPanel = ({ className }) => {
|
|
|
159
171
|
}
|
|
160
172
|
}
|
|
161
173
|
},
|
|
162
|
-
[client, file, t]
|
|
174
|
+
[client, file, t, location]
|
|
163
175
|
)
|
|
164
176
|
|
|
165
177
|
const handleRefresh = () => {
|
package/src/Panel/AI/prompts.js
CHANGED
|
@@ -15,10 +15,46 @@ Writing rules:
|
|
|
15
15
|
- Do not add new information
|
|
16
16
|
- Do not guess what is not explicitly stated
|
|
17
17
|
|
|
18
|
+
|
|
18
19
|
Output:
|
|
19
20
|
- A single coherent paragraph unless otherwise specified
|
|
20
21
|
- Do not add any extra information or interpret anything beyond the explicit task`
|
|
21
22
|
|
|
23
|
+
export const LONG_SUMMARY_SYSTEM_PROMPT = `You are a comprehensive and detailed text summarizer.
|
|
24
|
+
|
|
25
|
+
Your goal:
|
|
26
|
+
- Produce a detailed and extensive summary of the provided content
|
|
27
|
+
- Capture all key information, main points, and supporting details
|
|
28
|
+
- Maintain the original meaning and context
|
|
29
|
+
- Ensure the summary is significantly longer and more detailed than a standard summary
|
|
30
|
+
|
|
31
|
+
Writing rules:
|
|
32
|
+
- Keep the same language as the provided input. For example, if it's french, keep french
|
|
33
|
+
- Use clear and professional phrasing
|
|
34
|
+
- Organize the summary logically, using paragraphs if necessary
|
|
35
|
+
- Do not add new information not present in the text
|
|
36
|
+
- Do not guess what is not explicitly stated
|
|
37
|
+
|
|
38
|
+
Output:
|
|
39
|
+
- A structured and detailed summary
|
|
40
|
+
- Do not add any extra information or interpret anything beyond the explicit task`
|
|
41
|
+
|
|
42
|
+
export const SHORT_SUMMARY_SYSTEM_PROMPT = `You are an extremely concise text summarizer.
|
|
43
|
+
|
|
44
|
+
Your goal:
|
|
45
|
+
- Produce a very short summary (TL;DR) of the provided content
|
|
46
|
+
- Limit the summary to 1-2 sentences maximum
|
|
47
|
+
- Capture only the single most important point
|
|
48
|
+
|
|
49
|
+
Writing rules:
|
|
50
|
+
- Keep the same language as the provided input. For example, if it's french, keep french
|
|
51
|
+
- Be direct and to the point
|
|
52
|
+
- No fluff, no introductory phrases
|
|
53
|
+
|
|
54
|
+
Output:
|
|
55
|
+
- A single short paragraph (1-2 sentences)
|
|
56
|
+
- Do not add any extra information or interpret anything beyond the explicit task`
|
|
57
|
+
|
|
22
58
|
/**
|
|
23
59
|
* Generate user prompt for document summarization
|
|
24
60
|
* @param {string} textContent - The text content to summarize
|
package/src/Panel/Summary.jsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import cx from 'classnames'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import React, { useState, useRef } from 'react'
|
|
4
|
+
import { useLocation, useNavigate } from 'react-router-dom'
|
|
4
5
|
|
|
5
6
|
import flag from 'cozy-flags'
|
|
6
7
|
import Accordion from 'cozy-ui/transpiled/react/Accordion'
|
|
@@ -32,7 +33,7 @@ import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'
|
|
|
32
33
|
import QualificationListItemText from './Qualifications/QualificationListItemText'
|
|
33
34
|
import SummaryDialog from './SummaryDialog'
|
|
34
35
|
import styles from './styles.styl'
|
|
35
|
-
import {
|
|
36
|
+
import { makeSummaryLonger, makeSummaryShorter } from '../actions'
|
|
36
37
|
import { withViewerLocales } from '../hoc/withViewerLocales'
|
|
37
38
|
|
|
38
39
|
const Summary = ({ file, isReadOnly, t }) => {
|
|
@@ -41,6 +42,8 @@ const Summary = ({ file, isReadOnly, t }) => {
|
|
|
41
42
|
const [isExpanded, setIsExpanded] = useState(false)
|
|
42
43
|
const anchorRef = useRef()
|
|
43
44
|
const { showAlert } = useAlert()
|
|
45
|
+
const location = useLocation()
|
|
46
|
+
const navigate = useNavigate()
|
|
44
47
|
|
|
45
48
|
const label = t('Viewer.panel.summary')
|
|
46
49
|
const value = file.metadata?.description
|
|
@@ -51,16 +54,15 @@ const Summary = ({ file, isReadOnly, t }) => {
|
|
|
51
54
|
flag('drive.new-file-viewer-ui.enabled') && divider,
|
|
52
55
|
flag('drive.new-file-viewer-ui.enabled') && exportToText,
|
|
53
56
|
flag('drive.new-file-viewer-ui.enabled') && divider,
|
|
54
|
-
flag('drive.new-file-viewer-ui.enabled') &&
|
|
55
|
-
flag('drive.new-file-viewer-ui.enabled') &&
|
|
57
|
+
flag('drive.new-file-viewer-ui.enabled') && makeSummaryShorter,
|
|
58
|
+
flag('drive.new-file-viewer-ui.enabled') && makeSummaryLonger
|
|
56
59
|
],
|
|
57
60
|
{
|
|
58
61
|
t,
|
|
59
62
|
exportedText: value,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
file
|
|
63
|
+
file,
|
|
64
|
+
location,
|
|
65
|
+
navigate
|
|
64
66
|
}
|
|
65
67
|
)
|
|
66
68
|
|
|
@@ -7,6 +7,7 @@ import Informations from './Informations'
|
|
|
7
7
|
import Qualification from './Qualification'
|
|
8
8
|
import Sharing from './Sharing'
|
|
9
9
|
import Summary from './Summary'
|
|
10
|
+
import { getAntivirusStatus } from './helpers'
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @typedef {Object} PanelBlockSpec
|
|
@@ -27,7 +28,10 @@ export const getPanelBlocksSpecs = (isPublic = false, panelProps) =>
|
|
|
27
28
|
flag('drive.new-file-viewer-ui.enabled')
|
|
28
29
|
? {
|
|
29
30
|
antivirus: {
|
|
30
|
-
condition: () =>
|
|
31
|
+
condition: (file, t) => {
|
|
32
|
+
const { icon, text } = getAntivirusStatus(file, t)
|
|
33
|
+
return !panelProps?.antivirus?.disabled && icon && text
|
|
34
|
+
},
|
|
31
35
|
component: Antivirus
|
|
32
36
|
},
|
|
33
37
|
sharing: {
|
|
@@ -56,7 +60,10 @@ export const getPanelBlocksSpecs = (isPublic = false, panelProps) =>
|
|
|
56
60
|
}
|
|
57
61
|
: {
|
|
58
62
|
antivirus: {
|
|
59
|
-
condition: () =>
|
|
63
|
+
condition: (file, t) => {
|
|
64
|
+
const { icon, text } = getAntivirusStatus(file, t)
|
|
65
|
+
return !panelProps?.antivirus?.disabled && icon && text
|
|
66
|
+
},
|
|
60
67
|
component: Antivirus
|
|
61
68
|
},
|
|
62
69
|
qualifications: {
|
|
@@ -91,11 +98,11 @@ export const getPanelBlocksSpecs = (isPublic = false, panelProps) =>
|
|
|
91
98
|
* @param {import('cozy-client/types/types').FileDocument} options.file - File object
|
|
92
99
|
* @returns {Array.<React.Component>}
|
|
93
100
|
*/
|
|
94
|
-
const getPanelBlocks = ({ panelBlocksSpecs, file }) => {
|
|
101
|
+
const getPanelBlocks = ({ panelBlocksSpecs, file, t }) => {
|
|
95
102
|
const panelBlocks = []
|
|
96
103
|
|
|
97
104
|
Object.values(panelBlocksSpecs).forEach(panelBlock => {
|
|
98
|
-
panelBlock.condition(file) && panelBlocks.push(panelBlock.component)
|
|
105
|
+
panelBlock.condition(file, t) && panelBlocks.push(panelBlock.component)
|
|
99
106
|
})
|
|
100
107
|
|
|
101
108
|
return panelBlocks
|
package/src/ViewerContainer.jsx
CHANGED
|
@@ -17,7 +17,8 @@ const ViewerInformationsWrapper = ({
|
|
|
17
17
|
disableFooter,
|
|
18
18
|
validForPanel,
|
|
19
19
|
toolbarRef,
|
|
20
|
-
children
|
|
20
|
+
children,
|
|
21
|
+
currentIndex
|
|
21
22
|
}) => {
|
|
22
23
|
const theme = useTheme()
|
|
23
24
|
const { isLight } = useCozyTheme()
|
|
@@ -35,11 +36,17 @@ const ViewerInformationsWrapper = ({
|
|
|
35
36
|
setIsOpenAiAssistant(true)
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
if (location?.state?.
|
|
39
|
-
setIsOpenFileViewerPanel(
|
|
39
|
+
if (location?.state?.triggerDetailPanelTime !== undefined) {
|
|
40
|
+
setIsOpenFileViewerPanel(prev => !prev)
|
|
40
41
|
}
|
|
41
42
|
}, [location, setIsOpenAiAssistant, setIsOpenFileViewerPanel])
|
|
42
43
|
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!isOpenAiAssistant) {
|
|
46
|
+
setIsOpenFileViewerPanel(true)
|
|
47
|
+
}
|
|
48
|
+
}, [isOpenAiAssistant, currentIndex, setIsOpenFileViewerPanel])
|
|
49
|
+
|
|
43
50
|
useSetFlagshipUI(
|
|
44
51
|
{
|
|
45
52
|
bottomBackground: theme.palette.background.paper,
|
|
@@ -71,7 +78,7 @@ const ViewerInformationsWrapper = ({
|
|
|
71
78
|
)}
|
|
72
79
|
</>
|
|
73
80
|
)}
|
|
74
|
-
{isOpenFileViewerPanel && (
|
|
81
|
+
{isOpenFileViewerPanel && !isOpenAiAssistant && (
|
|
75
82
|
<>
|
|
76
83
|
{!disableFooter && (
|
|
77
84
|
<Footer>
|
package/src/actions/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { makeSummaryLonger } from './makeSummaryLonger'
|
|
2
|
+
export { makeSummaryShorter } from './makeSummaryShorter'
|
|
@@ -18,21 +18,29 @@ const makeComponent = (label, icon) => {
|
|
|
18
18
|
)
|
|
19
19
|
})
|
|
20
20
|
|
|
21
|
-
Component.displayName = '
|
|
21
|
+
Component.displayName = 'makeSummaryLonger'
|
|
22
22
|
|
|
23
23
|
return Component
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export const
|
|
26
|
+
export const makeSummaryLonger = ({ t, navigate, location }) => {
|
|
27
27
|
const icon = ExpandIcon
|
|
28
28
|
const label = t('Viewer.panel.expand')
|
|
29
29
|
|
|
30
30
|
return {
|
|
31
|
-
name: '
|
|
31
|
+
name: 'makeSummaryLonger',
|
|
32
32
|
icon,
|
|
33
33
|
label,
|
|
34
34
|
Component: makeComponent(label, icon),
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
action: () => {
|
|
36
|
+
navigate(location.pathname, {
|
|
37
|
+
replace: true,
|
|
38
|
+
state: {
|
|
39
|
+
...location.state,
|
|
40
|
+
showAIAssistant: true,
|
|
41
|
+
type: 'makeSummaryLonger'
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
}
|
|
37
45
|
}
|
|
38
46
|
}
|
|
@@ -18,21 +18,29 @@ const makeComponent = (label, icon) => {
|
|
|
18
18
|
)
|
|
19
19
|
})
|
|
20
20
|
|
|
21
|
-
Component.displayName = '
|
|
21
|
+
Component.displayName = 'makeSummaryShorter'
|
|
22
22
|
|
|
23
23
|
return Component
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export const
|
|
26
|
+
export const makeSummaryShorter = ({ t, location, navigate }) => {
|
|
27
27
|
const icon = NarrowIcon
|
|
28
28
|
const label = t('Viewer.panel.shorter')
|
|
29
29
|
|
|
30
30
|
return {
|
|
31
|
-
name: '
|
|
31
|
+
name: 'makeSummaryShorter',
|
|
32
32
|
icon,
|
|
33
33
|
label,
|
|
34
34
|
Component: makeComponent(label, icon),
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
action: () => {
|
|
36
|
+
navigate(location.pathname, {
|
|
37
|
+
replace: true,
|
|
38
|
+
state: {
|
|
39
|
+
...location.state,
|
|
40
|
+
showAIAssistant: true,
|
|
41
|
+
type: 'makeSummaryShorter'
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
}
|
|
37
45
|
}
|
|
38
46
|
}
|
package/src/locales/en.json
CHANGED
package/src/locales/fr.json
CHANGED
package/src/locales/ru.json
CHANGED