sst 3.0.1-10 → 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.
- package/dist/vector-client.d.ts +47 -30
- 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,18 +39,30 @@ 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.
|
|
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
|
|
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",
|
|
@@ -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
|
|
86
|
-
* Only
|
|
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
|
|
89
|
-
* - 1 means the prompt and the retrieved
|
|
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
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
142
|
+
remove: (event: RemoveEvent) => Promise<any>;
|
|
126
143
|
};
|
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),
|