@h-ai/api-contract 0.1.0-alpha.67 → 0.1.0-alpha.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +16 -0
- package/README.ja.md +16 -0
- package/README.md +16 -0
- package/dist/ai/index.d.ts +981 -200
- package/dist/ai/index.js +2 -2
- package/dist/{chunk-RVSGP2GF.js → chunk-G3SME6V5.js} +4 -5
- package/dist/chunk-G3SME6V5.js.map +1 -0
- package/dist/{chunk-VSPYX4DD.js → chunk-G55ATYDA.js} +64 -39
- package/dist/chunk-G55ATYDA.js.map +1 -0
- package/dist/{chunk-3QSKWVLP.js → chunk-IVZVAWEF.js} +30 -17
- package/dist/chunk-IVZVAWEF.js.map +1 -0
- package/dist/{chunk-CUU2F6YD.js → chunk-JKPLID6E.js} +2 -2
- package/dist/chunk-JKPLID6E.js.map +1 -0
- package/dist/{chunk-JIQINMLG.js → chunk-R5GDWFYC.js} +7 -7
- package/dist/chunk-R5GDWFYC.js.map +1 -0
- package/dist/iam/index.d.ts +845 -32
- package/dist/iam/index.js +2 -2
- package/dist/index.d.ts +196 -89
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/payment/index.d.ts +218 -28
- package/dist/payment/index.js +2 -2
- package/dist/storage/index.d.ts +414 -161
- package/dist/storage/index.js +2 -2
- package/package.json +3 -2
- package/dist/chunk-3QSKWVLP.js.map +0 -1
- package/dist/chunk-CUU2F6YD.js.map +0 -1
- package/dist/chunk-JIQINMLG.js.map +0 -1
- package/dist/chunk-RVSGP2GF.js.map +0 -1
- package/dist/chunk-VSPYX4DD.js.map +0 -1
package/dist/ai/index.d.ts
CHANGED
|
@@ -11,16 +11,47 @@ import { HaiResult } from '@h-ai/core';
|
|
|
11
11
|
* 避免 Serv 根入口为了校验可选 Audio 消息而静态加载整个 `@h-ai/ai` 包。
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* 统一语音入口的默认路径(相对 API 前缀)。
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { AUDIO_WS_PATH } from '@h-ai/api-contract'
|
|
19
|
+
*
|
|
20
|
+
* const endpoint = new URL(AUDIO_WS_PATH, 'https://api.example.com')
|
|
21
|
+
* endpoint.protocol = 'wss:'
|
|
22
|
+
* void endpoint
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
15
25
|
declare const AUDIO_WS_PATH = "/ai/audio";
|
|
16
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* 合法音频格式。
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { AudioFormatSchema } from '@h-ai/api-contract'
|
|
31
|
+
*
|
|
32
|
+
* const value = AudioFormatSchema.parse('pcm16')
|
|
33
|
+
* void value
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
17
36
|
declare const AudioFormatSchema: z.ZodEnum<{
|
|
18
37
|
pcm16: "pcm16";
|
|
19
38
|
wav: "wav";
|
|
20
39
|
mp3: "mp3";
|
|
21
40
|
opus: "opus";
|
|
22
41
|
}>;
|
|
23
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* 会话起始帧 Schema。
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { AudioWsStartMessageSchema } from '@h-ai/api-contract'
|
|
47
|
+
*
|
|
48
|
+
* const value = AudioWsStartMessageSchema.parse({
|
|
49
|
+
* type: 'start',
|
|
50
|
+
* operation: 'transcribe'
|
|
51
|
+
* })
|
|
52
|
+
* void value
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
24
55
|
declare const AudioWsStartMessageSchema: z.ZodObject<{
|
|
25
56
|
type: z.ZodLiteral<"start">;
|
|
26
57
|
operation: z.ZodEnum<{
|
|
@@ -42,17 +73,53 @@ declare const AudioWsStartMessageSchema: z.ZodObject<{
|
|
|
42
73
|
sampleRate: z.ZodOptional<z.ZodNumber>;
|
|
43
74
|
channels: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>>;
|
|
44
75
|
}, z.core.$strip>;
|
|
45
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* 文本输入帧 Schema。
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* import { AudioWsTextMessageSchema } from '@h-ai/api-contract'
|
|
81
|
+
*
|
|
82
|
+
* const value = AudioWsTextMessageSchema.parse({
|
|
83
|
+
* type: 'text',
|
|
84
|
+
* segmentId: 'example',
|
|
85
|
+
* text: 'Hello'
|
|
86
|
+
* })
|
|
87
|
+
* void value
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
46
90
|
declare const AudioWsTextMessageSchema: z.ZodObject<{
|
|
47
91
|
type: z.ZodLiteral<"text">;
|
|
48
92
|
segmentId: z.ZodString;
|
|
49
93
|
text: z.ZodString;
|
|
50
94
|
}, z.core.$strip>;
|
|
51
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* 输入结束帧 Schema。
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* import { AudioWsDoneMessageSchema } from '@h-ai/api-contract'
|
|
100
|
+
*
|
|
101
|
+
* const value = AudioWsDoneMessageSchema.parse({
|
|
102
|
+
* type: 'done'
|
|
103
|
+
* })
|
|
104
|
+
* void value
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
52
107
|
declare const AudioWsDoneMessageSchema: z.ZodObject<{
|
|
53
108
|
type: z.ZodLiteral<"done">;
|
|
54
109
|
}, z.core.$strip>;
|
|
55
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* 客户端 JSON 控制消息 Schema。
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* import { AudioWsClientMessageSchema } from '@h-ai/api-contract'
|
|
115
|
+
*
|
|
116
|
+
* const value = AudioWsClientMessageSchema.parse({
|
|
117
|
+
* type: 'start',
|
|
118
|
+
* operation: 'transcribe'
|
|
119
|
+
* })
|
|
120
|
+
* void value
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
56
123
|
declare const AudioWsClientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
57
124
|
type: z.ZodLiteral<"start">;
|
|
58
125
|
operation: z.ZodEnum<{
|
|
@@ -87,24 +154,38 @@ declare const AudioWsClientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
87
154
|
* 定义 AI 功能相关 API 的接口边界:聊天补全、记忆管理与会话管理。
|
|
88
155
|
* 聊天补全使用 OpenAI 兼容结构(`messages` 数组 + `choices` 数组)。
|
|
89
156
|
* 所有接口均需 Bearer Token 认证(由 `@h-ai/serv` 的 feature 层强制)。
|
|
157
|
+
* 默认绑定认证用户的 objectId;其它主体和会话的访问须经过服务端资源授权。
|
|
90
158
|
* @module ai-contract
|
|
91
159
|
*/
|
|
92
|
-
/**
|
|
160
|
+
/**
|
|
161
|
+
* AI 领域 oRPC contract。
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* import { apiContract } from '@h-ai/api-contract'
|
|
165
|
+
*
|
|
166
|
+
* const contract = apiContract.ai
|
|
167
|
+
* void contract
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
93
170
|
declare const aiContract: {
|
|
94
171
|
chats: {
|
|
95
172
|
createCompletion: _orpc_contract.ContractProcedureBuilderWithInputOutput<zod.ZodObject<{
|
|
173
|
+
objectId: zod.ZodOptional<zod.ZodString>;
|
|
174
|
+
sessionId: zod.ZodOptional<zod.ZodString>;
|
|
96
175
|
model: zod.ZodOptional<zod.ZodString>;
|
|
97
|
-
messages: zod.ZodArray<zod.ZodObject<{
|
|
98
|
-
role: zod.
|
|
99
|
-
|
|
100
|
-
user: "user";
|
|
101
|
-
assistant: "assistant";
|
|
102
|
-
tool: "tool";
|
|
103
|
-
}>;
|
|
104
|
-
content: zod.ZodOptional<zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
176
|
+
messages: zod.ZodArray<zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
177
|
+
role: zod.ZodLiteral<"system">;
|
|
178
|
+
content: zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodObject<{
|
|
105
179
|
type: zod.ZodLiteral<"text">;
|
|
106
180
|
text: zod.ZodString;
|
|
107
|
-
}, zod_v4_core.$
|
|
181
|
+
}, zod_v4_core.$strict>>]>;
|
|
182
|
+
name: zod.ZodOptional<zod.ZodString>;
|
|
183
|
+
}, zod_v4_core.$strict>, zod.ZodObject<{
|
|
184
|
+
role: zod.ZodLiteral<"user">;
|
|
185
|
+
content: zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
186
|
+
type: zod.ZodLiteral<"text">;
|
|
187
|
+
text: zod.ZodString;
|
|
188
|
+
}, zod_v4_core.$strict>, zod.ZodObject<{
|
|
108
189
|
type: zod.ZodLiteral<"image_url">;
|
|
109
190
|
image_url: zod.ZodObject<{
|
|
110
191
|
url: zod.ZodString;
|
|
@@ -113,8 +194,15 @@ declare const aiContract: {
|
|
|
113
194
|
low: "low";
|
|
114
195
|
high: "high";
|
|
115
196
|
}>>;
|
|
116
|
-
}, zod_v4_core.$
|
|
117
|
-
}, zod_v4_core.$
|
|
197
|
+
}, zod_v4_core.$strict>;
|
|
198
|
+
}, zod_v4_core.$strict>]>>]>;
|
|
199
|
+
name: zod.ZodOptional<zod.ZodString>;
|
|
200
|
+
}, zod_v4_core.$strict>, zod.ZodObject<{
|
|
201
|
+
role: zod.ZodLiteral<"assistant">;
|
|
202
|
+
content: zod.ZodOptional<zod.ZodNullable<zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodObject<{
|
|
203
|
+
type: zod.ZodLiteral<"text">;
|
|
204
|
+
text: zod.ZodString;
|
|
205
|
+
}, zod_v4_core.$strict>>]>>>;
|
|
118
206
|
name: zod.ZodOptional<zod.ZodString>;
|
|
119
207
|
tool_calls: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
|
|
120
208
|
id: zod.ZodString;
|
|
@@ -122,37 +210,35 @@ declare const aiContract: {
|
|
|
122
210
|
function: zod.ZodObject<{
|
|
123
211
|
name: zod.ZodString;
|
|
124
212
|
arguments: zod.ZodString;
|
|
125
|
-
}, zod_v4_core.$
|
|
126
|
-
}, zod_v4_core.$
|
|
127
|
-
|
|
128
|
-
|
|
213
|
+
}, zod_v4_core.$strict>;
|
|
214
|
+
}, zod_v4_core.$strict>>>;
|
|
215
|
+
}, zod_v4_core.$strict>, zod.ZodObject<{
|
|
216
|
+
role: zod.ZodLiteral<"tool">;
|
|
217
|
+
content: zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodObject<{
|
|
218
|
+
type: zod.ZodLiteral<"text">;
|
|
219
|
+
text: zod.ZodString;
|
|
220
|
+
}, zod_v4_core.$strict>>]>;
|
|
221
|
+
tool_call_id: zod.ZodString;
|
|
222
|
+
}, zod_v4_core.$strict>], "role">>;
|
|
129
223
|
temperature: zod.ZodOptional<zod.ZodNumber>;
|
|
130
224
|
top_p: zod.ZodOptional<zod.ZodNumber>;
|
|
131
225
|
max_tokens: zod.ZodOptional<zod.ZodNumber>;
|
|
132
|
-
stream: zod.ZodOptional<zod.ZodBoolean>;
|
|
133
226
|
tools: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
|
|
134
227
|
type: zod.ZodLiteral<"function">;
|
|
135
228
|
function: zod.ZodObject<{
|
|
136
229
|
name: zod.ZodString;
|
|
137
230
|
description: zod.ZodOptional<zod.ZodString>;
|
|
138
|
-
parameters: zod.ZodOptional<zod.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
enum: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
|
|
144
|
-
}, zod_v4_core.$strip>>>;
|
|
145
|
-
required: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
|
|
146
|
-
}, zod_v4_core.$strip>>;
|
|
147
|
-
}, zod_v4_core.$strip>;
|
|
148
|
-
}, zod_v4_core.$strip>>>;
|
|
149
|
-
tool_choice: zod.ZodOptional<zod.ZodUnion<readonly [zod.ZodLiteral<"auto">, zod.ZodLiteral<"none">, zod.ZodObject<{
|
|
231
|
+
parameters: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodJSONSchema>>;
|
|
232
|
+
strict: zod.ZodOptional<zod.ZodNullable<zod.ZodBoolean>>;
|
|
233
|
+
}, zod_v4_core.$strict>;
|
|
234
|
+
}, zod_v4_core.$strict>>>;
|
|
235
|
+
tool_choice: zod.ZodOptional<zod.ZodUnion<readonly [zod.ZodLiteral<"auto">, zod.ZodLiteral<"none">, zod.ZodLiteral<"required">, zod.ZodObject<{
|
|
150
236
|
type: zod.ZodLiteral<"function">;
|
|
151
237
|
function: zod.ZodObject<{
|
|
152
238
|
name: zod.ZodString;
|
|
153
|
-
}, zod_v4_core.$
|
|
154
|
-
}, zod_v4_core.$
|
|
155
|
-
}, zod_v4_core.$
|
|
239
|
+
}, zod_v4_core.$strict>;
|
|
240
|
+
}, zod_v4_core.$strict>]>>;
|
|
241
|
+
}, zod_v4_core.$strict>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
156
242
|
success: zod.ZodLiteral<true>;
|
|
157
243
|
data: zod.ZodObject<{
|
|
158
244
|
id: zod.ZodString;
|
|
@@ -170,8 +256,8 @@ declare const aiContract: {
|
|
|
170
256
|
function: zod.ZodObject<{
|
|
171
257
|
name: zod.ZodString;
|
|
172
258
|
arguments: zod.ZodString;
|
|
173
|
-
}, zod_v4_core.$
|
|
174
|
-
}, zod_v4_core.$
|
|
259
|
+
}, zod_v4_core.$strict>;
|
|
260
|
+
}, zod_v4_core.$strict>>>;
|
|
175
261
|
}, zod_v4_core.$strip>;
|
|
176
262
|
finish_reason: zod.ZodEnum<{
|
|
177
263
|
length: "length";
|
|
@@ -200,6 +286,8 @@ declare const aiContract: {
|
|
|
200
286
|
}, zod_v4_core.$strip>;
|
|
201
287
|
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
202
288
|
sendMessage: _orpc_contract.ContractProcedureBuilderWithInputOutput<zod.ZodObject<{
|
|
289
|
+
objectId: zod.ZodOptional<zod.ZodString>;
|
|
290
|
+
sessionId: zod.ZodOptional<zod.ZodString>;
|
|
203
291
|
message: zod.ZodString;
|
|
204
292
|
systemPrompt: zod.ZodOptional<zod.ZodString>;
|
|
205
293
|
model: zod.ZodOptional<zod.ZodString>;
|
|
@@ -229,7 +317,7 @@ declare const aiContract: {
|
|
|
229
317
|
}, zod_v4_core.$strip>;
|
|
230
318
|
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
231
319
|
listHistory: _orpc_contract.ContractProcedureBuilderWithInputOutput<zod.ZodObject<{
|
|
232
|
-
objectId: zod.ZodString
|
|
320
|
+
objectId: zod.ZodOptional<zod.ZodString>;
|
|
233
321
|
sessionId: zod.ZodString;
|
|
234
322
|
limit: zod.ZodOptional<zod.ZodNumber>;
|
|
235
323
|
order: zod.ZodOptional<zod.ZodEnum<{
|
|
@@ -245,17 +333,19 @@ declare const aiContract: {
|
|
|
245
333
|
sessionId: zod.ZodString;
|
|
246
334
|
request: zod.ZodObject<{
|
|
247
335
|
model: zod.ZodString;
|
|
248
|
-
messages: zod.ZodArray<zod.ZodObject<{
|
|
249
|
-
role: zod.
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
336
|
+
messages: zod.ZodArray<zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
337
|
+
role: zod.ZodLiteral<"system">;
|
|
338
|
+
content: zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodObject<{
|
|
339
|
+
type: zod.ZodLiteral<"text">;
|
|
340
|
+
text: zod.ZodString;
|
|
341
|
+
}, zod_v4_core.$strict>>]>;
|
|
342
|
+
name: zod.ZodOptional<zod.ZodString>;
|
|
343
|
+
}, zod_v4_core.$strict>, zod.ZodObject<{
|
|
344
|
+
role: zod.ZodLiteral<"user">;
|
|
345
|
+
content: zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
256
346
|
type: zod.ZodLiteral<"text">;
|
|
257
347
|
text: zod.ZodString;
|
|
258
|
-
}, zod_v4_core.$
|
|
348
|
+
}, zod_v4_core.$strict>, zod.ZodObject<{
|
|
259
349
|
type: zod.ZodLiteral<"image_url">;
|
|
260
350
|
image_url: zod.ZodObject<{
|
|
261
351
|
url: zod.ZodString;
|
|
@@ -264,8 +354,15 @@ declare const aiContract: {
|
|
|
264
354
|
low: "low";
|
|
265
355
|
high: "high";
|
|
266
356
|
}>>;
|
|
267
|
-
}, zod_v4_core.$
|
|
268
|
-
}, zod_v4_core.$
|
|
357
|
+
}, zod_v4_core.$strict>;
|
|
358
|
+
}, zod_v4_core.$strict>]>>]>;
|
|
359
|
+
name: zod.ZodOptional<zod.ZodString>;
|
|
360
|
+
}, zod_v4_core.$strict>, zod.ZodObject<{
|
|
361
|
+
role: zod.ZodLiteral<"assistant">;
|
|
362
|
+
content: zod.ZodOptional<zod.ZodNullable<zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodObject<{
|
|
363
|
+
type: zod.ZodLiteral<"text">;
|
|
364
|
+
text: zod.ZodString;
|
|
365
|
+
}, zod_v4_core.$strict>>]>>>;
|
|
269
366
|
name: zod.ZodOptional<zod.ZodString>;
|
|
270
367
|
tool_calls: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
|
|
271
368
|
id: zod.ZodString;
|
|
@@ -273,10 +370,16 @@ declare const aiContract: {
|
|
|
273
370
|
function: zod.ZodObject<{
|
|
274
371
|
name: zod.ZodString;
|
|
275
372
|
arguments: zod.ZodString;
|
|
276
|
-
}, zod_v4_core.$
|
|
277
|
-
}, zod_v4_core.$
|
|
278
|
-
|
|
279
|
-
|
|
373
|
+
}, zod_v4_core.$strict>;
|
|
374
|
+
}, zod_v4_core.$strict>>>;
|
|
375
|
+
}, zod_v4_core.$strict>, zod.ZodObject<{
|
|
376
|
+
role: zod.ZodLiteral<"tool">;
|
|
377
|
+
content: zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodObject<{
|
|
378
|
+
type: zod.ZodLiteral<"text">;
|
|
379
|
+
text: zod.ZodString;
|
|
380
|
+
}, zod_v4_core.$strict>>]>;
|
|
381
|
+
tool_call_id: zod.ZodString;
|
|
382
|
+
}, zod_v4_core.$strict>], "role">>;
|
|
280
383
|
}, zod_v4_core.$strip>;
|
|
281
384
|
response: zod.ZodObject<{
|
|
282
385
|
content: zod.ZodString;
|
|
@@ -286,8 +389,8 @@ declare const aiContract: {
|
|
|
286
389
|
function: zod.ZodObject<{
|
|
287
390
|
name: zod.ZodString;
|
|
288
391
|
arguments: zod.ZodString;
|
|
289
|
-
}, zod_v4_core.$
|
|
290
|
-
}, zod_v4_core.$
|
|
392
|
+
}, zod_v4_core.$strict>;
|
|
393
|
+
}, zod_v4_core.$strict>>>;
|
|
291
394
|
finishReason: zod.ZodString;
|
|
292
395
|
usage: zod.ZodObject<{
|
|
293
396
|
prompt_tokens: zod.ZodNumber;
|
|
@@ -409,7 +512,7 @@ declare const aiContract: {
|
|
|
409
512
|
};
|
|
410
513
|
sessions: {
|
|
411
514
|
list: _orpc_contract.ContractProcedureBuilderWithInputOutput<zod.ZodObject<{
|
|
412
|
-
objectId: zod.ZodString
|
|
515
|
+
objectId: zod.ZodOptional<zod.ZodString>;
|
|
413
516
|
}, zod_v4_core.$strip>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
414
517
|
success: zod.ZodLiteral<true>;
|
|
415
518
|
data: zod.ZodObject<{
|
|
@@ -436,30 +539,76 @@ declare const aiContract: {
|
|
|
436
539
|
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
437
540
|
};
|
|
438
541
|
};
|
|
542
|
+
/**
|
|
543
|
+
* ai 领域公开 procedure 契约的完整类型。
|
|
544
|
+
* @example
|
|
545
|
+
* ```ts
|
|
546
|
+
* import type { AiContract } from '@h-ai/api-contract'
|
|
547
|
+
* import { apiContract } from '@h-ai/api-contract'
|
|
548
|
+
*
|
|
549
|
+
* const contract: AiContract = apiContract.ai
|
|
550
|
+
* void contract
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
439
553
|
type AiContract = typeof aiContract;
|
|
440
554
|
|
|
441
555
|
/**
|
|
442
556
|
* @h-ai/api-contract — AI 领域 Schema
|
|
443
557
|
*
|
|
444
558
|
* 包含聊天补全、消息占位、记忆召回与历史会话相关的 input/output Zod Schema。
|
|
445
|
-
*
|
|
559
|
+
* 默认聊天补全为非流式 JSON,支持 function tool calling;未声明字段在边界拒绝。
|
|
446
560
|
* 仅保留跨接口、跨层复用的数据结构;一次性输出包装在 contract 中内联。
|
|
447
561
|
* @module ai-schemas
|
|
448
562
|
*/
|
|
449
563
|
|
|
450
|
-
/**
|
|
564
|
+
/**
|
|
565
|
+
* 消息角色 Schema。
|
|
566
|
+
* @example
|
|
567
|
+
* ```ts
|
|
568
|
+
* import { AiMessageRoleSchema } from '@h-ai/api-contract'
|
|
569
|
+
*
|
|
570
|
+
* const value = AiMessageRoleSchema.parse('system')
|
|
571
|
+
* void value
|
|
572
|
+
* ```
|
|
573
|
+
*/
|
|
451
574
|
declare const AiMessageRoleSchema: z.ZodEnum<{
|
|
452
575
|
system: "system";
|
|
453
576
|
user: "user";
|
|
454
577
|
assistant: "assistant";
|
|
455
578
|
tool: "tool";
|
|
456
579
|
}>;
|
|
457
|
-
/**
|
|
580
|
+
/**
|
|
581
|
+
* 文本内容 Schema。
|
|
582
|
+
* @example
|
|
583
|
+
* ```ts
|
|
584
|
+
* import { AiTextContentSchema } from '@h-ai/api-contract'
|
|
585
|
+
*
|
|
586
|
+
* const value = AiTextContentSchema.parse({
|
|
587
|
+
* type: 'text',
|
|
588
|
+
* text: 'Hello'
|
|
589
|
+
* })
|
|
590
|
+
* void value
|
|
591
|
+
* ```
|
|
592
|
+
*/
|
|
458
593
|
declare const AiTextContentSchema: z.ZodObject<{
|
|
459
594
|
type: z.ZodLiteral<"text">;
|
|
460
595
|
text: z.ZodString;
|
|
461
|
-
}, z.core.$
|
|
462
|
-
/**
|
|
596
|
+
}, z.core.$strict>;
|
|
597
|
+
/**
|
|
598
|
+
* 图片内容 Schema。
|
|
599
|
+
* @example
|
|
600
|
+
* ```ts
|
|
601
|
+
* import { AiImageContentSchema } from '@h-ai/api-contract'
|
|
602
|
+
*
|
|
603
|
+
* const value = AiImageContentSchema.parse({
|
|
604
|
+
* type: 'image_url',
|
|
605
|
+
* image_url: {
|
|
606
|
+
* url: 'https://example.com/resource'
|
|
607
|
+
* }
|
|
608
|
+
* })
|
|
609
|
+
* void value
|
|
610
|
+
* ```
|
|
611
|
+
*/
|
|
463
612
|
declare const AiImageContentSchema: z.ZodObject<{
|
|
464
613
|
type: z.ZodLiteral<"image_url">;
|
|
465
614
|
image_url: z.ZodObject<{
|
|
@@ -469,13 +618,22 @@ declare const AiImageContentSchema: z.ZodObject<{
|
|
|
469
618
|
low: "low";
|
|
470
619
|
high: "high";
|
|
471
620
|
}>>;
|
|
472
|
-
}, z.core.$
|
|
473
|
-
}, z.core.$
|
|
474
|
-
/**
|
|
621
|
+
}, z.core.$strict>;
|
|
622
|
+
}, z.core.$strict>;
|
|
623
|
+
/**
|
|
624
|
+
* 消息内容 Schema。
|
|
625
|
+
* @example
|
|
626
|
+
* ```ts
|
|
627
|
+
* import { AiMessageContentSchema } from '@h-ai/api-contract'
|
|
628
|
+
*
|
|
629
|
+
* const value = AiMessageContentSchema.parse('example')
|
|
630
|
+
* void value
|
|
631
|
+
* ```
|
|
632
|
+
*/
|
|
475
633
|
declare const AiMessageContentSchema: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
476
634
|
type: z.ZodLiteral<"text">;
|
|
477
635
|
text: z.ZodString;
|
|
478
|
-
}, z.core.$
|
|
636
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
479
637
|
type: z.ZodLiteral<"image_url">;
|
|
480
638
|
image_url: z.ZodObject<{
|
|
481
639
|
url: z.ZodString;
|
|
@@ -484,29 +642,59 @@ declare const AiMessageContentSchema: z.ZodUnion<readonly [z.ZodString, z.ZodArr
|
|
|
484
642
|
low: "low";
|
|
485
643
|
high: "high";
|
|
486
644
|
}>>;
|
|
487
|
-
}, z.core.$
|
|
488
|
-
}, z.core.$
|
|
489
|
-
/**
|
|
645
|
+
}, z.core.$strict>;
|
|
646
|
+
}, z.core.$strict>]>>]>;
|
|
647
|
+
/**
|
|
648
|
+
* 工具调用 Schema。
|
|
649
|
+
* @example
|
|
650
|
+
* ```ts
|
|
651
|
+
* import { AiToolCallSchema } from '@h-ai/api-contract'
|
|
652
|
+
*
|
|
653
|
+
* const value = AiToolCallSchema.parse({
|
|
654
|
+
* id: 'call_1',
|
|
655
|
+
* type: 'function',
|
|
656
|
+
* function: {
|
|
657
|
+
* name: 'lookupOrder',
|
|
658
|
+
* arguments: '{\'id\':\'order_1\'}'
|
|
659
|
+
* }
|
|
660
|
+
* })
|
|
661
|
+
* void value
|
|
662
|
+
* ```
|
|
663
|
+
*/
|
|
490
664
|
declare const AiToolCallSchema: z.ZodObject<{
|
|
491
665
|
id: z.ZodString;
|
|
492
666
|
type: z.ZodLiteral<"function">;
|
|
493
667
|
function: z.ZodObject<{
|
|
494
668
|
name: z.ZodString;
|
|
495
669
|
arguments: z.ZodString;
|
|
496
|
-
}, z.core.$
|
|
497
|
-
}, z.core.$
|
|
498
|
-
/**
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
670
|
+
}, z.core.$strict>;
|
|
671
|
+
}, z.core.$strict>;
|
|
672
|
+
/**
|
|
673
|
+
* 按角色校验聊天消息;工具结果必须携带非空 tool_call_id。
|
|
674
|
+
* @example
|
|
675
|
+
* ```ts
|
|
676
|
+
* import { AiChatMessageSchema } from '@h-ai/api-contract'
|
|
677
|
+
*
|
|
678
|
+
* const value = AiChatMessageSchema.parse({
|
|
679
|
+
* role: 'system',
|
|
680
|
+
* content: 'Hello'
|
|
681
|
+
* })
|
|
682
|
+
* void value
|
|
683
|
+
* ```
|
|
684
|
+
*/
|
|
685
|
+
declare const AiChatMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
686
|
+
role: z.ZodLiteral<"system">;
|
|
687
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
688
|
+
type: z.ZodLiteral<"text">;
|
|
689
|
+
text: z.ZodString;
|
|
690
|
+
}, z.core.$strict>>]>;
|
|
691
|
+
name: z.ZodOptional<z.ZodString>;
|
|
692
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
693
|
+
role: z.ZodLiteral<"user">;
|
|
694
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
507
695
|
type: z.ZodLiteral<"text">;
|
|
508
696
|
text: z.ZodString;
|
|
509
|
-
}, z.core.$
|
|
697
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
510
698
|
type: z.ZodLiteral<"image_url">;
|
|
511
699
|
image_url: z.ZodObject<{
|
|
512
700
|
url: z.ZodString;
|
|
@@ -515,8 +703,15 @@ declare const AiChatMessageSchema: z.ZodObject<{
|
|
|
515
703
|
low: "low";
|
|
516
704
|
high: "high";
|
|
517
705
|
}>>;
|
|
518
|
-
}, z.core.$
|
|
519
|
-
}, z.core.$
|
|
706
|
+
}, z.core.$strict>;
|
|
707
|
+
}, z.core.$strict>]>>]>;
|
|
708
|
+
name: z.ZodOptional<z.ZodString>;
|
|
709
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
710
|
+
role: z.ZodLiteral<"assistant">;
|
|
711
|
+
content: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
712
|
+
type: z.ZodLiteral<"text">;
|
|
713
|
+
text: z.ZodString;
|
|
714
|
+
}, z.core.$strict>>]>>>;
|
|
520
715
|
name: z.ZodOptional<z.ZodString>;
|
|
521
716
|
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
522
717
|
id: z.ZodString;
|
|
@@ -524,47 +719,86 @@ declare const AiChatMessageSchema: z.ZodObject<{
|
|
|
524
719
|
function: z.ZodObject<{
|
|
525
720
|
name: z.ZodString;
|
|
526
721
|
arguments: z.ZodString;
|
|
527
|
-
}, z.core.$
|
|
528
|
-
}, z.core.$
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
}, z.core.$
|
|
537
|
-
/**
|
|
722
|
+
}, z.core.$strict>;
|
|
723
|
+
}, z.core.$strict>>>;
|
|
724
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
725
|
+
role: z.ZodLiteral<"tool">;
|
|
726
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
727
|
+
type: z.ZodLiteral<"text">;
|
|
728
|
+
text: z.ZodString;
|
|
729
|
+
}, z.core.$strict>>]>;
|
|
730
|
+
tool_call_id: z.ZodString;
|
|
731
|
+
}, z.core.$strict>], "role">;
|
|
732
|
+
/**
|
|
733
|
+
* 完整的 function 工具定义;parameters 保留嵌套 JSON Schema,不裁剪其关键字。
|
|
734
|
+
* @example
|
|
735
|
+
* ```ts
|
|
736
|
+
* import { AiToolDefinitionSchema } from '@h-ai/api-contract'
|
|
737
|
+
*
|
|
738
|
+
* const value = AiToolDefinitionSchema.parse({
|
|
739
|
+
* type: 'function',
|
|
740
|
+
* function: {
|
|
741
|
+
* name: 'lookupOrder',
|
|
742
|
+
* description: 'Look up an order',
|
|
743
|
+
* parameters: {
|
|
744
|
+
* type: 'object',
|
|
745
|
+
* properties: {
|
|
746
|
+
* id: {
|
|
747
|
+
* type: 'string'
|
|
748
|
+
* }
|
|
749
|
+
* },
|
|
750
|
+
* required: [
|
|
751
|
+
* 'id'
|
|
752
|
+
* ]
|
|
753
|
+
* }
|
|
754
|
+
* }
|
|
755
|
+
* })
|
|
756
|
+
* void value
|
|
757
|
+
* ```
|
|
758
|
+
*/
|
|
538
759
|
declare const AiToolDefinitionSchema: z.ZodObject<{
|
|
539
760
|
type: z.ZodLiteral<"function">;
|
|
540
761
|
function: z.ZodObject<{
|
|
541
762
|
name: z.ZodString;
|
|
542
763
|
description: z.ZodOptional<z.ZodString>;
|
|
543
|
-
parameters: z.ZodOptional<z.
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
764
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
765
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
766
|
+
}, z.core.$strict>;
|
|
767
|
+
}, z.core.$strict>;
|
|
768
|
+
/**
|
|
769
|
+
* 非流式聊天补全入参;stream 等未声明字段明确拒绝。
|
|
770
|
+
* @example
|
|
771
|
+
* ```ts
|
|
772
|
+
* import { AiChatCompletionInputSchema } from '@h-ai/api-contract'
|
|
773
|
+
*
|
|
774
|
+
* const value = AiChatCompletionInputSchema.parse({
|
|
775
|
+
* messages: [
|
|
776
|
+
* {
|
|
777
|
+
* role: 'user',
|
|
778
|
+
* content: 'Say hello'
|
|
779
|
+
* }
|
|
780
|
+
* ]
|
|
781
|
+
* })
|
|
782
|
+
* void value
|
|
783
|
+
* ```
|
|
784
|
+
*/
|
|
555
785
|
declare const AiChatCompletionInputSchema: z.ZodObject<{
|
|
786
|
+
objectId: z.ZodOptional<z.ZodString>;
|
|
787
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
556
788
|
model: z.ZodOptional<z.ZodString>;
|
|
557
|
-
messages: z.ZodArray<z.ZodObject<{
|
|
558
|
-
role: z.
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
789
|
+
messages: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
790
|
+
role: z.ZodLiteral<"system">;
|
|
791
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
792
|
+
type: z.ZodLiteral<"text">;
|
|
793
|
+
text: z.ZodString;
|
|
794
|
+
}, z.core.$strict>>]>;
|
|
795
|
+
name: z.ZodOptional<z.ZodString>;
|
|
796
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
797
|
+
role: z.ZodLiteral<"user">;
|
|
798
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
565
799
|
type: z.ZodLiteral<"text">;
|
|
566
800
|
text: z.ZodString;
|
|
567
|
-
}, z.core.$
|
|
801
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
568
802
|
type: z.ZodLiteral<"image_url">;
|
|
569
803
|
image_url: z.ZodObject<{
|
|
570
804
|
url: z.ZodString;
|
|
@@ -573,8 +807,15 @@ declare const AiChatCompletionInputSchema: z.ZodObject<{
|
|
|
573
807
|
low: "low";
|
|
574
808
|
high: "high";
|
|
575
809
|
}>>;
|
|
576
|
-
}, z.core.$
|
|
577
|
-
}, z.core.$
|
|
810
|
+
}, z.core.$strict>;
|
|
811
|
+
}, z.core.$strict>]>>]>;
|
|
812
|
+
name: z.ZodOptional<z.ZodString>;
|
|
813
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
814
|
+
role: z.ZodLiteral<"assistant">;
|
|
815
|
+
content: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
816
|
+
type: z.ZodLiteral<"text">;
|
|
817
|
+
text: z.ZodString;
|
|
818
|
+
}, z.core.$strict>>]>>>;
|
|
578
819
|
name: z.ZodOptional<z.ZodString>;
|
|
579
820
|
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
580
821
|
id: z.ZodString;
|
|
@@ -582,44 +823,67 @@ declare const AiChatCompletionInputSchema: z.ZodObject<{
|
|
|
582
823
|
function: z.ZodObject<{
|
|
583
824
|
name: z.ZodString;
|
|
584
825
|
arguments: z.ZodString;
|
|
585
|
-
}, z.core.$
|
|
586
|
-
}, z.core.$
|
|
587
|
-
|
|
588
|
-
|
|
826
|
+
}, z.core.$strict>;
|
|
827
|
+
}, z.core.$strict>>>;
|
|
828
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
829
|
+
role: z.ZodLiteral<"tool">;
|
|
830
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
831
|
+
type: z.ZodLiteral<"text">;
|
|
832
|
+
text: z.ZodString;
|
|
833
|
+
}, z.core.$strict>>]>;
|
|
834
|
+
tool_call_id: z.ZodString;
|
|
835
|
+
}, z.core.$strict>], "role">>;
|
|
589
836
|
temperature: z.ZodOptional<z.ZodNumber>;
|
|
590
837
|
top_p: z.ZodOptional<z.ZodNumber>;
|
|
591
838
|
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
592
|
-
stream: z.ZodOptional<z.ZodBoolean>;
|
|
593
839
|
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
594
840
|
type: z.ZodLiteral<"function">;
|
|
595
841
|
function: z.ZodObject<{
|
|
596
842
|
name: z.ZodString;
|
|
597
843
|
description: z.ZodOptional<z.ZodString>;
|
|
598
|
-
parameters: z.ZodOptional<z.
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
enum: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
604
|
-
}, z.core.$strip>>>;
|
|
605
|
-
required: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
606
|
-
}, z.core.$strip>>;
|
|
607
|
-
}, z.core.$strip>;
|
|
608
|
-
}, z.core.$strip>>>;
|
|
609
|
-
tool_choice: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodObject<{
|
|
844
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
845
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
846
|
+
}, z.core.$strict>;
|
|
847
|
+
}, z.core.$strict>>>;
|
|
848
|
+
tool_choice: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{
|
|
610
849
|
type: z.ZodLiteral<"function">;
|
|
611
850
|
function: z.ZodObject<{
|
|
612
851
|
name: z.ZodString;
|
|
613
|
-
}, z.core.$
|
|
614
|
-
}, z.core.$
|
|
615
|
-
}, z.core.$
|
|
616
|
-
/**
|
|
852
|
+
}, z.core.$strict>;
|
|
853
|
+
}, z.core.$strict>]>>;
|
|
854
|
+
}, z.core.$strict>;
|
|
855
|
+
/**
|
|
856
|
+
* Token 使用统计 Schema。
|
|
857
|
+
* @example
|
|
858
|
+
* ```ts
|
|
859
|
+
* import { AiTokenUsageSchema } from '@h-ai/api-contract'
|
|
860
|
+
*
|
|
861
|
+
* const value = AiTokenUsageSchema.parse({
|
|
862
|
+
* prompt_tokens: 0,
|
|
863
|
+
* completion_tokens: 0,
|
|
864
|
+
* total_tokens: 0
|
|
865
|
+
* })
|
|
866
|
+
* void value
|
|
867
|
+
* ```
|
|
868
|
+
*/
|
|
617
869
|
declare const AiTokenUsageSchema: z.ZodObject<{
|
|
618
870
|
prompt_tokens: z.ZodNumber;
|
|
619
871
|
completion_tokens: z.ZodNumber;
|
|
620
872
|
total_tokens: z.ZodNumber;
|
|
621
873
|
}, z.core.$strip>;
|
|
622
|
-
/**
|
|
874
|
+
/**
|
|
875
|
+
* 助手消息 Schema。
|
|
876
|
+
* @example
|
|
877
|
+
* ```ts
|
|
878
|
+
* import { AiAssistantMessageSchema } from '@h-ai/api-contract'
|
|
879
|
+
*
|
|
880
|
+
* const value = AiAssistantMessageSchema.parse({
|
|
881
|
+
* role: 'assistant',
|
|
882
|
+
* content: 'Hello'
|
|
883
|
+
* })
|
|
884
|
+
* void value
|
|
885
|
+
* ```
|
|
886
|
+
*/
|
|
623
887
|
declare const AiAssistantMessageSchema: z.ZodObject<{
|
|
624
888
|
role: z.ZodLiteral<"assistant">;
|
|
625
889
|
content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -629,10 +893,26 @@ declare const AiAssistantMessageSchema: z.ZodObject<{
|
|
|
629
893
|
function: z.ZodObject<{
|
|
630
894
|
name: z.ZodString;
|
|
631
895
|
arguments: z.ZodString;
|
|
632
|
-
}, z.core.$
|
|
633
|
-
}, z.core.$
|
|
896
|
+
}, z.core.$strict>;
|
|
897
|
+
}, z.core.$strict>>>;
|
|
634
898
|
}, z.core.$strip>;
|
|
635
|
-
/**
|
|
899
|
+
/**
|
|
900
|
+
* 聊天完成选择 Schema。
|
|
901
|
+
* @example
|
|
902
|
+
* ```ts
|
|
903
|
+
* import { AiChatCompletionChoiceSchema } from '@h-ai/api-contract'
|
|
904
|
+
*
|
|
905
|
+
* const value = AiChatCompletionChoiceSchema.parse({
|
|
906
|
+
* index: 0,
|
|
907
|
+
* message: {
|
|
908
|
+
* role: 'assistant',
|
|
909
|
+
* content: 'Hello'
|
|
910
|
+
* },
|
|
911
|
+
* finish_reason: 'stop'
|
|
912
|
+
* })
|
|
913
|
+
* void value
|
|
914
|
+
* ```
|
|
915
|
+
*/
|
|
636
916
|
declare const AiChatCompletionChoiceSchema: z.ZodObject<{
|
|
637
917
|
index: z.ZodNumber;
|
|
638
918
|
message: z.ZodObject<{
|
|
@@ -644,8 +924,8 @@ declare const AiChatCompletionChoiceSchema: z.ZodObject<{
|
|
|
644
924
|
function: z.ZodObject<{
|
|
645
925
|
name: z.ZodString;
|
|
646
926
|
arguments: z.ZodString;
|
|
647
|
-
}, z.core.$
|
|
648
|
-
}, z.core.$
|
|
927
|
+
}, z.core.$strict>;
|
|
928
|
+
}, z.core.$strict>>>;
|
|
649
929
|
}, z.core.$strip>;
|
|
650
930
|
finish_reason: z.ZodEnum<{
|
|
651
931
|
length: "length";
|
|
@@ -654,7 +934,36 @@ declare const AiChatCompletionChoiceSchema: z.ZodObject<{
|
|
|
654
934
|
content_filter: "content_filter";
|
|
655
935
|
}>;
|
|
656
936
|
}, z.core.$strip>;
|
|
657
|
-
/**
|
|
937
|
+
/**
|
|
938
|
+
* 聊天完成业务数据 Schema。
|
|
939
|
+
* @example
|
|
940
|
+
* ```ts
|
|
941
|
+
* import { AiChatCompletionDataSchema } from '@h-ai/api-contract'
|
|
942
|
+
*
|
|
943
|
+
* const value = AiChatCompletionDataSchema.parse({
|
|
944
|
+
* id: 'example-1',
|
|
945
|
+
* object: 'chat.completion',
|
|
946
|
+
* created: 0,
|
|
947
|
+
* model: 'example',
|
|
948
|
+
* choices: [
|
|
949
|
+
* {
|
|
950
|
+
* index: 0,
|
|
951
|
+
* message: {
|
|
952
|
+
* role: 'assistant',
|
|
953
|
+
* content: 'Hello'
|
|
954
|
+
* },
|
|
955
|
+
* finish_reason: 'stop'
|
|
956
|
+
* }
|
|
957
|
+
* ],
|
|
958
|
+
* usage: {
|
|
959
|
+
* prompt_tokens: 0,
|
|
960
|
+
* completion_tokens: 0,
|
|
961
|
+
* total_tokens: 0
|
|
962
|
+
* }
|
|
963
|
+
* })
|
|
964
|
+
* void value
|
|
965
|
+
* ```
|
|
966
|
+
*/
|
|
658
967
|
declare const AiChatCompletionDataSchema: z.ZodObject<{
|
|
659
968
|
id: z.ZodString;
|
|
660
969
|
object: z.ZodLiteral<"chat.completion">;
|
|
@@ -671,8 +980,8 @@ declare const AiChatCompletionDataSchema: z.ZodObject<{
|
|
|
671
980
|
function: z.ZodObject<{
|
|
672
981
|
name: z.ZodString;
|
|
673
982
|
arguments: z.ZodString;
|
|
674
|
-
}, z.core.$
|
|
675
|
-
}, z.core.$
|
|
983
|
+
}, z.core.$strict>;
|
|
984
|
+
}, z.core.$strict>>>;
|
|
676
985
|
}, z.core.$strip>;
|
|
677
986
|
finish_reason: z.ZodEnum<{
|
|
678
987
|
length: "length";
|
|
@@ -687,14 +996,39 @@ declare const AiChatCompletionDataSchema: z.ZodObject<{
|
|
|
687
996
|
total_tokens: z.ZodNumber;
|
|
688
997
|
}, z.core.$strip>;
|
|
689
998
|
}, z.core.$strip>;
|
|
690
|
-
/**
|
|
999
|
+
/**
|
|
1000
|
+
* 简单消息入参 Schema。
|
|
1001
|
+
* @example
|
|
1002
|
+
* ```ts
|
|
1003
|
+
* import { AiSendMessageInputSchema } from '@h-ai/api-contract'
|
|
1004
|
+
*
|
|
1005
|
+
* const value = AiSendMessageInputSchema.parse({
|
|
1006
|
+
* message: 'example'
|
|
1007
|
+
* })
|
|
1008
|
+
* void value
|
|
1009
|
+
* ```
|
|
1010
|
+
*/
|
|
691
1011
|
declare const AiSendMessageInputSchema: z.ZodObject<{
|
|
1012
|
+
objectId: z.ZodOptional<z.ZodString>;
|
|
1013
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
692
1014
|
message: z.ZodString;
|
|
693
1015
|
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
694
1016
|
model: z.ZodOptional<z.ZodString>;
|
|
695
1017
|
temperature: z.ZodOptional<z.ZodNumber>;
|
|
696
1018
|
}, z.core.$strip>;
|
|
697
|
-
/**
|
|
1019
|
+
/**
|
|
1020
|
+
* 简单消息业务数据 Schema。
|
|
1021
|
+
* @example
|
|
1022
|
+
* ```ts
|
|
1023
|
+
* import { AiSendMessageDataSchema } from '@h-ai/api-contract'
|
|
1024
|
+
*
|
|
1025
|
+
* const value = AiSendMessageDataSchema.parse({
|
|
1026
|
+
* content: 'Hello',
|
|
1027
|
+
* model: 'example'
|
|
1028
|
+
* })
|
|
1029
|
+
* void value
|
|
1030
|
+
* ```
|
|
1031
|
+
*/
|
|
698
1032
|
declare const AiSendMessageDataSchema: z.ZodObject<{
|
|
699
1033
|
content: z.ZodString;
|
|
700
1034
|
model: z.ZodString;
|
|
@@ -704,7 +1038,16 @@ declare const AiSendMessageDataSchema: z.ZodObject<{
|
|
|
704
1038
|
total_tokens: z.ZodNumber;
|
|
705
1039
|
}, z.core.$strip>>;
|
|
706
1040
|
}, z.core.$strip>;
|
|
707
|
-
/**
|
|
1041
|
+
/**
|
|
1042
|
+
* 记忆类型 Schema。
|
|
1043
|
+
* @example
|
|
1044
|
+
* ```ts
|
|
1045
|
+
* import { AiMemoryTypeSchema } from '@h-ai/api-contract'
|
|
1046
|
+
*
|
|
1047
|
+
* const value = AiMemoryTypeSchema.parse('fact')
|
|
1048
|
+
* void value
|
|
1049
|
+
* ```
|
|
1050
|
+
*/
|
|
708
1051
|
declare const AiMemoryTypeSchema: z.ZodEnum<{
|
|
709
1052
|
instruction: "instruction";
|
|
710
1053
|
fact: "fact";
|
|
@@ -712,7 +1055,24 @@ declare const AiMemoryTypeSchema: z.ZodEnum<{
|
|
|
712
1055
|
event: "event";
|
|
713
1056
|
entity: "entity";
|
|
714
1057
|
}>;
|
|
715
|
-
/**
|
|
1058
|
+
/**
|
|
1059
|
+
* 记忆条目 Schema。
|
|
1060
|
+
* @example
|
|
1061
|
+
* ```ts
|
|
1062
|
+
* import { AiMemoryEntrySchema } from '@h-ai/api-contract'
|
|
1063
|
+
*
|
|
1064
|
+
* const value = AiMemoryEntrySchema.parse({
|
|
1065
|
+
* id: 'example-1',
|
|
1066
|
+
* content: 'Hello',
|
|
1067
|
+
* type: 'fact',
|
|
1068
|
+
* importance: 0,
|
|
1069
|
+
* createdAt: 0,
|
|
1070
|
+
* lastAccessedAt: 0,
|
|
1071
|
+
* accessCount: 0
|
|
1072
|
+
* })
|
|
1073
|
+
* void value
|
|
1074
|
+
* ```
|
|
1075
|
+
*/
|
|
716
1076
|
declare const AiMemoryEntrySchema: z.ZodObject<{
|
|
717
1077
|
id: z.ZodString;
|
|
718
1078
|
content: z.ZodString;
|
|
@@ -730,7 +1090,18 @@ declare const AiMemoryEntrySchema: z.ZodObject<{
|
|
|
730
1090
|
lastAccessedAt: z.ZodNumber;
|
|
731
1091
|
accessCount: z.ZodNumber;
|
|
732
1092
|
}, z.core.$strip>;
|
|
733
|
-
/**
|
|
1093
|
+
/**
|
|
1094
|
+
* 记忆检索入参 Schema。
|
|
1095
|
+
* @example
|
|
1096
|
+
* ```ts
|
|
1097
|
+
* import { AiMemoryRecallInputSchema } from '@h-ai/api-contract'
|
|
1098
|
+
*
|
|
1099
|
+
* const value = AiMemoryRecallInputSchema.parse({
|
|
1100
|
+
* query: 'example'
|
|
1101
|
+
* })
|
|
1102
|
+
* void value
|
|
1103
|
+
* ```
|
|
1104
|
+
*/
|
|
734
1105
|
declare const AiMemoryRecallInputSchema: z.ZodObject<{
|
|
735
1106
|
query: z.ZodString;
|
|
736
1107
|
topK: z.ZodOptional<z.ZodNumber>;
|
|
@@ -744,7 +1115,28 @@ declare const AiMemoryRecallInputSchema: z.ZodObject<{
|
|
|
744
1115
|
minImportance: z.ZodOptional<z.ZodNumber>;
|
|
745
1116
|
objectId: z.ZodOptional<z.ZodString>;
|
|
746
1117
|
}, z.core.$strip>;
|
|
747
|
-
/**
|
|
1118
|
+
/**
|
|
1119
|
+
* 记忆检索业务数据 Schema。
|
|
1120
|
+
* @example
|
|
1121
|
+
* ```ts
|
|
1122
|
+
* import { AiMemoryRecallDataSchema } from '@h-ai/api-contract'
|
|
1123
|
+
*
|
|
1124
|
+
* const value = AiMemoryRecallDataSchema.parse({
|
|
1125
|
+
* items: [
|
|
1126
|
+
* {
|
|
1127
|
+
* id: 'example-1',
|
|
1128
|
+
* content: 'Hello',
|
|
1129
|
+
* type: 'fact',
|
|
1130
|
+
* importance: 0,
|
|
1131
|
+
* createdAt: 0,
|
|
1132
|
+
* lastAccessedAt: 0,
|
|
1133
|
+
* accessCount: 0
|
|
1134
|
+
* }
|
|
1135
|
+
* ]
|
|
1136
|
+
* })
|
|
1137
|
+
* void value
|
|
1138
|
+
* ```
|
|
1139
|
+
*/
|
|
748
1140
|
declare const AiMemoryRecallDataSchema: z.ZodObject<{
|
|
749
1141
|
items: z.ZodArray<z.ZodObject<{
|
|
750
1142
|
id: z.ZodString;
|
|
@@ -764,7 +1156,16 @@ declare const AiMemoryRecallDataSchema: z.ZodObject<{
|
|
|
764
1156
|
accessCount: z.ZodNumber;
|
|
765
1157
|
}, z.core.$strip>>;
|
|
766
1158
|
}, z.core.$strip>;
|
|
767
|
-
/**
|
|
1159
|
+
/**
|
|
1160
|
+
* 记忆列表入参 Schema。
|
|
1161
|
+
* @example
|
|
1162
|
+
* ```ts
|
|
1163
|
+
* import { AiMemoryListInputSchema } from '@h-ai/api-contract'
|
|
1164
|
+
*
|
|
1165
|
+
* const value = AiMemoryListInputSchema.parse({})
|
|
1166
|
+
* void value
|
|
1167
|
+
* ```
|
|
1168
|
+
*/
|
|
768
1169
|
declare const AiMemoryListInputSchema: z.ZodObject<{
|
|
769
1170
|
types: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
770
1171
|
instruction: "instruction";
|
|
@@ -777,7 +1178,29 @@ declare const AiMemoryListInputSchema: z.ZodObject<{
|
|
|
777
1178
|
offset: z.ZodOptional<z.ZodNumber>;
|
|
778
1179
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
779
1180
|
}, z.core.$strip>;
|
|
780
|
-
/**
|
|
1181
|
+
/**
|
|
1182
|
+
* 记忆列表业务数据 Schema。
|
|
1183
|
+
* @example
|
|
1184
|
+
* ```ts
|
|
1185
|
+
* import { AiMemoryListDataSchema } from '@h-ai/api-contract'
|
|
1186
|
+
*
|
|
1187
|
+
* const value = AiMemoryListDataSchema.parse({
|
|
1188
|
+
* items: [
|
|
1189
|
+
* {
|
|
1190
|
+
* id: 'example-1',
|
|
1191
|
+
* content: 'Hello',
|
|
1192
|
+
* type: 'fact',
|
|
1193
|
+
* importance: 0,
|
|
1194
|
+
* createdAt: 0,
|
|
1195
|
+
* lastAccessedAt: 0,
|
|
1196
|
+
* accessCount: 0
|
|
1197
|
+
* }
|
|
1198
|
+
* ],
|
|
1199
|
+
* total: 0
|
|
1200
|
+
* })
|
|
1201
|
+
* void value
|
|
1202
|
+
* ```
|
|
1203
|
+
*/
|
|
781
1204
|
declare const AiMemoryListDataSchema: z.ZodObject<{
|
|
782
1205
|
items: z.ZodArray<z.ZodObject<{
|
|
783
1206
|
id: z.ZodString;
|
|
@@ -798,7 +1221,21 @@ declare const AiMemoryListDataSchema: z.ZodObject<{
|
|
|
798
1221
|
}, z.core.$strip>>;
|
|
799
1222
|
total: z.ZodNumber;
|
|
800
1223
|
}, z.core.$strip>;
|
|
801
|
-
/**
|
|
1224
|
+
/**
|
|
1225
|
+
* 会话信息 Schema。
|
|
1226
|
+
* @example
|
|
1227
|
+
* ```ts
|
|
1228
|
+
* import { AiSessionInfoSchema } from '@h-ai/api-contract'
|
|
1229
|
+
*
|
|
1230
|
+
* const value = AiSessionInfoSchema.parse({
|
|
1231
|
+
* objectId: 'example',
|
|
1232
|
+
* sessionId: 'example',
|
|
1233
|
+
* createdAt: 0,
|
|
1234
|
+
* updatedAt: 0
|
|
1235
|
+
* })
|
|
1236
|
+
* void value
|
|
1237
|
+
* ```
|
|
1238
|
+
*/
|
|
802
1239
|
declare const AiSessionInfoSchema: z.ZodObject<{
|
|
803
1240
|
objectId: z.ZodString;
|
|
804
1241
|
sessionId: z.ZodString;
|
|
@@ -806,11 +1243,38 @@ declare const AiSessionInfoSchema: z.ZodObject<{
|
|
|
806
1243
|
updatedAt: z.ZodNumber;
|
|
807
1244
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
808
1245
|
}, z.core.$strip>;
|
|
809
|
-
/**
|
|
1246
|
+
/**
|
|
1247
|
+
* 会话列表入参 Schema。
|
|
1248
|
+
* @example
|
|
1249
|
+
* ```ts
|
|
1250
|
+
* import { AiSessionListInputSchema } from '@h-ai/api-contract'
|
|
1251
|
+
*
|
|
1252
|
+
* const value = AiSessionListInputSchema.parse({})
|
|
1253
|
+
* void value
|
|
1254
|
+
* ```
|
|
1255
|
+
*/
|
|
810
1256
|
declare const AiSessionListInputSchema: z.ZodObject<{
|
|
811
|
-
objectId: z.ZodString
|
|
1257
|
+
objectId: z.ZodOptional<z.ZodString>;
|
|
812
1258
|
}, z.core.$strip>;
|
|
813
|
-
/**
|
|
1259
|
+
/**
|
|
1260
|
+
* 会话列表业务数据 Schema。
|
|
1261
|
+
* @example
|
|
1262
|
+
* ```ts
|
|
1263
|
+
* import { AiSessionListDataSchema } from '@h-ai/api-contract'
|
|
1264
|
+
*
|
|
1265
|
+
* const value = AiSessionListDataSchema.parse({
|
|
1266
|
+
* items: [
|
|
1267
|
+
* {
|
|
1268
|
+
* objectId: 'example',
|
|
1269
|
+
* sessionId: 'example',
|
|
1270
|
+
* createdAt: 0,
|
|
1271
|
+
* updatedAt: 0
|
|
1272
|
+
* }
|
|
1273
|
+
* ]
|
|
1274
|
+
* })
|
|
1275
|
+
* void value
|
|
1276
|
+
* ```
|
|
1277
|
+
*/
|
|
814
1278
|
declare const AiSessionListDataSchema: z.ZodObject<{
|
|
815
1279
|
items: z.ZodArray<z.ZodObject<{
|
|
816
1280
|
objectId: z.ZodString;
|
|
@@ -820,24 +1284,59 @@ declare const AiSessionListDataSchema: z.ZodObject<{
|
|
|
820
1284
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
821
1285
|
}, z.core.$strip>>;
|
|
822
1286
|
}, z.core.$strip>;
|
|
823
|
-
/**
|
|
1287
|
+
/**
|
|
1288
|
+
* 对话记录 Schema。
|
|
1289
|
+
* @example
|
|
1290
|
+
* ```ts
|
|
1291
|
+
* import { AiChatRecordSchema } from '@h-ai/api-contract'
|
|
1292
|
+
*
|
|
1293
|
+
* const value = AiChatRecordSchema.parse({
|
|
1294
|
+
* id: 'example-1',
|
|
1295
|
+
* objectId: 'example',
|
|
1296
|
+
* sessionId: 'example',
|
|
1297
|
+
* request: {
|
|
1298
|
+
* model: 'example',
|
|
1299
|
+
* messages: [
|
|
1300
|
+
* {
|
|
1301
|
+
* role: 'system',
|
|
1302
|
+
* content: 'Hello'
|
|
1303
|
+
* }
|
|
1304
|
+
* ]
|
|
1305
|
+
* },
|
|
1306
|
+
* response: {
|
|
1307
|
+
* content: 'Hello',
|
|
1308
|
+
* finishReason: 'example',
|
|
1309
|
+
* usage: {
|
|
1310
|
+
* prompt_tokens: 0,
|
|
1311
|
+
* completion_tokens: 0,
|
|
1312
|
+
* total_tokens: 0
|
|
1313
|
+
* }
|
|
1314
|
+
* },
|
|
1315
|
+
* createdAt: 0,
|
|
1316
|
+
* duration: 0
|
|
1317
|
+
* })
|
|
1318
|
+
* void value
|
|
1319
|
+
* ```
|
|
1320
|
+
*/
|
|
824
1321
|
declare const AiChatRecordSchema: z.ZodObject<{
|
|
825
1322
|
id: z.ZodString;
|
|
826
1323
|
objectId: z.ZodString;
|
|
827
1324
|
sessionId: z.ZodString;
|
|
828
1325
|
request: z.ZodObject<{
|
|
829
1326
|
model: z.ZodString;
|
|
830
|
-
messages: z.ZodArray<z.ZodObject<{
|
|
831
|
-
role: z.
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
1327
|
+
messages: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1328
|
+
role: z.ZodLiteral<"system">;
|
|
1329
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
1330
|
+
type: z.ZodLiteral<"text">;
|
|
1331
|
+
text: z.ZodString;
|
|
1332
|
+
}, z.core.$strict>>]>;
|
|
1333
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1334
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1335
|
+
role: z.ZodLiteral<"user">;
|
|
1336
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
838
1337
|
type: z.ZodLiteral<"text">;
|
|
839
1338
|
text: z.ZodString;
|
|
840
|
-
}, z.core.$
|
|
1339
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
841
1340
|
type: z.ZodLiteral<"image_url">;
|
|
842
1341
|
image_url: z.ZodObject<{
|
|
843
1342
|
url: z.ZodString;
|
|
@@ -846,8 +1345,15 @@ declare const AiChatRecordSchema: z.ZodObject<{
|
|
|
846
1345
|
low: "low";
|
|
847
1346
|
high: "high";
|
|
848
1347
|
}>>;
|
|
849
|
-
}, z.core.$
|
|
850
|
-
}, z.core.$
|
|
1348
|
+
}, z.core.$strict>;
|
|
1349
|
+
}, z.core.$strict>]>>]>;
|
|
1350
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1351
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1352
|
+
role: z.ZodLiteral<"assistant">;
|
|
1353
|
+
content: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
1354
|
+
type: z.ZodLiteral<"text">;
|
|
1355
|
+
text: z.ZodString;
|
|
1356
|
+
}, z.core.$strict>>]>>>;
|
|
851
1357
|
name: z.ZodOptional<z.ZodString>;
|
|
852
1358
|
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
853
1359
|
id: z.ZodString;
|
|
@@ -855,10 +1361,16 @@ declare const AiChatRecordSchema: z.ZodObject<{
|
|
|
855
1361
|
function: z.ZodObject<{
|
|
856
1362
|
name: z.ZodString;
|
|
857
1363
|
arguments: z.ZodString;
|
|
858
|
-
}, z.core.$
|
|
859
|
-
}, z.core.$
|
|
860
|
-
|
|
861
|
-
|
|
1364
|
+
}, z.core.$strict>;
|
|
1365
|
+
}, z.core.$strict>>>;
|
|
1366
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1367
|
+
role: z.ZodLiteral<"tool">;
|
|
1368
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
1369
|
+
type: z.ZodLiteral<"text">;
|
|
1370
|
+
text: z.ZodString;
|
|
1371
|
+
}, z.core.$strict>>]>;
|
|
1372
|
+
tool_call_id: z.ZodString;
|
|
1373
|
+
}, z.core.$strict>], "role">>;
|
|
862
1374
|
}, z.core.$strip>;
|
|
863
1375
|
response: z.ZodObject<{
|
|
864
1376
|
content: z.ZodString;
|
|
@@ -868,8 +1380,8 @@ declare const AiChatRecordSchema: z.ZodObject<{
|
|
|
868
1380
|
function: z.ZodObject<{
|
|
869
1381
|
name: z.ZodString;
|
|
870
1382
|
arguments: z.ZodString;
|
|
871
|
-
}, z.core.$
|
|
872
|
-
}, z.core.$
|
|
1383
|
+
}, z.core.$strict>;
|
|
1384
|
+
}, z.core.$strict>>>;
|
|
873
1385
|
finishReason: z.ZodString;
|
|
874
1386
|
usage: z.ZodObject<{
|
|
875
1387
|
prompt_tokens: z.ZodNumber;
|
|
@@ -880,9 +1392,20 @@ declare const AiChatRecordSchema: z.ZodObject<{
|
|
|
880
1392
|
createdAt: z.ZodNumber;
|
|
881
1393
|
duration: z.ZodNumber;
|
|
882
1394
|
}, z.core.$strip>;
|
|
883
|
-
/**
|
|
1395
|
+
/**
|
|
1396
|
+
* 对话历史入参 Schema。
|
|
1397
|
+
* @example
|
|
1398
|
+
* ```ts
|
|
1399
|
+
* import { AiChatHistoryInputSchema } from '@h-ai/api-contract'
|
|
1400
|
+
*
|
|
1401
|
+
* const value = AiChatHistoryInputSchema.parse({
|
|
1402
|
+
* sessionId: 'example'
|
|
1403
|
+
* })
|
|
1404
|
+
* void value
|
|
1405
|
+
* ```
|
|
1406
|
+
*/
|
|
884
1407
|
declare const AiChatHistoryInputSchema: z.ZodObject<{
|
|
885
|
-
objectId: z.ZodString
|
|
1408
|
+
objectId: z.ZodOptional<z.ZodString>;
|
|
886
1409
|
sessionId: z.ZodString;
|
|
887
1410
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
888
1411
|
order: z.ZodOptional<z.ZodEnum<{
|
|
@@ -890,7 +1413,44 @@ declare const AiChatHistoryInputSchema: z.ZodObject<{
|
|
|
890
1413
|
desc: "desc";
|
|
891
1414
|
}>>;
|
|
892
1415
|
}, z.core.$strip>;
|
|
893
|
-
/**
|
|
1416
|
+
/**
|
|
1417
|
+
* 对话历史业务数据 Schema。
|
|
1418
|
+
* @example
|
|
1419
|
+
* ```ts
|
|
1420
|
+
* import { AiChatHistoryDataSchema } from '@h-ai/api-contract'
|
|
1421
|
+
*
|
|
1422
|
+
* const value = AiChatHistoryDataSchema.parse({
|
|
1423
|
+
* items: [
|
|
1424
|
+
* {
|
|
1425
|
+
* id: 'example-1',
|
|
1426
|
+
* objectId: 'example',
|
|
1427
|
+
* sessionId: 'example',
|
|
1428
|
+
* request: {
|
|
1429
|
+
* model: 'example',
|
|
1430
|
+
* messages: [
|
|
1431
|
+
* {
|
|
1432
|
+
* role: 'system',
|
|
1433
|
+
* content: 'Hello'
|
|
1434
|
+
* }
|
|
1435
|
+
* ]
|
|
1436
|
+
* },
|
|
1437
|
+
* response: {
|
|
1438
|
+
* content: 'Hello',
|
|
1439
|
+
* finishReason: 'example',
|
|
1440
|
+
* usage: {
|
|
1441
|
+
* prompt_tokens: 0,
|
|
1442
|
+
* completion_tokens: 0,
|
|
1443
|
+
* total_tokens: 0
|
|
1444
|
+
* }
|
|
1445
|
+
* },
|
|
1446
|
+
* createdAt: 0,
|
|
1447
|
+
* duration: 0
|
|
1448
|
+
* }
|
|
1449
|
+
* ]
|
|
1450
|
+
* })
|
|
1451
|
+
* void value
|
|
1452
|
+
* ```
|
|
1453
|
+
*/
|
|
894
1454
|
declare const AiChatHistoryDataSchema: z.ZodObject<{
|
|
895
1455
|
items: z.ZodArray<z.ZodObject<{
|
|
896
1456
|
id: z.ZodString;
|
|
@@ -898,17 +1458,19 @@ declare const AiChatHistoryDataSchema: z.ZodObject<{
|
|
|
898
1458
|
sessionId: z.ZodString;
|
|
899
1459
|
request: z.ZodObject<{
|
|
900
1460
|
model: z.ZodString;
|
|
901
|
-
messages: z.ZodArray<z.ZodObject<{
|
|
902
|
-
role: z.
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
1461
|
+
messages: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1462
|
+
role: z.ZodLiteral<"system">;
|
|
1463
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
1464
|
+
type: z.ZodLiteral<"text">;
|
|
1465
|
+
text: z.ZodString;
|
|
1466
|
+
}, z.core.$strict>>]>;
|
|
1467
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1468
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1469
|
+
role: z.ZodLiteral<"user">;
|
|
1470
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
909
1471
|
type: z.ZodLiteral<"text">;
|
|
910
1472
|
text: z.ZodString;
|
|
911
|
-
}, z.core.$
|
|
1473
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
912
1474
|
type: z.ZodLiteral<"image_url">;
|
|
913
1475
|
image_url: z.ZodObject<{
|
|
914
1476
|
url: z.ZodString;
|
|
@@ -917,8 +1479,15 @@ declare const AiChatHistoryDataSchema: z.ZodObject<{
|
|
|
917
1479
|
low: "low";
|
|
918
1480
|
high: "high";
|
|
919
1481
|
}>>;
|
|
920
|
-
}, z.core.$
|
|
921
|
-
}, z.core.$
|
|
1482
|
+
}, z.core.$strict>;
|
|
1483
|
+
}, z.core.$strict>]>>]>;
|
|
1484
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1485
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1486
|
+
role: z.ZodLiteral<"assistant">;
|
|
1487
|
+
content: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
1488
|
+
type: z.ZodLiteral<"text">;
|
|
1489
|
+
text: z.ZodString;
|
|
1490
|
+
}, z.core.$strict>>]>>>;
|
|
922
1491
|
name: z.ZodOptional<z.ZodString>;
|
|
923
1492
|
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
924
1493
|
id: z.ZodString;
|
|
@@ -926,10 +1495,16 @@ declare const AiChatHistoryDataSchema: z.ZodObject<{
|
|
|
926
1495
|
function: z.ZodObject<{
|
|
927
1496
|
name: z.ZodString;
|
|
928
1497
|
arguments: z.ZodString;
|
|
929
|
-
}, z.core.$
|
|
930
|
-
}, z.core.$
|
|
931
|
-
|
|
932
|
-
|
|
1498
|
+
}, z.core.$strict>;
|
|
1499
|
+
}, z.core.$strict>>>;
|
|
1500
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1501
|
+
role: z.ZodLiteral<"tool">;
|
|
1502
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
1503
|
+
type: z.ZodLiteral<"text">;
|
|
1504
|
+
text: z.ZodString;
|
|
1505
|
+
}, z.core.$strict>>]>;
|
|
1506
|
+
tool_call_id: z.ZodString;
|
|
1507
|
+
}, z.core.$strict>], "role">>;
|
|
933
1508
|
}, z.core.$strip>;
|
|
934
1509
|
response: z.ZodObject<{
|
|
935
1510
|
content: z.ZodString;
|
|
@@ -939,8 +1514,8 @@ declare const AiChatHistoryDataSchema: z.ZodObject<{
|
|
|
939
1514
|
function: z.ZodObject<{
|
|
940
1515
|
name: z.ZodString;
|
|
941
1516
|
arguments: z.ZodString;
|
|
942
|
-
}, z.core.$
|
|
943
|
-
}, z.core.$
|
|
1517
|
+
}, z.core.$strict>;
|
|
1518
|
+
}, z.core.$strict>>>;
|
|
944
1519
|
finishReason: z.ZodString;
|
|
945
1520
|
usage: z.ZodObject<{
|
|
946
1521
|
prompt_tokens: z.ZodNumber;
|
|
@@ -952,16 +1527,222 @@ declare const AiChatHistoryDataSchema: z.ZodObject<{
|
|
|
952
1527
|
duration: z.ZodNumber;
|
|
953
1528
|
}, z.core.$strip>>;
|
|
954
1529
|
}, z.core.$strip>;
|
|
1530
|
+
/**
|
|
1531
|
+
* 聊天补全请求,含消息、模型和生成参数。
|
|
1532
|
+
* @example
|
|
1533
|
+
* ```ts
|
|
1534
|
+
* import type { AiChatCompletionInput } from '@h-ai/api-contract'
|
|
1535
|
+
* import { AiChatCompletionInputSchema } from '@h-ai/api-contract'
|
|
1536
|
+
*
|
|
1537
|
+
* const value: AiChatCompletionInput = AiChatCompletionInputSchema.parse({
|
|
1538
|
+
* messages: [
|
|
1539
|
+
* {
|
|
1540
|
+
* role: 'user',
|
|
1541
|
+
* content: 'Say hello'
|
|
1542
|
+
* }
|
|
1543
|
+
* ]
|
|
1544
|
+
* })
|
|
1545
|
+
* void value
|
|
1546
|
+
* ```
|
|
1547
|
+
*/
|
|
955
1548
|
type AiChatCompletionInput = z.infer<typeof AiChatCompletionInputSchema>;
|
|
1549
|
+
/**
|
|
1550
|
+
* 聊天补全业务数据,含候选消息与用量。
|
|
1551
|
+
* @example
|
|
1552
|
+
* ```ts
|
|
1553
|
+
* import type { AiChatCompletionData } from '@h-ai/api-contract'
|
|
1554
|
+
* import { AiChatCompletionDataSchema } from '@h-ai/api-contract'
|
|
1555
|
+
*
|
|
1556
|
+
* const value: AiChatCompletionData = AiChatCompletionDataSchema.parse({
|
|
1557
|
+
* id: 'example-1',
|
|
1558
|
+
* object: 'chat.completion',
|
|
1559
|
+
* created: 0,
|
|
1560
|
+
* model: 'example',
|
|
1561
|
+
* choices: [
|
|
1562
|
+
* {
|
|
1563
|
+
* index: 0,
|
|
1564
|
+
* message: {
|
|
1565
|
+
* role: 'assistant',
|
|
1566
|
+
* content: 'Hello'
|
|
1567
|
+
* },
|
|
1568
|
+
* finish_reason: 'stop'
|
|
1569
|
+
* }
|
|
1570
|
+
* ],
|
|
1571
|
+
* usage: {
|
|
1572
|
+
* prompt_tokens: 0,
|
|
1573
|
+
* completion_tokens: 0,
|
|
1574
|
+
* total_tokens: 0
|
|
1575
|
+
* }
|
|
1576
|
+
* })
|
|
1577
|
+
* void value
|
|
1578
|
+
* ```
|
|
1579
|
+
*/
|
|
956
1580
|
type AiChatCompletionData = z.infer<typeof AiChatCompletionDataSchema>;
|
|
1581
|
+
/**
|
|
1582
|
+
* 以 HaiResult 区分成功业务数据和公共错误的 AiChatCompletionOutput 响应。
|
|
1583
|
+
* @example
|
|
1584
|
+
* ```ts
|
|
1585
|
+
* import type { AiChatCompletionOutput } from '@h-ai/api-contract'
|
|
1586
|
+
* import { AiChatCompletionDataSchema } from '@h-ai/api-contract'
|
|
1587
|
+
* import { ok } from '@h-ai/core'
|
|
1588
|
+
*
|
|
1589
|
+
* const response: AiChatCompletionOutput = ok(AiChatCompletionDataSchema.parse({
|
|
1590
|
+
* id: 'example-1',
|
|
1591
|
+
* object: 'chat.completion',
|
|
1592
|
+
* created: 0,
|
|
1593
|
+
* model: 'example',
|
|
1594
|
+
* choices: [
|
|
1595
|
+
* {
|
|
1596
|
+
* index: 0,
|
|
1597
|
+
* message: {
|
|
1598
|
+
* role: 'assistant',
|
|
1599
|
+
* content: 'Hello'
|
|
1600
|
+
* },
|
|
1601
|
+
* finish_reason: 'stop'
|
|
1602
|
+
* }
|
|
1603
|
+
* ],
|
|
1604
|
+
* usage: {
|
|
1605
|
+
* prompt_tokens: 0,
|
|
1606
|
+
* completion_tokens: 0,
|
|
1607
|
+
* total_tokens: 0
|
|
1608
|
+
* }
|
|
1609
|
+
* }))
|
|
1610
|
+
* if (response.success) void response.data
|
|
1611
|
+
* ```
|
|
1612
|
+
*/
|
|
957
1613
|
type AiChatCompletionOutput = HaiResult<AiChatCompletionData>;
|
|
1614
|
+
/**
|
|
1615
|
+
* 会话消息发送请求。
|
|
1616
|
+
* @example
|
|
1617
|
+
* ```ts
|
|
1618
|
+
* import type { AiSendMessageInput } from '@h-ai/api-contract'
|
|
1619
|
+
* import { AiSendMessageInputSchema } from '@h-ai/api-contract'
|
|
1620
|
+
*
|
|
1621
|
+
* const value: AiSendMessageInput = AiSendMessageInputSchema.parse({
|
|
1622
|
+
* message: 'example'
|
|
1623
|
+
* })
|
|
1624
|
+
* void value
|
|
1625
|
+
* ```
|
|
1626
|
+
*/
|
|
958
1627
|
type AiSendMessageInput = z.infer<typeof AiSendMessageInputSchema>;
|
|
1628
|
+
/**
|
|
1629
|
+
* 会话消息写入后的业务数据。
|
|
1630
|
+
* @example
|
|
1631
|
+
* ```ts
|
|
1632
|
+
* import type { AiSendMessageData } from '@h-ai/api-contract'
|
|
1633
|
+
* import { AiSendMessageDataSchema } from '@h-ai/api-contract'
|
|
1634
|
+
*
|
|
1635
|
+
* const value: AiSendMessageData = AiSendMessageDataSchema.parse({
|
|
1636
|
+
* content: 'Hello',
|
|
1637
|
+
* model: 'example'
|
|
1638
|
+
* })
|
|
1639
|
+
* void value
|
|
1640
|
+
* ```
|
|
1641
|
+
*/
|
|
959
1642
|
type AiSendMessageData = z.infer<typeof AiSendMessageDataSchema>;
|
|
1643
|
+
/**
|
|
1644
|
+
* 以 HaiResult 区分成功业务数据和公共错误的 AiSendMessageOutput 响应。
|
|
1645
|
+
* @example
|
|
1646
|
+
* ```ts
|
|
1647
|
+
* import type { AiSendMessageOutput } from '@h-ai/api-contract'
|
|
1648
|
+
* import { AiSendMessageDataSchema } from '@h-ai/api-contract'
|
|
1649
|
+
* import { ok } from '@h-ai/core'
|
|
1650
|
+
*
|
|
1651
|
+
* const response: AiSendMessageOutput = ok(AiSendMessageDataSchema.parse({
|
|
1652
|
+
* content: 'Hello',
|
|
1653
|
+
* model: 'example'
|
|
1654
|
+
* }))
|
|
1655
|
+
* if (response.success) void response.data
|
|
1656
|
+
* ```
|
|
1657
|
+
*/
|
|
960
1658
|
type AiSendMessageOutput = HaiResult<AiSendMessageData>;
|
|
1659
|
+
/**
|
|
1660
|
+
* 按主体和条件检索记忆的请求。
|
|
1661
|
+
* @example
|
|
1662
|
+
* ```ts
|
|
1663
|
+
* import type { AiMemoryRecallInput } from '@h-ai/api-contract'
|
|
1664
|
+
* import { AiMemoryRecallInputSchema } from '@h-ai/api-contract'
|
|
1665
|
+
*
|
|
1666
|
+
* const value: AiMemoryRecallInput = AiMemoryRecallInputSchema.parse({
|
|
1667
|
+
* query: 'example'
|
|
1668
|
+
* })
|
|
1669
|
+
* void value
|
|
1670
|
+
* ```
|
|
1671
|
+
*/
|
|
961
1672
|
type AiMemoryRecallInput = z.infer<typeof AiMemoryRecallInputSchema>;
|
|
1673
|
+
/**
|
|
1674
|
+
* 按主体查询记忆列表的分页请求。
|
|
1675
|
+
* @example
|
|
1676
|
+
* ```ts
|
|
1677
|
+
* import type { AiMemoryListInput } from '@h-ai/api-contract'
|
|
1678
|
+
* import { AiMemoryListInputSchema } from '@h-ai/api-contract'
|
|
1679
|
+
*
|
|
1680
|
+
* const value: AiMemoryListInput = AiMemoryListInputSchema.parse({})
|
|
1681
|
+
* void value
|
|
1682
|
+
* ```
|
|
1683
|
+
*/
|
|
962
1684
|
type AiMemoryListInput = z.infer<typeof AiMemoryListInputSchema>;
|
|
1685
|
+
/**
|
|
1686
|
+
* 按主体列出会话的分页请求。
|
|
1687
|
+
* @example
|
|
1688
|
+
* ```ts
|
|
1689
|
+
* import type { AiSessionListInput } from '@h-ai/api-contract'
|
|
1690
|
+
* import { AiSessionListInputSchema } from '@h-ai/api-contract'
|
|
1691
|
+
*
|
|
1692
|
+
* const value: AiSessionListInput = AiSessionListInputSchema.parse({})
|
|
1693
|
+
* void value
|
|
1694
|
+
* ```
|
|
1695
|
+
*/
|
|
963
1696
|
type AiSessionListInput = z.infer<typeof AiSessionListInputSchema>;
|
|
1697
|
+
/**
|
|
1698
|
+
* 读取指定会话历史的请求。
|
|
1699
|
+
* @example
|
|
1700
|
+
* ```ts
|
|
1701
|
+
* import type { AiChatHistoryInput } from '@h-ai/api-contract'
|
|
1702
|
+
* import { AiChatHistoryInputSchema } from '@h-ai/api-contract'
|
|
1703
|
+
*
|
|
1704
|
+
* const value: AiChatHistoryInput = AiChatHistoryInputSchema.parse({
|
|
1705
|
+
* sessionId: 'example'
|
|
1706
|
+
* })
|
|
1707
|
+
* void value
|
|
1708
|
+
* ```
|
|
1709
|
+
*/
|
|
964
1710
|
type AiChatHistoryInput = z.infer<typeof AiChatHistoryInputSchema>;
|
|
1711
|
+
/**
|
|
1712
|
+
* 会话持久化消息记录。
|
|
1713
|
+
* @example
|
|
1714
|
+
* ```ts
|
|
1715
|
+
* import type { AiChatRecord } from '@h-ai/api-contract'
|
|
1716
|
+
* import { AiChatRecordSchema } from '@h-ai/api-contract'
|
|
1717
|
+
*
|
|
1718
|
+
* const value: AiChatRecord = AiChatRecordSchema.parse({
|
|
1719
|
+
* id: 'example-1',
|
|
1720
|
+
* objectId: 'example',
|
|
1721
|
+
* sessionId: 'example',
|
|
1722
|
+
* request: {
|
|
1723
|
+
* model: 'example',
|
|
1724
|
+
* messages: [
|
|
1725
|
+
* {
|
|
1726
|
+
* role: 'system',
|
|
1727
|
+
* content: 'Hello'
|
|
1728
|
+
* }
|
|
1729
|
+
* ]
|
|
1730
|
+
* },
|
|
1731
|
+
* response: {
|
|
1732
|
+
* content: 'Hello',
|
|
1733
|
+
* finishReason: 'example',
|
|
1734
|
+
* usage: {
|
|
1735
|
+
* prompt_tokens: 0,
|
|
1736
|
+
* completion_tokens: 0,
|
|
1737
|
+
* total_tokens: 0
|
|
1738
|
+
* }
|
|
1739
|
+
* },
|
|
1740
|
+
* createdAt: 0,
|
|
1741
|
+
* duration: 0
|
|
1742
|
+
* })
|
|
1743
|
+
* void value
|
|
1744
|
+
* ```
|
|
1745
|
+
*/
|
|
965
1746
|
type AiChatRecord = z.infer<typeof AiChatRecordSchema>;
|
|
966
1747
|
|
|
967
|
-
export { AUDIO_WS_PATH, AiAssistantMessageSchema, AiChatCompletionChoiceSchema, type AiChatCompletionData, AiChatCompletionDataSchema, type AiChatCompletionInput, AiChatCompletionInputSchema, type AiChatCompletionOutput, AiChatHistoryDataSchema, type AiChatHistoryInput, AiChatHistoryInputSchema, AiChatMessageSchema, type AiChatRecord, AiChatRecordSchema, type AiContract, AiImageContentSchema, AiMemoryEntrySchema, AiMemoryListDataSchema, type AiMemoryListInput, AiMemoryListInputSchema, AiMemoryRecallDataSchema, type AiMemoryRecallInput, AiMemoryRecallInputSchema, AiMemoryTypeSchema, AiMessageContentSchema, AiMessageRoleSchema, type AiSendMessageData, AiSendMessageDataSchema, type AiSendMessageInput, AiSendMessageInputSchema, type AiSendMessageOutput, AiSessionInfoSchema, AiSessionListDataSchema, type AiSessionListInput, AiSessionListInputSchema, AiTextContentSchema, AiTokenUsageSchema, AiToolCallSchema, AiToolDefinitionSchema,
|
|
1748
|
+
export { AUDIO_WS_PATH, AiAssistantMessageSchema, AiChatCompletionChoiceSchema, type AiChatCompletionData, AiChatCompletionDataSchema, type AiChatCompletionInput, AiChatCompletionInputSchema, type AiChatCompletionOutput, AiChatHistoryDataSchema, type AiChatHistoryInput, AiChatHistoryInputSchema, AiChatMessageSchema, type AiChatRecord, AiChatRecordSchema, type AiContract, AiImageContentSchema, AiMemoryEntrySchema, AiMemoryListDataSchema, type AiMemoryListInput, AiMemoryListInputSchema, AiMemoryRecallDataSchema, type AiMemoryRecallInput, AiMemoryRecallInputSchema, AiMemoryTypeSchema, AiMessageContentSchema, AiMessageRoleSchema, type AiSendMessageData, AiSendMessageDataSchema, type AiSendMessageInput, AiSendMessageInputSchema, type AiSendMessageOutput, AiSessionInfoSchema, AiSessionListDataSchema, type AiSessionListInput, AiSessionListInputSchema, AiTextContentSchema, AiTokenUsageSchema, AiToolCallSchema, AiToolDefinitionSchema, AudioFormatSchema, AudioWsClientMessageSchema, AudioWsDoneMessageSchema, AudioWsStartMessageSchema, AudioWsTextMessageSchema, aiContract };
|