@automattic/jetpack-ai-client 0.28.0 → 0.28.1
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
CHANGED
|
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.28.1] - 2025-05-15
|
|
9
|
+
### Fixed
|
|
10
|
+
- AI Assistant: Shorten AI excerpt if the built-in AI model doesn't respect the word count limit. [#43433]
|
|
11
|
+
|
|
8
12
|
## [0.28.0] - 2025-05-12
|
|
9
13
|
### Changed
|
|
10
14
|
- AI Assistant: Propagate the AI model used in the AI requests. [#43390]
|
|
@@ -608,6 +612,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
608
612
|
- AI Client: stop using smart document visibility handling on the fetchEventSource library, so it does not restart the completion when changing tabs. [#32004]
|
|
609
613
|
- Updated package dependencies. [#31468] [#31659] [#31785]
|
|
610
614
|
|
|
615
|
+
[0.28.1]: https://github.com/Automattic/jetpack-ai-client/compare/v0.28.0...v0.28.1
|
|
611
616
|
[0.28.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.27.10...v0.28.0
|
|
612
617
|
[0.27.10]: https://github.com/Automattic/jetpack-ai-client/compare/v0.27.9...v0.27.10
|
|
613
618
|
[0.27.9]: https://github.com/Automattic/jetpack-ai-client/compare/v0.27.8...v0.27.9
|
|
@@ -82,7 +82,7 @@ export default class ChromeAISuggestionsEventSource extends EventTarget {
|
|
|
82
82
|
}
|
|
83
83
|
// Helper function to format summarizer options
|
|
84
84
|
getSummarizerOptions(tone, wordCount) {
|
|
85
|
-
let sharedContext = `The summary you write should contain
|
|
85
|
+
let sharedContext = `The summary you write should contain strictly less than ${wordCount ?? 50} words. Strive for precision in word count without compromising clarity and significance`;
|
|
86
86
|
if (tone) {
|
|
87
87
|
sharedContext += `\n - Write with a ${tone} tone.\n`;
|
|
88
88
|
}
|
|
@@ -99,8 +99,6 @@ export default class ChromeAISuggestionsEventSource extends EventTarget {
|
|
|
99
99
|
if (!('Summarizer' in self)) {
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
-
// eslint-disable-next-line no-console
|
|
103
|
-
console.log('Summarizer is available');
|
|
104
102
|
const availability = await self.Summarizer.availability();
|
|
105
103
|
if (availability === 'unavailable') {
|
|
106
104
|
return;
|
|
@@ -112,7 +110,12 @@ export default class ChromeAISuggestionsEventSource extends EventTarget {
|
|
|
112
110
|
}
|
|
113
111
|
try {
|
|
114
112
|
const context = `Write with a ${tone} tone.`;
|
|
115
|
-
|
|
113
|
+
let summary = await summarizer.summarize(text, { context: context });
|
|
114
|
+
wordCount = wordCount ?? 50;
|
|
115
|
+
// gemini-nano has a tendency to exceed the word count, so we need to check and summarize again if necessary
|
|
116
|
+
if (summary.split(' ').length > wordCount) {
|
|
117
|
+
summary = await summarizer.summarize(summary, { context: context });
|
|
118
|
+
}
|
|
116
119
|
this.processEvent({
|
|
117
120
|
id: '',
|
|
118
121
|
event: 'summary',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@automattic/jetpack-ai-client",
|
|
4
|
-
"version": "0.28.
|
|
4
|
+
"version": "0.28.1",
|
|
5
5
|
"description": "A JS client for consuming Jetpack AI services",
|
|
6
6
|
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/ai-client/#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -141,9 +141,9 @@ export default class ChromeAISuggestionsEventSource extends EventTarget {
|
|
|
141
141
|
|
|
142
142
|
// Helper function to format summarizer options
|
|
143
143
|
private getSummarizerOptions( tone?: string, wordCount?: number ) {
|
|
144
|
-
let sharedContext = `The summary you write should contain
|
|
144
|
+
let sharedContext = `The summary you write should contain strictly less than ${
|
|
145
145
|
wordCount ?? 50
|
|
146
|
-
} words
|
|
146
|
+
} words. Strive for precision in word count without compromising clarity and significance`;
|
|
147
147
|
|
|
148
148
|
if ( tone ) {
|
|
149
149
|
sharedContext += `\n - Write with a ${ tone } tone.\n`;
|
|
@@ -164,8 +164,7 @@ export default class ChromeAISuggestionsEventSource extends EventTarget {
|
|
|
164
164
|
if ( ! ( 'Summarizer' in self ) ) {
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
|
-
|
|
168
|
-
console.log( 'Summarizer is available' );
|
|
167
|
+
|
|
169
168
|
const availability = await self.Summarizer.availability();
|
|
170
169
|
|
|
171
170
|
if ( availability === 'unavailable' ) {
|
|
@@ -182,7 +181,15 @@ export default class ChromeAISuggestionsEventSource extends EventTarget {
|
|
|
182
181
|
|
|
183
182
|
try {
|
|
184
183
|
const context = `Write with a ${ tone } tone.`;
|
|
185
|
-
|
|
184
|
+
let summary = await summarizer.summarize( text, { context: context } );
|
|
185
|
+
|
|
186
|
+
wordCount = wordCount ?? 50;
|
|
187
|
+
|
|
188
|
+
// gemini-nano has a tendency to exceed the word count, so we need to check and summarize again if necessary
|
|
189
|
+
if ( summary.split( ' ' ).length > wordCount ) {
|
|
190
|
+
summary = await summarizer.summarize( summary, { context: context } );
|
|
191
|
+
}
|
|
192
|
+
|
|
186
193
|
this.processEvent( {
|
|
187
194
|
id: '',
|
|
188
195
|
event: 'summary',
|