@@ -45,35 +45,44 @@ const ClassificationMethodSettings = () => {
45
45
) ;
46
46
const { setFeatureSettings } = useDispatch ( STORE_NAME ) ;
47
47
48
- const classifaicationMethodOptions = [
49
- {
48
+ const classifaicationMethodOptions = [ ] ;
49
+ if ( featureSettings . provider === 'ibm_watson_nlu' ) {
50
+ classifaicationMethodOptions . push ( {
50
51
label : __ (
51
52
'Recommend terms even if they do not exist on the site' ,
52
53
'classifai'
53
54
) ,
54
55
value : 'recommended_terms' ,
55
- } ,
56
- {
57
- label : __ (
58
- 'Only recommend terms that already exist on the site' ,
59
- 'classifai'
60
- ) ,
61
- value : 'existing_terms' ,
62
- } ,
63
- ] ;
56
+ } ) ;
57
+ }
64
58
65
- if (
66
- [ 'openai_embeddings' , 'azure_openai_embeddings' ] . includes (
67
- featureSettings . provider
68
- )
69
- ) {
70
- delete classifaicationMethodOptions [ 0 ] ;
71
- if ( featureSettings . classification_method === 'recommended_terms' ) {
72
- setFeatureSettings ( {
73
- classification_method : 'existing_terms' ,
74
- } ) ;
59
+ classifaicationMethodOptions . push ( {
60
+ label : __ (
61
+ 'Only recommend terms that already exist on the site' ,
62
+ 'classifai'
63
+ ) ,
64
+ value : 'existing_terms' ,
65
+ } ) ;
66
+
67
+ useEffect ( ( ) => {
68
+ if (
69
+ [ 'openai_embeddings' , 'azure_openai_embeddings' ] . includes (
70
+ featureSettings . provider
71
+ )
72
+ ) {
73
+ if (
74
+ featureSettings . classification_method === 'recommended_terms'
75
+ ) {
76
+ setFeatureSettings ( {
77
+ classification_method : 'existing_terms' ,
78
+ } ) ;
79
+ }
75
80
}
76
- }
81
+ } , [
82
+ featureSettings . provider ,
83
+ featureSettings . classification_method ,
84
+ setFeatureSettings ,
85
+ ] ) ;
77
86
78
87
return (
79
88
< SettingsRow label = { __ ( 'Classification method' , 'classifai' ) } >
@@ -201,6 +210,7 @@ export const ClassificationSettings = () => {
201
210
'Used to preview the results for a particular post.' ,
202
211
'classifai'
203
212
) }
213
+ __nextHasNoMarginBottom
204
214
>
205
215
< PostSelector showLabel = { false } />
206
216
</ BaseControl >
@@ -259,6 +269,7 @@ export const ClassificationSettings = () => {
259
269
} ,
260
270
} ) ;
261
271
} }
272
+ __nextHasNoMarginBottom
262
273
/>
263
274
) ;
264
275
} ) }
@@ -288,6 +299,7 @@ export const ClassificationSettings = () => {
288
299
} ,
289
300
} ) ;
290
301
} }
302
+ __nextHasNoMarginBottom
291
303
/>
292
304
) ;
293
305
} ) }
0 commit comments