@@ -83,48 +83,55 @@ export class CollectionSearchResultObject {
83
83
84
84
export class CollectionClassificationResult extends CollectionResult {
85
85
searchMethod : string ;
86
- label : string ;
87
- labelsResult : string [ ] ;
86
+ labelsResult : CollectionClassificationLabelObject [ ] ;
88
87
cluster : CollectionClassificationResultObject [ ] ;
89
88
90
89
constructor (
91
90
collection : string ,
92
91
status : CollectionStatus ,
93
92
error : string ,
94
93
searchMethod : string ,
95
- label : string ,
96
- labelsResult : string [ ] ,
94
+ labelsResult : CollectionClassificationLabelObject [ ] ,
97
95
cluster : CollectionClassificationResultObject [ ] ,
98
96
) {
99
97
super ( collection , status , error ) ;
100
98
this . searchMethod = searchMethod ;
101
- this . label = label ;
102
99
this . labelsResult = labelsResult ;
103
100
this . cluster = cluster ;
104
101
}
105
102
}
106
103
104
+ export class CollectionClassificationLabelObject {
105
+ label : string ;
106
+ confidence : f64 ;
107
+
108
+ constructor ( label : string , confidence : f64 ) {
109
+ this . label = label ;
110
+ this . confidence = confidence ;
111
+ }
112
+ }
113
+
107
114
export class CollectionClassificationResultObject {
108
115
key : string ;
109
- label : string ;
116
+ labels : string [ ] ;
110
117
distance : f64 ;
111
118
score : f64 ;
112
119
113
- constructor ( key : string , label : string , distance : f64 , score : f64 ) {
120
+ constructor ( key : string , labels : string [ ] , distance : f64 , score : f64 ) {
114
121
this . key = key ;
115
- this . label = label ;
122
+ this . labels = labels ;
116
123
this . distance = distance ;
117
124
this . score = score ;
118
125
}
119
126
}
120
127
121
128
// @ts -expect-error: decorator
122
- @external ( "hypermode" , "upsertToCollection " )
129
+ @external ( "hypermode" , "upsertToCollection_v2 " )
123
130
declare function hostUpsertToCollection (
124
131
collection : string ,
125
132
keys : string [ ] ,
126
133
texts : string [ ] ,
127
- labels : string [ ] ,
134
+ labels : string [ ] [ ] ,
128
135
) : CollectionMutationResult ;
129
136
130
137
// @ts -expect-error: decorator
@@ -145,8 +152,8 @@ declare function hostSearchCollection(
145
152
) : CollectionSearchResult ;
146
153
147
154
// @ts -expect-error: decorator
148
- @external ( "hypermode" , "zsClassifyCollection " )
149
- declare function hostZSClassifyCollection (
155
+ @external ( "hypermode" , "nnClassifyCollection " )
156
+ declare function hostNnClassifyCollection (
150
157
collection : string ,
151
158
searchMethod : string ,
152
159
text : string ,
@@ -186,7 +193,7 @@ export function upsertBatch(
186
193
collection : string ,
187
194
keys : string [ ] | null ,
188
195
texts : string [ ] ,
189
- labels : string [ ] = [ ] ,
196
+ labelsArr : string [ ] [ ] = [ ] ,
190
197
) : CollectionMutationResult {
191
198
if ( collection . length == 0 ) {
192
199
console . error ( "Collection is empty." ) ;
@@ -211,7 +218,7 @@ export function upsertBatch(
211
218
keysArr = keys ;
212
219
}
213
220
214
- const result = hostUpsertToCollection ( collection , keysArr , texts , labels ) ;
221
+ const result = hostUpsertToCollection ( collection , keysArr , texts , labelsArr ) ;
215
222
if ( utils . resultIsInvalid ( result ) ) {
216
223
console . error ( "Error upserting to Text index." ) ;
217
224
return new CollectionMutationResult (
@@ -230,7 +237,7 @@ export function upsert(
230
237
collection : string ,
231
238
key : string | null ,
232
239
text : string ,
233
- label : string = "" ,
240
+ labels : string [ ] = [ ] ,
234
241
) : CollectionMutationResult {
235
242
if ( collection . length == 0 ) {
236
243
console . error ( "Collection is empty." ) ;
@@ -257,12 +264,12 @@ export function upsert(
257
264
258
265
const texts : string [ ] = [ text ] ;
259
266
260
- const labels : string [ ] = [ ] ;
261
- if ( label !== "" ) {
262
- labels . push ( label ) ;
267
+ const labelsArr : string [ ] [ ] = [ ] ;
268
+ if ( labels != null ) {
269
+ labelsArr . push ( labels ) ;
263
270
}
264
271
265
- const result = hostUpsertToCollection ( collection , keys , texts , labels ) ;
272
+ const result = hostUpsertToCollection ( collection , keys , texts , labelsArr ) ;
266
273
if ( utils . resultIsInvalid ( result ) ) {
267
274
console . error ( "Error upserting to Text index." ) ;
268
275
return new CollectionMutationResult (
@@ -353,7 +360,7 @@ export function search(
353
360
354
361
// fetch embedders for collection & search method, run text through it and
355
362
// classify Text index for similar Texts, return the result keys
356
- export function zsClassify (
363
+ export function nnClassify (
357
364
collection : string ,
358
365
searchMethod : string ,
359
366
text : string ,
@@ -365,20 +372,18 @@ export function zsClassify(
365
372
CollectionStatus . Error ,
366
373
"Text is empty." ,
367
374
searchMethod ,
368
- "" ,
369
375
[ ] ,
370
376
[ ] ,
371
377
) ;
372
378
}
373
- const result = hostZSClassifyCollection ( collection , searchMethod , text ) ;
379
+ const result = hostNnClassifyCollection ( collection , searchMethod , text ) ;
374
380
if ( utils . resultIsInvalid ( result ) ) {
375
381
console . error ( "Error classifying Text index." ) ;
376
382
return new CollectionClassificationResult (
377
383
collection ,
378
384
CollectionStatus . Error ,
379
385
"Error classifying Text index." ,
380
386
searchMethod ,
381
- "" ,
382
387
[ ] ,
383
388
[ ] ,
384
389
) ;
0 commit comments