1
1
export interface EmailAdapter {
2
+
3
+ /**
4
+ * This method is called to validate the configuration of the adapter
5
+ * and should throw a clear user-readbale error if the configuration is invalid.
6
+ */
2
7
validate ( ) : Promise < void > ;
3
8
9
+ /**
10
+ * This method should send an email using the adapter
11
+ * @param from - The sender's email address
12
+ * @param to - The recipient's email address
13
+ * @param text - The plain text version of the email
14
+ * @param html - The HTML version of the email
15
+ * @param subject - The subject of the email
16
+ */
4
17
sendEmail (
5
18
from : string ,
6
19
to : string ,
@@ -15,8 +28,19 @@ export interface EmailAdapter {
15
28
16
29
export interface CompletionAdapter {
17
30
31
+ /**
32
+ * This method is called to validate the configuration of the adapter
33
+ * and should throw a clear user-readbale error if the configuration is invalid.
34
+ */
18
35
validate ( ) : void ;
19
36
37
+ /**
38
+ * This method should return a text completion based on the provided content and stop sequence.
39
+ * @param content - The input text to complete
40
+ * @param stop - An array of stop sequences to indicate where to stop the completion
41
+ * @param maxTokens - The maximum number of tokens to generate
42
+ * @returns A promise that resolves to an object containing the completed text and other metadata
43
+ */
20
44
complete (
21
45
content : string ,
22
46
stop : string [ ] ,
@@ -30,10 +54,14 @@ export interface CompletionAdapter {
30
54
31
55
export interface ImageGenerationAdapter {
32
56
57
+ /**
58
+ * This method is called to validate the configuration of the adapter
59
+ * and should throw a clear user-readbale error if the configuration is invalid.
60
+ */
33
61
validate ( ) : void ;
34
62
35
63
/**
36
- * Return 1 or 10, or Infinity if the adapter supports multiple images
64
+ * Return max number of images which model can generate in one request
37
65
*/
38
66
outputImagesMaxCountSupported ( ) : number ;
39
67
@@ -47,6 +75,14 @@ export interface ImageGenerationAdapter {
47
75
*/
48
76
inputFileExtensionSupported ( ) : string [ ] ;
49
77
78
+ /**
79
+ * This method should generate an image based on the provided prompt and input files.
80
+ * @param prompt - The prompt to generate the image
81
+ * @param inputFiles - An array of input file paths (optional)
82
+ * @param n - The number of images to generate (default is 1)
83
+ * @param size - The size of the generated image (default is the lowest dimension supported)
84
+ * @returns A promise that resolves to an object containing the generated image URLs and any error message
85
+ */
50
86
generate ( {
51
87
prompt,
52
88
inputFiles,
@@ -68,11 +104,76 @@ export interface ImageGenerationAdapter {
68
104
}
69
105
70
106
71
-
107
+ /**
108
+ * This interface is used to implement OAuth2 authentication adapters.
109
+ */
72
110
export interface OAuth2Adapter {
111
+ /**
112
+ * This method should return navigatable URL to the OAuth2 provider authentication page.
113
+ */
73
114
getAuthUrl ( ) : string ;
115
+
116
+ /**
117
+ * This method should return the token from the OAuth2 provider using the provided code and redirect URI.
118
+ * @param code - The authorization code received from the OAuth2 provider
119
+ * @param redirect_uri - The redirect URI used in the authentication request
120
+ * @returns A promise that resolves to an object containing the email address of the authenticated user
121
+ */
74
122
getTokenFromCode ( code : string , redirect_uri : string ) : Promise < { email : string } > ;
123
+
124
+ /**
125
+ * This method should return text (content) of SVG icon which will be used in the UI.
126
+ * Use official SVG icons with simplest possible conent, omit icons which have base64 encoded raster images inside.
127
+ */
75
128
getIcon ( ) : string ;
129
+
130
+ /**
131
+ * This method should return the text to be displayed on the button in the UI
132
+ */
76
133
getButtonText ?( ) : string ;
134
+
135
+ /**
136
+ * This method should return the name of the adapter
137
+ */
77
138
getName ?( ) : string ;
78
139
}
140
+
141
+
142
+ export interface StorageAdapter {
143
+ /**
144
+ * This method should return the presigned URL for the given key capable of upload.
145
+ * The PUT method should fail if the file already exists.
146
+ * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
147
+ * @param expiresIn - The expiration time in seconds for the presigned URL
148
+ */
149
+ getUploadSignedUrl ( key : string , contentType : string , expiresIn ?: number ) : Promise < string > ;
150
+
151
+ /**
152
+ * This method should return the presigned URL for the given key capable of download
153
+ * @param key - The key of the file to be downloaded e.g. "uploads/file.txt"
154
+ * @param expiresIn - The expiration time in seconds for the presigned URL
155
+ */
156
+ getDownloadSignedUrl ( key : string , expiresIn ?: number ) : Promise < string > ;
157
+
158
+ /**
159
+ * This method should mark the file for deletion.
160
+ * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
161
+ */
162
+ markKeyForDeletation ( key : string ) : Promise < string > ;
163
+
164
+
165
+ /**
166
+ * This method should return the list of files in the storage.
167
+ * @param key
168
+ */
169
+ markKeyForNotDeletation ( key : string ) : Promise < string > ;
170
+
171
+
172
+ /**
173
+ * THis method can start needed schedullers, cron jobs, etc. to clean up the storage.
174
+ */
175
+ setupLifecycle ( ) : Promise < void > ;
176
+
177
+ }
178
+
179
+
0 commit comments