diff --git a/types/wx/lib.wx.cloud.d.ts b/types/wx/lib.wx.cloud.d.ts
index 0eb620f..d452f05 100644
--- a/types/wx/lib.wx.cloud.d.ts
+++ b/types/wx/lib.wx.cloud.d.ts
@@ -20,6 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
***************************************************************************** */
+///
+
/**
* Common interfaces and types
*/
@@ -137,6 +139,7 @@ interface WxCloud {
): Promise
services: ICloud.CloudServices
+ extend: ICloud.ICloudExtendServices
}
declare namespace ICloud {
@@ -218,7 +221,7 @@ declare namespace ICloud {
refresh: (session: AsyncSession) => Promise
}
interface GatewayConstructOptions {
- id: string
+ id?: string
appid?: string
domain?: string
keepalive?: boolean
@@ -234,6 +237,70 @@ declare namespace ICloud {
}
// === end ===
+ // === API: extend ===
+ interface ICloudExtendServices {
+ AI: ICloudAI
+ }
+ interface ICloudAI {
+ createModel: (modelName: string) => ICloudAIModel
+ bot: ICloudBot
+ }
+ interface ICloudAICallbackOptions {
+ onEvent?: (ev: ICloudAIEvent) => void
+ onText?: (text: string) => void
+ onFinish?: (text: string) => void
+ }
+ interface ICloudBot {
+ get: ({ botId: string }: any) => any
+ list: (data: any) => any
+ create: (data: any) => any
+ update: (data: any) => any
+ delete: (data: any) => any
+ getChatRecords: (data: any) => any
+ sendFeedback: (data: any) => any
+ getFeedBack: (data: any) => any
+ getRecommendQuestions: (options: ICloudAICallbackOptions & ICloudBotOptions) => Promise
+ sendMessage: (options: ICloudAICallbackOptions & ICloudBotOptions) => Promise
+ }
+
+ interface ICloudBotOptions { data: any, botId: string, timeout?: number }
+ interface ICloudAIModel {
+ streamText: (opts: ICloudAIOptions & ICloudAICallbackOptions) => Promise
+ generateText: (opts: ICloudAIOptions & ICloudAICallbackOptions) => Promise
+ }
+ interface ICloudAIChatMessage {
+ role: 'user' | 'assistant' | string
+ content: string
+ }
+ interface ICloudAIChatModelInput {
+ model: string
+ messages: ICloudAIChatMessage[]
+ temperature?: number
+ top_p?: number
+ }
+ interface ICloudAIOptions{
+ data: ICloudAIChatModelInput
+ }
+ interface ICloudAIEvent {
+ event: string
+ id: string
+ data: string
+ json?: any
+ }
+
+ interface AsyncIterator {
+ next(value?: any): Promise>
+ return?(value?: any): Promise>
+ throw?(e?: any): Promise>
+ [Symbol.asyncIterator](): AsyncIterableIterator
+ }
+ interface ICloudAIStreamResult {
+ textStream: AsyncIterator
+ eventStream: AsyncIterator
+ abort?: () => void
+ }
+ // === end ===
+
// === API: uploadFile ===
interface UploadFileResult extends IAPISuccessParam {
fileID: string