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