Skip to content

Commit 51b0b1e

Browse files
committed
feat: add cloud extend interfaces
- added cloud ai related api - fix saas definitions for gateway
1 parent 7dc4302 commit 51b0b1e

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

types/wx/lib.wx.cloud.d.ts

+64-1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ interface WxCloud {
137137
): Promise<ICloud.ConnectContainerResult>
138138

139139
services: ICloud.CloudServices
140+
extend: ICloud.ICloudExtendServices
140141
}
141142

142143
declare namespace ICloud {
@@ -218,7 +219,7 @@ declare namespace ICloud {
218219
refresh: (session: AsyncSession<string>) => Promise<void>
219220
}
220221
interface GatewayConstructOptions {
221-
id: string
222+
id?: string
222223
appid?: string
223224
domain?: string
224225
keepalive?: boolean
@@ -234,6 +235,68 @@ declare namespace ICloud {
234235
}
235236
// === end ===
236237

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+
237300
// === API: uploadFile ===
238301
interface UploadFileResult extends IAPISuccessParam {
239302
fileID: string

0 commit comments

Comments
 (0)