@@ -20,6 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
20
SOFTWARE.
21
21
***************************************************************************** */
22
22
23
+ /// <reference lib="es2018.asynciterable" />
24
+
23
25
/**
24
26
* Common interfaces and types
25
27
*/
@@ -137,6 +139,7 @@ interface WxCloud {
137
139
) : Promise < ICloud . ConnectContainerResult >
138
140
139
141
services : ICloud . CloudServices
142
+ extend : ICloud . ICloudExtendServices
140
143
}
141
144
142
145
declare namespace ICloud {
@@ -218,7 +221,7 @@ declare namespace ICloud {
218
221
refresh : ( session : AsyncSession < string > ) => Promise < void >
219
222
}
220
223
interface GatewayConstructOptions {
221
- id : string
224
+ id ? : string
222
225
appid ?: string
223
226
domain ?: string
224
227
keepalive ?: boolean
@@ -234,6 +237,70 @@ declare namespace ICloud {
234
237
}
235
238
// === end ===
236
239
240
+ // === API: extend ===
241
+ interface ICloudExtendServices {
242
+ AI : ICloudAI
243
+ }
244
+ interface ICloudAI {
245
+ createModel : ( modelName : string ) => ICloudAIModel
246
+ bot : ICloudBot
247
+ }
248
+ interface ICloudAICallbackOptions {
249
+ onEvent ?: ( ev : ICloudAIEvent ) => void
250
+ onText ?: ( text : string ) => void
251
+ onFinish ?: ( text : string ) => void
252
+ }
253
+ interface ICloudBot {
254
+ get : ( { botId : string } : any) => any
255
+ list : ( data : any ) => any
256
+ create : ( data : any ) => any
257
+ update : ( data : any ) => any
258
+ delete : ( data : any ) => any
259
+ getChatRecords : ( data : any ) => any
260
+ sendFeedback : ( data : any ) => any
261
+ getFeedBack : ( data : any ) => any
262
+ getRecommendQuestions : ( options : ICloudAICallbackOptions & ICloudBotOptions ) => Promise < ICloudAIStreamResult >
263
+ sendMessage : ( options : ICloudAICallbackOptions & ICloudBotOptions ) => Promise < ICloudAIStreamResult >
264
+ }
265
+
266
+ interface ICloudBotOptions { data : any , botId : string , timeout ?: number }
267
+ interface ICloudAIModel {
268
+ streamText : ( opts : ICloudAIOptions & ICloudAICallbackOptions ) => Promise < ICloudAIStreamResult >
269
+ generateText : ( opts : ICloudAIOptions & ICloudAICallbackOptions ) => Promise < string >
270
+ }
271
+ interface ICloudAIChatMessage {
272
+ role : 'user' | 'assistant' | string
273
+ content : string
274
+ }
275
+ interface ICloudAIChatModelInput {
276
+ model : string
277
+ messages : ICloudAIChatMessage [ ]
278
+ temperature ?: number
279
+ top_p ?: number
280
+ }
281
+ interface ICloudAIOptions {
282
+ data : ICloudAIChatModelInput
283
+ }
284
+ interface ICloudAIEvent {
285
+ event : string
286
+ id : string
287
+ data : string
288
+ json ?: any
289
+ }
290
+
291
+ interface AsyncIterator < T > {
292
+ next ( value ?: any ) : Promise < IteratorResult < T > >
293
+ return ?( value ?: any ) : Promise < IteratorResult < T > >
294
+ throw ?( e ?: any ) : Promise < IteratorResult < T > >
295
+ [ Symbol . asyncIterator ] ( ) : AsyncIterableIterator < T >
296
+ }
297
+ interface ICloudAIStreamResult {
298
+ textStream : AsyncIterator < string >
299
+ eventStream : AsyncIterator < ICloudAIEvent >
300
+ abort ?: ( ) => void
301
+ }
302
+ // === end ===
303
+
237
304
// === API: uploadFile ===
238
305
interface UploadFileResult extends IAPISuccessParam {
239
306
fileID : string
0 commit comments