sst 3.0.1-11 → 3.0.1-13
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/dist/vector-client.d.ts +80 -34
- package/dist/vector-client.js +1 -1
- package/package.json +1 -1
package/dist/vector-client.d.ts
CHANGED
|
@@ -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
|
|
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
|
-
*
|
|
34
|
-
* This metadata will be used to filter
|
|
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
|
-
*
|
|
40
|
-
*
|
|
31
|
+
* type: "movie",
|
|
32
|
+
* id: "movie-123",
|
|
33
|
+
* name: "Spiderman",
|
|
41
34
|
* }
|
|
42
35
|
* }
|
|
43
36
|
* ```
|
|
@@ -46,47 +39,89 @@ export type IngestEvent = {
|
|
|
46
39
|
};
|
|
47
40
|
export type RetrieveEvent = {
|
|
48
41
|
/**
|
|
49
|
-
* The prompt used to retrieve
|
|
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
|
-
*
|
|
47
|
+
* text: "This is an example text.",
|
|
54
48
|
* }
|
|
55
49
|
* ```
|
|
56
50
|
*/
|
|
57
|
-
|
|
51
|
+
text?: string;
|
|
58
52
|
/**
|
|
59
|
-
* The
|
|
60
|
-
*
|
|
53
|
+
* The base64 representation of the image prompt used to retrive embeddings.
|
|
54
|
+
* At least one of `text` or `image` must be provided.
|
|
61
55
|
* @example
|
|
62
56
|
* ```js
|
|
63
57
|
* {
|
|
64
|
-
*
|
|
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.
|
|
66
|
+
* @example
|
|
67
|
+
* ```js
|
|
68
|
+
* {
|
|
69
|
+
* include: {
|
|
65
70
|
* type: "movie",
|
|
66
|
-
*
|
|
71
|
+
* release: "2001",
|
|
67
72
|
* }
|
|
68
73
|
* }
|
|
69
74
|
* ```
|
|
70
|
-
* This will match
|
|
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
|
-
*
|
|
81
|
+
*
|
|
82
|
+
* But not the embedding with metadata:
|
|
77
83
|
* {
|
|
78
84
|
* type: "book",
|
|
79
85
|
* name: "Spiderman",
|
|
80
|
-
* release: "
|
|
86
|
+
* release: "2001",
|
|
81
87
|
* }
|
|
82
88
|
*/
|
|
83
|
-
|
|
89
|
+
include: any;
|
|
84
90
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
91
|
+
* Exclude embeddings with metadata that match the provided fields.
|
|
92
|
+
* @example
|
|
93
|
+
* ```js
|
|
94
|
+
* {
|
|
95
|
+
* include: {
|
|
96
|
+
* type: "movie",
|
|
97
|
+
* release: "2001",
|
|
98
|
+
* },
|
|
99
|
+
* exclude: {
|
|
100
|
+
* name: "Spiderman",
|
|
101
|
+
* }
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
* This will match the embedding with metadata:
|
|
105
|
+
* {
|
|
106
|
+
* type: "movie",
|
|
107
|
+
* name: "A Beautiful Mind",
|
|
108
|
+
* release: "2001",
|
|
109
|
+
* }
|
|
110
|
+
*
|
|
111
|
+
* But not the embedding with metadata:
|
|
112
|
+
* {
|
|
113
|
+
* type: "book",
|
|
114
|
+
* name: "Spiderman",
|
|
115
|
+
* release: "2001",
|
|
116
|
+
* }
|
|
117
|
+
*/
|
|
118
|
+
exclude?: any;
|
|
119
|
+
/**
|
|
120
|
+
* The threshold of similarity between the prompt and the retrieved embeddings.
|
|
121
|
+
* Only embeddings with a similarity score higher than the threshold will be returned.
|
|
87
122
|
* Expected value is between 0 and 1.
|
|
88
|
-
* - 0 means the prompt and the retrieved
|
|
89
|
-
* - 1 means the prompt and the retrieved
|
|
123
|
+
* - 0 means the prompt and the retrieved embeddings are completely different.
|
|
124
|
+
* - 1 means the prompt and the retrieved embeddings are identical.
|
|
90
125
|
* @default 0
|
|
91
126
|
* @example
|
|
92
127
|
* ```js
|
|
@@ -110,17 +145,28 @@ export type RetrieveEvent = {
|
|
|
110
145
|
};
|
|
111
146
|
export type RemoveEvent = {
|
|
112
147
|
/**
|
|
113
|
-
* The
|
|
148
|
+
* The metadata used to filter the removal of embeddings.
|
|
149
|
+
* Only embeddings with metadata that match the provided fields will be removed.
|
|
114
150
|
* @example
|
|
151
|
+
* To remove embeddings for movie with id "movie-123":
|
|
115
152
|
* ```js
|
|
116
153
|
* {
|
|
117
|
-
*
|
|
154
|
+
* include: {
|
|
155
|
+
* id: "movie-123",
|
|
156
|
+
* }
|
|
118
157
|
* }
|
|
158
|
+
* ```
|
|
159
|
+
* To remove embeddings for all movies:
|
|
160
|
+
* {
|
|
161
|
+
* include: {
|
|
162
|
+
* type: "movie",
|
|
163
|
+
* }
|
|
164
|
+
* }
|
|
119
165
|
*/
|
|
120
|
-
|
|
166
|
+
include: any;
|
|
121
167
|
};
|
|
122
168
|
export declare const VectorClient: (name: string) => {
|
|
123
169
|
ingest: (event: IngestEvent) => Promise<any>;
|
|
124
170
|
retrieve: (event: RetrieveEvent) => Promise<any>;
|
|
125
|
-
|
|
171
|
+
remove: (event: RemoveEvent) => Promise<any>;
|
|
126
172
|
};
|
package/dist/vector-client.js
CHANGED
|
@@ -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
|
-
|
|
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),
|