sst 3.0.1-11 → 3.0.1-12

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.
@@ -1,16 +1,7 @@
1
1
  export type IngestEvent = {
2
- /**
3
- * The external ID of the event.
4
- * If the external ID already exists, the embedding and metadata will be updated.
5
- * @example
6
- * ```js
7
- * {
8
- * externalId: "37043bc3-2166-437d-bbf8-a2238d7a5796"
9
- * }
10
- */
11
- externalId: string;
12
2
  /**
13
3
  * The text used to generate the embedding vector.
4
+ * At least one of `text` or `image` must be provided.
14
5
  * @example
15
6
  * ```js
16
7
  * {
@@ -18,9 +9,10 @@ export type IngestEvent = {
18
9
  * }
19
10
  * ```
20
11
  */
21
- text: string;
12
+ text?: string;
22
13
  /**
23
14
  * The base64 representation of the image used to generate the embedding vector.
15
+ * At least one of `text` or `image` must be provided.
24
16
  * @example
25
17
  * ```js
26
18
  * {
@@ -30,14 +22,15 @@ export type IngestEvent = {
30
22
  */
31
23
  image?: string;
32
24
  /**
33
- * Additional metadata for the event in JSON format.
34
- * This metadata will be used to filter the retrieval of events.
25
+ * Metadata for the event in JSON format.
26
+ * This metadata will be used to filter when retrieving and removing embeddings.
35
27
  * @example
36
28
  * ```js
37
29
  * {
38
30
  * metadata: {
39
- * key1: "value1",
40
- * key2: "value2"
31
+ * type: "movie",
32
+ * id: "movie-123",
33
+ * name: "Spiderman",
41
34
  * }
42
35
  * }
43
36
  * ```
@@ -46,18 +39,30 @@ export type IngestEvent = {
46
39
  };
47
40
  export type RetrieveEvent = {
48
41
  /**
49
- * The prompt used to retrieve events.
42
+ * The text prompt used to retrieve embeddings.
43
+ * At least one of `text` or `image` must be provided.
50
44
  * @example
51
45
  * ```js
52
46
  * {
53
- * prompt: "This is an example text.",
47
+ * text: "This is an example text.",
54
48
  * }
55
49
  * ```
56
50
  */
57
- prompt: string;
51
+ text?: string;
58
52
  /**
59
- * The metadata used to filter the retrieval of events.
60
- * Only events with metadata that match the provided fields will be returned.
53
+ * The base64 representation of the image prompt used to retrive embeddings.
54
+ * At least one of `text` or `image` must be provided.
55
+ * @example
56
+ * ```js
57
+ * {
58
+ * image: await fs.readFile("./file.jpg").toString("base64"),
59
+ * }
60
+ * ```
61
+ */
62
+ image?: string;
63
+ /**
64
+ * The metadata used to filter the retrieval of embeddings.
65
+ * Only embeddings with metadata that match the provided fields will be returned.
61
66
  * @example
62
67
  * ```js
63
68
  * {
@@ -67,13 +72,14 @@ export type RetrieveEvent = {
67
72
  * }
68
73
  * }
69
74
  * ```
70
- * This will match event with metadata:
75
+ * This will match the embedding with metadata:
71
76
  * {
72
77
  * type: "movie",
73
78
  * name: "Spiderman",
74
79
  * release: "2001",
75
80
  * }
76
- * But this will not match event with metadata:
81
+ *
82
+ * But not the embedding with metadata:
77
83
  * {
78
84
  * type: "book",
79
85
  * name: "Spiderman",
@@ -82,11 +88,11 @@ export type RetrieveEvent = {
82
88
  */
83
89
  metadata: any;
84
90
  /**
85
- * The threshold of similarity between the prompt and the retrieved events.
86
- * Only events with a similarity score higher than the threshold will be returned.
91
+ * The threshold of similarity between the prompt and the retrieved embeddings.
92
+ * Only embeddings with a similarity score higher than the threshold will be returned.
87
93
  * Expected value is between 0 and 1.
88
- * - 0 means the prompt and the retrieved events are completely different.
89
- * - 1 means the prompt and the retrieved events are identical.
94
+ * - 0 means the prompt and the retrieved embeddings are completely different.
95
+ * - 1 means the prompt and the retrieved embeddings are identical.
90
96
  * @default 0
91
97
  * @example
92
98
  * ```js
@@ -110,17 +116,28 @@ export type RetrieveEvent = {
110
116
  };
111
117
  export type RemoveEvent = {
112
118
  /**
113
- * The external ID of the event to remove.
119
+ * The metadata used to filter the removal of embeddings.
120
+ * Only embeddings with metadata that match the provided fields will be removed.
114
121
  * @example
122
+ * To remove embeddings for movie with id "movie-123":
115
123
  * ```js
116
124
  * {
117
- * externalId: "37043bc3-2166-437d-bbf8-a2238d7a5796"
125
+ * metadata: {
126
+ * id: "movie-123",
127
+ * }
118
128
  * }
129
+ * ```
130
+ * To remove embeddings for all movies:
131
+ * {
132
+ * metadata: {
133
+ * type: "movie",
134
+ * }
135
+ * }
119
136
  */
120
- externalId: string;
137
+ metadata: any;
121
138
  };
122
139
  export declare const VectorClient: (name: string) => {
123
140
  ingest: (event: IngestEvent) => Promise<any>;
124
141
  retrieve: (event: RetrieveEvent) => Promise<any>;
125
- delete: (event: RemoveEvent) => Promise<any>;
142
+ remove: (event: RemoveEvent) => Promise<any>;
126
143
  };
@@ -17,7 +17,7 @@ export const VectorClient = (name) => {
17
17
  }));
18
18
  return parsePayload(ret, "Failed to retrieve from the vector db");
19
19
  },
20
- delete: async (event) => {
20
+ remove: async (event) => {
21
21
  const ret = await lambda.send(new InvokeCommand({
22
22
  FunctionName: Resource[name].removerFunctionName,
23
23
  Payload: JSON.stringify(event),
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "sst",
4
4
  "type": "module",
5
- "version": "3.0.1-11",
5
+ "version": "3.0.1-12",
6
6
  "main": "./dist/index.js",
7
7
  "exports": {
8
8
  ".": "./dist/index.js",