@@ -13,18 +13,10 @@ The Modus Collection APIs allow you to add vector search within your functions.
1313
1414To begin, import the ` collections ` namespace from the SDK:
1515
16- <CodeGroup >
17-
18- ``` go Go
19- import github.com /hypermodeinc/modus/sdk/go /pkg/collections
20- ```
21-
22- ``` ts AssemblyScript
16+ ``` ts
2317import { collections } from " @hypermode/modus-sdk-as"
2418```
2519
26- </CodeGroup >
27-
2820## Collections APIs
2921
3022{ /* <!-- vale Google.Headings = NO --> */ }
@@ -44,7 +36,7 @@ Inserts or updates an item in a collection.
4436 not, it creates a new one.
4537</Note >
4638
47- ``` go
39+ ``` ts
4840collections .upsert (
4941 collection : string ,
5042 key : string | null ,
@@ -86,7 +78,7 @@ Inserts or updates a batch of items into a collection.
8678 with the new text.
8779</Note >
8880
89- ``` go
81+ ``` ts
9082collections .upsertBatch (
9183 collection : string ,
9284 keys : string [] | null ,
@@ -123,7 +115,7 @@ collections.upsertBatch(
123115
124116Removes an item from the collection.
125117
126- ``` go
118+ ``` ts
127119collections .remove (
128120 collection : string ,
129121 key : string ,
@@ -157,7 +149,7 @@ useful for finding items that match a search query based on semantic meaning.
157149 for the text used when searching the collection.
158150</Note >
159151
160- ``` go
152+ ``` ts
161153collections .search (
162154 collection : string ,
163155 searchMethod : string ,
@@ -204,7 +196,7 @@ requiring precise similarity calculations between pre-computed embeddings.
204196 for the vector used when searching the collection.
205197</Note >
206198
207- ``` go
199+ ``` ts
208200collections .searchByVector (
209201 collection : string ,
210202 searchMethod : string ,
@@ -244,7 +236,7 @@ collections.searchByVector(
244236
245237Classify an item in the collection using previous vectors' labels.
246238
247- ``` go
239+ ``` ts
248240 collections .nnClassify (
249241 collection : string ,
250242 searchMethod : string ,
@@ -276,7 +268,7 @@ Classify an item in the collection using previous vectors' labels.
276268Computes distance between two keys in a collection using a search method's
277269embedder.
278270
279- ``` go
271+ ``` ts
280272collections .computeDistance (
281273 collection : string ,
282274 searchMethod : string ,
@@ -308,7 +300,7 @@ collections.computeDistance(
308300
309301Gets an item's text from a collection, give the item's key.
310302
311- ``` go
303+ ``` ts
312304collections .getText (
313305 collection : string ,
314306 key : string ,
@@ -335,7 +327,7 @@ collections.getText(
335327Get all items from a collection. The result is a map of key to text for all
336328items in the collection.
337329
338- ``` go
330+ ``` ts
339331collections .getTexts (
340332 collection : string ,
341333 namespace : string = " " ,
@@ -356,7 +348,7 @@ collections.getTexts(
356348
357349Get all namespaces in a collection.
358350
359- ``` go
351+ ``` ts
360352collections .getNamespaces (
361353 collection : string ,
362354): string []
@@ -371,7 +363,7 @@ collections.getNamespaces(
371363
372364Get the vector for an item in a collection.
373365
374- ``` go
366+ ``` ts
375367collections .getVector (
376368 collection : string ,
377369 searchMethod : string ,
@@ -402,7 +394,7 @@ collections.getVector(
402394
403395Get the labels for an item in a collection.
404396
405- ``` go
397+ ``` ts
406398collections .getLabels (
407399 collection : string ,
408400 key : string ,
@@ -433,7 +425,7 @@ resource-intensive, use it when necessary, for example after you have updated
433425the method for embedding calculation and want to re-compute the embeddings for
434426existing data in the collection.
435427
436- ``` go
428+ ``` ts
437429collections .recomputeSearchMethod (
438430 collection : string ,
439431 searchMethod : string ,
@@ -458,14 +450,14 @@ collections.recomputeSearchMethod(
458450
459451#### CollectionMutationResult
460452
461- ``` go
453+ ``` ts
462454class CollectionMutationResult {
463- collection: string ;
464- status: CollectionStatus ;
465- error : string ;
466- isSuccessful: bool ;
467- operation: string ;
468- keys: string [];
455+ collection: string
456+ status: CollectionStatus
457+ error: string
458+ isSuccessful: bool
459+ operation: string
460+ keys: string []
469461}
470462```
471463
@@ -498,14 +490,14 @@ Represents the result of a mutation operation on a collection.
498490
499491#### CollectionSearchResult
500492
501- ``` go
493+ ``` ts
502494class CollectionSearchResult {
503- collection: string ;
504- status: CollectionStatus ;
505- error : string ;
506- isSuccessful: bool ;
507- searchMethod: string ;
508- objects: CollectionSearchResultObject [];
495+ collection: string
496+ status: CollectionStatus
497+ error: string
498+ isSuccessful: bool
499+ searchMethod: string
500+ objects: CollectionSearchResultObject []
509501}
510502```
511503
@@ -538,14 +530,14 @@ Represents the result of a search operation on a collection.
538530
539531#### CollectionSearchResultObject
540532
541- ``` go
533+ ``` ts
542534class CollectionSearchResultObject {
543- namespace: string ;
544- key: string ;
545- text: string ;
546- labels: string [];
547- distance: f64;
548- score: f64;
535+ namespace: string
536+ key: string
537+ text: string
538+ labels: string []
539+ distance: f64
540+ score: f64
549541}
550542```
551543
@@ -573,15 +565,15 @@ Represents an object in the search results.
573565
574566#### CollectionClassificationResult
575567
576- ``` go
568+ ``` ts
577569class CollectionClassificationResult {
578- collection: string ;
579- status: CollectionStatus ;
580- error : string ;
581- isSuccessful: bool ;
582- searchMethod: string ;
583- labelsResult: CollectionClassificationLabelObject [];
584- cluster: CollectionClassificationResultObject [];
570+ collection: string
571+ status: CollectionStatus
572+ error: string
573+ isSuccessful: bool
574+ searchMethod: string
575+ labelsResult: CollectionClassificationLabelObject []
576+ cluster: CollectionClassificationResultObject []
585577}
586578```
587579
@@ -618,10 +610,10 @@ Represents the result of a classification operation on a collection.
618610
619611#### CollectionClassificationLabelObject
620612
621- ``` go
613+ ``` ts
622614class CollectionClassificationLabelObject {
623- label: string ;
624- confidence: f64;
615+ label: string
616+ confidence: f64
625617}
626618```
627619
@@ -637,12 +629,12 @@ Represents a classification label.
637629
638630#### CollectionClassificationResultObject
639631
640- ``` go
632+ ``` ts
641633class CollectionClassificationResultObject {
642- key: string ;
643- labels: string [];
644- distance: f64;
645- score: f64;
634+ key: string
635+ labels: string []
636+ distance: f64
637+ score: f64
646638}
647639```
648640
@@ -666,7 +658,7 @@ Represents an object in the classification results.
666658
667659#### CollectionStatus
668660
669- ``` go
661+ ``` ts
670662enum CollectionStatus {
671663 Success = " success" ;
672664 Error = " error" ;
@@ -685,14 +677,14 @@ The status of a collection operation.
685677
686678#### SearchMethodMutationResult
687679
688- ``` go
680+ ``` ts
689681class SearchMethodMutationResult {
690- collection: string ;
691- status: CollectionStatus ;
692- error : string ;
693- isSuccessful: bool ;
694- operation: string ;
695- searchMethod: string ;
682+ collection: string
683+ status: CollectionStatus
684+ error: string
685+ isSuccessful: bool
686+ operation: string
687+ searchMethod: string
696688}
697689```
698690
0 commit comments