@automattic/jetpack-ai-client 0.26.2 → 0.26.3
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 +9 -1
- package/build/chrome-ai/suggestions.js +1 -1
- package/build/hooks/use-ai-suggestions/index.d.ts +1 -1
- package/build/hooks/use-ai-suggestions/index.js +2 -2
- package/package.json +10 -10
- package/src/chrome-ai/suggestions.ts +3 -1
- package/src/hooks/use-ai-suggestions/index.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,9 +5,16 @@ 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.26.3] - 2025-02-24
|
|
9
|
+
### Changed
|
|
10
|
+
- Update package dependencies. [#41955]
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- Prevent Chrome AI requests from incrementing request count. [#41900]
|
|
14
|
+
|
|
8
15
|
## [0.26.2] - 2025-02-17
|
|
9
16
|
### Added
|
|
10
|
-
-
|
|
17
|
+
- Add translation support using Chrome's Gemini AI mini. [#41724]
|
|
11
18
|
|
|
12
19
|
## [0.26.1] - 2025-02-11
|
|
13
20
|
### Changed
|
|
@@ -525,6 +532,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
525
532
|
- AI Client: stop using smart document visibility handling on the fetchEventSource library, so it does not restart the completion when changing tabs. [#32004]
|
|
526
533
|
- Updated package dependencies. [#31468] [#31659] [#31785]
|
|
527
534
|
|
|
535
|
+
[0.26.3]: https://github.com/Automattic/jetpack-ai-client/compare/v0.26.2...v0.26.3
|
|
528
536
|
[0.26.2]: https://github.com/Automattic/jetpack-ai-client/compare/v0.26.1...v0.26.2
|
|
529
537
|
[0.26.1]: https://github.com/Automattic/jetpack-ai-client/compare/v0.26.0...v0.26.1
|
|
530
538
|
[0.26.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.25.7...v0.26.0
|
|
@@ -43,7 +43,7 @@ export default class ChromeAISuggestionsEventSource extends EventTarget {
|
|
|
43
43
|
this.dispatchEvent(new CustomEvent('suggestion', { detail: data.message }));
|
|
44
44
|
}
|
|
45
45
|
if (data.complete) {
|
|
46
|
-
this.dispatchEvent(new CustomEvent('done', { detail: data.message }));
|
|
46
|
+
this.dispatchEvent(new CustomEvent('done', { detail: { message: data.message, source: 'chromeAI' } }));
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
processErrorEvent(e) {
|
|
@@ -18,7 +18,7 @@ type useAiSuggestionsOptions = {
|
|
|
18
18
|
askQuestionOptions?: AskQuestionOptionsArgProps;
|
|
19
19
|
initialRequestingState?: RequestingStateProp;
|
|
20
20
|
onSuggestion?: (suggestion: string) => void;
|
|
21
|
-
onDone?: (content: string) => void;
|
|
21
|
+
onDone?: (content: string, skipRequestCount?: boolean) => void;
|
|
22
22
|
onStop?: () => void;
|
|
23
23
|
onError?: (error: RequestingErrorProps) => void;
|
|
24
24
|
onAllErrors?: (error: RequestingErrorProps) => void;
|
|
@@ -100,8 +100,8 @@ export default function useAiSuggestions({ prompt, autoRequest = false, askQuest
|
|
|
100
100
|
*/
|
|
101
101
|
const handleDone = useCallback((event) => {
|
|
102
102
|
closeEventSource();
|
|
103
|
-
const fullSuggestion = removeLlamaArtifact(event?.detail);
|
|
104
|
-
onDone?.(fullSuggestion);
|
|
103
|
+
const fullSuggestion = removeLlamaArtifact(event?.detail?.message ?? event?.detail);
|
|
104
|
+
onDone?.(fullSuggestion, event?.detail?.source === 'chromeAI');
|
|
105
105
|
setRequestingState('done');
|
|
106
106
|
}, [onDone]);
|
|
107
107
|
const handleAnyError = useCallback((event) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@automattic/jetpack-ai-client",
|
|
4
|
-
"version": "0.26.
|
|
4
|
+
"version": "0.26.3",
|
|
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": {
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
},
|
|
25
25
|
"type": "module",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@storybook/addon-actions": "8.
|
|
28
|
-
"@storybook/blocks": "8.
|
|
29
|
-
"@storybook/preview-api": "8.
|
|
30
|
-
"@storybook/react": "8.
|
|
27
|
+
"@storybook/addon-actions": "8.5.8",
|
|
28
|
+
"@storybook/blocks": "8.5.8",
|
|
29
|
+
"@storybook/preview-api": "8.5.8",
|
|
30
|
+
"@storybook/react": "8.5.8",
|
|
31
31
|
"@types/markdown-it": "14.1.2",
|
|
32
32
|
"@types/turndown": "5.0.5",
|
|
33
33
|
"jest": "^29.6.2",
|
|
34
34
|
"jest-environment-jsdom": "29.7.0",
|
|
35
|
-
"storybook": "8.
|
|
35
|
+
"storybook": "8.5.8",
|
|
36
36
|
"typescript": "5.0.4"
|
|
37
37
|
},
|
|
38
38
|
"exports": {
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"main": "./build/index.js",
|
|
45
45
|
"types": "./build/index.d.ts",
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@automattic/jetpack-base-styles": "^0.6.
|
|
48
|
-
"@automattic/jetpack-components": "^0.67.
|
|
49
|
-
"@automattic/jetpack-connection": "^0.
|
|
50
|
-
"@automattic/jetpack-shared-extension-utils": "^0.17.
|
|
47
|
+
"@automattic/jetpack-base-styles": "^0.6.43",
|
|
48
|
+
"@automattic/jetpack-components": "^0.67.1",
|
|
49
|
+
"@automattic/jetpack-connection": "^0.37.0",
|
|
50
|
+
"@automattic/jetpack-shared-extension-utils": "^0.17.3",
|
|
51
51
|
"@microsoft/fetch-event-source": "2.0.1",
|
|
52
52
|
"@types/jest": "29.5.14",
|
|
53
53
|
"@types/react": "18.3.18",
|
|
@@ -88,7 +88,9 @@ export default class ChromeAISuggestionsEventSource extends EventTarget {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
if ( data.complete ) {
|
|
91
|
-
this.dispatchEvent(
|
|
91
|
+
this.dispatchEvent(
|
|
92
|
+
new CustomEvent( 'done', { detail: { message: data.message, source: 'chromeAI' } } )
|
|
93
|
+
);
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
|
|
@@ -70,7 +70,7 @@ type useAiSuggestionsOptions = {
|
|
|
70
70
|
/*
|
|
71
71
|
* onDone callback.
|
|
72
72
|
*/
|
|
73
|
-
onDone?: ( content: string ) => void;
|
|
73
|
+
onDone?: ( content: string, skipRequestCount?: boolean ) => void;
|
|
74
74
|
|
|
75
75
|
/*
|
|
76
76
|
* onStop callback.
|
|
@@ -256,9 +256,9 @@ export default function useAiSuggestions( {
|
|
|
256
256
|
( event: CustomEvent ) => {
|
|
257
257
|
closeEventSource();
|
|
258
258
|
|
|
259
|
-
const fullSuggestion = removeLlamaArtifact( event?.detail );
|
|
259
|
+
const fullSuggestion = removeLlamaArtifact( event?.detail?.message ?? event?.detail );
|
|
260
260
|
|
|
261
|
-
onDone?.( fullSuggestion );
|
|
261
|
+
onDone?.( fullSuggestion, event?.detail?.source === 'chromeAI' );
|
|
262
262
|
setRequestingState( 'done' );
|
|
263
263
|
},
|
|
264
264
|
[ onDone ]
|