@weisiren000/oiiai 0.2.0 → 0.2.2

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.md CHANGED
@@ -9,7 +9,7 @@
9
9
  [![License](https://img.shields.io/badge/License-MIT-yellow?style=flat-square)](LICENSE)
10
10
  [![npm](https://img.shields.io/npm/v/@weisiren000/oiiai?style=flat-square&color=CB3837&logo=npm)](https://www.npmjs.com/package/@weisiren000/oiiai)
11
11
 
12
- 支持 **OpenRouter** · **Gemini** · **Groq** · **HuggingFace** · **ModelScope** · **DeepSeek** · **Poe** · **Nova**
12
+ 支持 **OpenRouter** · **Gemini** · **Groq** · **HuggingFace** · **ModelScope** · **DeepSeek** · **Poe** · **Nova** · **Zhipu** · **SiliconFlow**
13
13
 
14
14
  [📖 详细文档](./docs/providers.md) · [🚀 快速开始](#快速开始) · [💡 示例](#使用示例) · [🔗 Fluent API](#-fluent-api-新)
15
15
 
@@ -95,7 +95,14 @@ const provider = createProvider({
95
95
  预配置的 Provider 实例,开箱即用:
96
96
 
97
97
  ```typescript
98
- import { deepseek, openrouter, gemini, groq } from '@weisiren000/oiiai';
98
+ import {
99
+ deepseek,
100
+ openrouter,
101
+ gemini,
102
+ groq,
103
+ zhipu,
104
+ siliconflow,
105
+ } from '@weisiren000/oiiai';
99
106
 
100
107
  // 配置 API Key(二选一)
101
108
  deepseek.configure({ apiKey: 'your-key' }); // 显式配置
@@ -186,6 +193,79 @@ const answer = await builder
186
193
  .ask('写一首关于春天的诗');
187
194
  ```
188
195
 
196
+ ### 多模态支持
197
+
198
+ Fluent API 链式构建器原生支持多模态输入(图像、视频、音频),提供简洁的链式调用接口:
199
+
200
+ ```typescript
201
+ import { oiiai, siliconflow } from '@weisiren000/oiiai';
202
+
203
+ // 配置
204
+ siliconflow.configure({ apiKey: 'your-key' });
205
+
206
+ // 图像分析
207
+ const answer = await oiiai
208
+ .use('siliconflow')
209
+ .key('your-key')
210
+ .model('Qwen/Qwen2.5-VL-72B-Instruct')
211
+ .image('https://example.com/image.jpg', { detail: 'high' })
212
+ .ask('描述这张图片');
213
+
214
+ // 多图对比
215
+ const answer = await oiiai
216
+ .use('siliconflow')
217
+ .key('your-key')
218
+ .model('Qwen/Qwen2.5-VL-72B-Instruct')
219
+ .image('https://example.com/image1.jpg')
220
+ .image('https://example.com/image2.jpg')
221
+ .ask('比较这两张图片');
222
+
223
+ // 视频分析
224
+ const answer = await oiiai
225
+ .use('siliconflow')
226
+ .key('your-key')
227
+ .model('Qwen/Qwen3-Omni-30B-A3B-Instruct')
228
+ .video('https://example.com/video.mp4', { maxFrames: 4, fps: 1 })
229
+ .ask('视频里发生了什么?');
230
+
231
+ // 音频理解
232
+ const answer = await oiiai
233
+ .use('siliconflow')
234
+ .key('your-key')
235
+ .model('Qwen/Qwen3-Omni-30B-A3B-Instruct')
236
+ .audio('https://example.com/audio.mp3')
237
+ .ask('这段音频说了什么?');
238
+
239
+ // 混合多模态 + 流式输出
240
+ for await (const chunk of oiiai
241
+ .use('siliconflow')
242
+ .key('your-key')
243
+ .model('Qwen/Qwen3-Omni-30B-A3B-Instruct')
244
+ .image('https://example.com/image.jpg')
245
+ .audio('https://example.com/audio.mp3')
246
+ .stream()
247
+ .ask('分析这张图片和音频')) {
248
+ process.stdout.write(chunk.text);
249
+ }
250
+ ```
251
+
252
+ #### 多模态方法说明
253
+
254
+ - **`image(url, options?)`** - 添加图像内容
255
+ - `url`: 图像 URL 或 Base64 (`data:image/jpeg;base64,...`)
256
+ - `options.detail`: `'auto' | 'low' | 'high'` - 分析精度
257
+
258
+ - **`video(url, options?)`** - 添加视频内容
259
+ - `url`: 视频 URL 或 Base64 (`data:video/mp4;base64,...`)
260
+ - `options.maxFrames`: 最大提取帧数(默认取决于模型)
261
+ - `options.fps`: 每秒提取帧数
262
+ - `options.detail`: `'auto' | 'low' | 'high'` - 分析精度
263
+
264
+ - **`audio(url)`** - 添加音频内容
265
+ - `url`: 音频 URL 或 Base64 (`data:audio/mp3;base64,...`)
266
+
267
+ **注意**: 多模态功能需要使用支持多模态的模型(如 SiliconFlow 的 Qwen VL 系列)。
268
+
189
269
  ### 多轮对话
190
270
 
191
271
  内置对话会话管理,自动维护上下文:
@@ -285,6 +365,52 @@ console.log('思考过程:', result.reasoning);
285
365
  console.log('最终答案:', result.content);
286
366
  ```
287
367
 
368
+ ### 多模态图像理解(SiliconFlow)
369
+
370
+ SiliconFlow 支持多模态输入,可以处理图像、视频、音频:
371
+
372
+ ```typescript
373
+ import { siliconflow } from '@weisiren000/oiiai';
374
+
375
+ siliconflow.configure({ apiKey: 'your-key' });
376
+
377
+ // 分析图片
378
+ const answer = await siliconflow.chat('Qwen/Qwen2.5-VL-72B-Instruct', {
379
+ messages: [
380
+ {
381
+ role: 'user',
382
+ content: [
383
+ {
384
+ type: 'image_url',
385
+ image_url: { url: 'https://example.com/image.jpg' },
386
+ },
387
+ { type: 'text', text: '描述这张图片' },
388
+ ],
389
+ },
390
+ ],
391
+ });
392
+
393
+ // 分析视频
394
+ const answer2 = await siliconflow.chat('Qwen/Qwen3-Omni-30B-A3B-Instruct', {
395
+ messages: [
396
+ {
397
+ role: 'user',
398
+ content: [
399
+ {
400
+ type: 'video_url',
401
+ video_url: {
402
+ url: 'data:video/mp4;base64,...',
403
+ max_frames: 4,
404
+ fps: 1,
405
+ },
406
+ },
407
+ { type: 'text', text: '视频里发生了什么?' },
408
+ ],
409
+ },
410
+ ],
411
+ });
412
+ ```
413
+
288
414
  ## 🔧 支持的 Provider
289
415
 
290
416
  | Provider | 服务商 | Reasoning 参数 | 支持思考模型 | 环境变量 |
@@ -297,6 +423,8 @@ console.log('最终答案:', result.content);
297
423
  | `modelscope` | 魔搭社区 | `enable_thinking` | ✅ | `MODELSCOPE_API_KEY` |
298
424
  | `poe` | Poe | `reasoning_effort` | ✅ | `POE_API_KEY` |
299
425
  | `nova` | AWS Nova | `reasoningConfig.type` | ✅ | `NOVA_API_KEY` |
426
+ | `zhipu` | 智谱AI | 暂不支持 | ❌ | `ZHIPU_API_KEY` |
427
+ | `siliconflow` | SiliconFlow | `thinking_budget` | ✅ | `SILICONFLOW_API_KEY` |
300
428
 
301
429
  ## 📝 常用模型
302
430
 
@@ -326,6 +454,20 @@ console.log('最终答案:', result.content);
326
454
  'nova-2-lite-v1';
327
455
  'nova-2-v1';
328
456
  'nova-premier-v1';
457
+
458
+ // 智谱AI (Zhipu)
459
+ 'glm-4-plus'; // 最强大的通用模型
460
+ 'glm-4-flash'; // 快速响应模型
461
+ 'glm-4-air'; // 轻量级模型
462
+ 'glm-4-long'; // 长文本处理模型
463
+
464
+ // SiliconFlow
465
+ 'deepseek-ai/DeepSeek-V3'; // 通用对话
466
+ 'deepseek-ai/DeepSeek-R1'; // 推理模型
467
+ 'Qwen/Qwen2.5-VL-72B-Instruct'; // 视觉理解
468
+ 'Qwen/Qwen3-Omni-30B-A3B-Instruct'; // 多模态全能
469
+ 'Qwen/Qwen3-VL-7B-Instruct'; // 视觉模型
470
+ 'zai-org/GLM-4.6V'; // 视觉对话
329
471
  ```
330
472
 
331
473
  ## 🌍 环境变量
@@ -342,17 +484,20 @@ HUGGINGFACE_API_KEY=hf_xxx
342
484
  MODELSCOPE_API_KEY=xxx
343
485
  POE_API_KEY=xxx
344
486
  NOVA_API_KEY=xxx
487
+ ZHIPU_API_KEY=xxx
345
488
  ```
346
489
 
347
490
  ```typescript
348
491
  import 'dotenv/config';
349
- import { deepseek, openrouter } from '@weisiren000/oiiai';
492
+ import { deepseek, openrouter, zhipu } from '@weisiren000/oiiai';
350
493
 
351
494
  // 从环境变量读取配置
352
495
  deepseek.fromEnv();
353
496
  openrouter.fromEnv();
497
+ zhipu.fromEnv();
354
498
 
355
499
  const answer = await deepseek.ask('deepseek-chat', '你好');
500
+ const answer2 = await zhipu.ask('glm-4-flash', '你好');
356
501
  ```
357
502
 
358
503
  ## 🧪 高级用法
@@ -439,6 +584,7 @@ const provider = createProvider({ provider: 'my-provider', apiKey: 'xxx' });
439
584
  ├─────────────────────────────────────────────────────────┤
440
585
  │ 适配器层 (Adapter) │
441
586
  │ OpenRouterAdapter / GeminiAdapter / GroqAdapter ... │
587
+ │ ✨ 统一支持多种 reasoning 字段备用方案 │
442
588
  ├─────────────────────────────────────────────────────────┤
443
589
  │ 客户端层 (Client) │
444
590
  │ HttpProviderClient │
@@ -448,6 +594,16 @@ const provider = createProvider({ provider: 'my-provider', apiKey: 'xxx' });
448
594
  └─────────────────────────────────────────────────────────┘
449
595
  ```
450
596
 
597
+ ### 适配器层增强
598
+
599
+ 所有 Provider 适配器现在都支持**多种 reasoning 字段的备用方案**,确保最大兼容性:
600
+
601
+ - 优先使用 `reasoning_content`(最常见)
602
+ - 备用 `reasoning`(部分 Provider)
603
+ - 备用 `thoughts`(Gemini 等)
604
+
605
+ 这意味着无论 Provider 使用哪种字段格式,都能正确识别和提取思考内容。
606
+
451
607
  ## ❓ 故障排除
452
608
 
453
609
  ### 常见问题
@@ -467,7 +623,7 @@ oiiai.use('deepseek').key('xxx').baseUrl('https://custom.api.com');
467
623
  ```
468
624
 
469
625
  **Q: 流式输出中如何区分思考和回答?**
470
- A: 检查 `chunk.type`:`'reasoning'` 表示思考内容,`'content'` 表示最终回答。
626
+ A: 检查 `chunk.type`:`'reasoning'` 表示思考内容,`'content'` 表示最终回答。所有 Provider 的适配器都已统一支持多种 reasoning 字段格式(`reasoning_content` / `reasoning` / `thoughts`),确保最大兼容性。
471
627
 
472
628
  ### 错误处理
473
629
 
package/dist/index.d.mts CHANGED
@@ -1,9 +1,74 @@
1
1
  /**
2
2
  * AI Provider 统一类型定义
3
3
  */
4
+ /**
5
+ * 文本内容部分
6
+ */
7
+ interface TextContentPart {
8
+ type: 'text';
9
+ text: string;
10
+ }
11
+ /**
12
+ * 图像 URL 配置
13
+ */
14
+ interface ImageUrlConfig {
15
+ /** 图像 URL 或 base64 编码数据 */
16
+ url: string;
17
+ /** 细节级别 */
18
+ detail?: 'auto' | 'low' | 'high';
19
+ }
20
+ /**
21
+ * 图像内容部分
22
+ */
23
+ interface ImageContentPart {
24
+ type: 'image_url';
25
+ image_url: ImageUrlConfig;
26
+ }
27
+ /**
28
+ * 视频 URL 配置
29
+ */
30
+ interface VideoUrlConfig {
31
+ /** 视频 URL 或 base64 编码数据 */
32
+ url: string;
33
+ /** 细节级别 */
34
+ detail?: 'auto' | 'low' | 'high';
35
+ /** 最大提取帧数 */
36
+ max_frames?: number;
37
+ /** 每秒提取帧数 */
38
+ fps?: number;
39
+ }
40
+ /**
41
+ * 视频内容部分
42
+ */
43
+ interface VideoContentPart {
44
+ type: 'video_url';
45
+ video_url: VideoUrlConfig;
46
+ }
47
+ /**
48
+ * 音频 URL 配置
49
+ */
50
+ interface AudioUrlConfig {
51
+ /** 音频 URL 或 base64 编码数据 */
52
+ url: string;
53
+ }
54
+ /**
55
+ * 音频内容部分
56
+ */
57
+ interface AudioContentPart {
58
+ type: 'audio_url';
59
+ audio_url: AudioUrlConfig;
60
+ }
61
+ /**
62
+ * 多模态内容部分联合类型
63
+ */
64
+ type ContentPart = TextContentPart | ImageContentPart | VideoContentPart | AudioContentPart;
65
+ /**
66
+ * 消息内容类型 - 支持纯文本或多模态内容数组
67
+ */
68
+ type MessageContent = string | ContentPart[];
4
69
  interface ChatMessage {
5
70
  role: 'system' | 'user' | 'assistant';
6
- content: string;
71
+ content: MessageContent;
7
72
  }
8
73
  /**
9
74
  * 统一的思考努力程度
@@ -282,7 +347,7 @@ declare abstract class BaseProvider implements AIProvider {
282
347
  /**
283
348
  * Provider 类型
284
349
  */
285
- type ProviderType$2 = 'openrouter' | 'gemini' | 'groq' | 'huggingface' | 'modelscope' | 'deepseek' | 'poe' | 'nova';
350
+ type ProviderType$2 = 'openrouter' | 'gemini' | 'groq' | 'huggingface' | 'modelscope' | 'deepseek' | 'poe' | 'nova' | 'zhipu' | 'siliconflow';
286
351
  /**
287
352
  * 统一的 Provider 配置格式
288
353
  * 用于配置各种 AI Provider 的连接和行为
@@ -436,6 +501,8 @@ declare const ai: {
436
501
  deepseek: (apiKey: string, baseUrl?: string) => AIProvider;
437
502
  poe: (apiKey: string, baseUrl?: string) => AIProvider;
438
503
  nova: (apiKey: string, baseUrl?: string) => AIProvider;
504
+ zhipu: (apiKey: string, baseUrl?: string) => AIProvider;
505
+ siliconflow: (apiKey: string, baseUrl?: string) => AIProvider;
439
506
  };
440
507
 
441
508
  /**
@@ -1147,7 +1214,7 @@ declare class HttpProviderClient implements ProviderClient {
1147
1214
  * Provider 类型枚举
1148
1215
  * 支持的所有 Provider 类型
1149
1216
  */
1150
- type ProviderType = 'openrouter' | 'gemini' | 'groq' | 'huggingface' | 'modelscope' | 'deepseek' | 'poe' | 'nova';
1217
+ type ProviderType = 'openrouter' | 'gemini' | 'groq' | 'huggingface' | 'modelscope' | 'deepseek' | 'poe' | 'nova' | 'zhipu' | 'siliconflow';
1151
1218
  /**
1152
1219
  * 适配器配置
1153
1220
  * 用于创建适配器实例时的配置
@@ -1486,7 +1553,8 @@ declare class GeminiAdapter extends BaseAdapter {
1486
1553
  buildReasoningParams(config?: ReasoningConfig): Record<string, unknown>;
1487
1554
  /**
1488
1555
  * 从 delta 中提取 StreamChunk
1489
- * Gemini 可能使用 reasoning_content 或 thoughts 字段
1556
+ * Gemini 可能使用 reasoning_content、reasoning 或 thoughts 字段
1557
+ * 支持多种字段名:reasoning_content / reasoning / thoughts
1490
1558
  */
1491
1559
  extractStreamChunk(delta: Record<string, unknown>): StreamChunk | null;
1492
1560
  /**
@@ -1531,6 +1599,7 @@ declare class GroqAdapter extends BaseAdapter {
1531
1599
  /**
1532
1600
  * 从 delta 中提取 StreamChunk
1533
1601
  * Groq 使用 reasoning_content 或 reasoning 字段
1602
+ * 支持多种字段名:reasoning_content / reasoning / thoughts
1534
1603
  */
1535
1604
  extractStreamChunk(delta: Record<string, unknown>): StreamChunk | null;
1536
1605
  /**
@@ -1568,6 +1637,7 @@ declare class HuggingFaceAdapter extends BaseAdapter {
1568
1637
  buildReasoningParams(config?: ReasoningConfig): Record<string, unknown>;
1569
1638
  /**
1570
1639
  * 从 delta 中提取 StreamChunk
1640
+ * 支持多种字段名:reasoning_content / reasoning / thoughts
1571
1641
  */
1572
1642
  extractStreamChunk(delta: Record<string, unknown>): StreamChunk | null;
1573
1643
  /**
@@ -1605,6 +1675,7 @@ declare class ModelScopeAdapter extends BaseAdapter {
1605
1675
  buildReasoningParams(config?: ReasoningConfig): Record<string, unknown>;
1606
1676
  /**
1607
1677
  * 从 delta 中提取 StreamChunk
1678
+ * 支持多种字段名:reasoning_content / reasoning / thoughts
1608
1679
  */
1609
1680
  extractStreamChunk(delta: Record<string, unknown>): StreamChunk | null;
1610
1681
  /**
@@ -1644,6 +1715,7 @@ declare class DeepSeekAdapter extends BaseAdapter {
1644
1715
  /**
1645
1716
  * 从 delta 中提取 StreamChunk
1646
1717
  * DeepSeek R1 使用 reasoning_content 返回思考过程
1718
+ * 支持多种字段名:reasoning_content / reasoning / thoughts
1647
1719
  */
1648
1720
  extractStreamChunk(delta: Record<string, unknown>): StreamChunk | null;
1649
1721
  /**
@@ -1688,6 +1760,7 @@ declare class PoeAdapter extends BaseAdapter {
1688
1760
  /**
1689
1761
  * 从 delta 中提取 StreamChunk
1690
1762
  * Poe 的流式响应处理比较复杂,需要处理多种思考格式
1763
+ * 支持多种字段名:reasoning_content / reasoning / thoughts
1691
1764
  */
1692
1765
  extractStreamChunk(delta: Record<string, unknown>): StreamChunk | null;
1693
1766
  /**
@@ -1727,6 +1800,47 @@ declare class NovaAdapter extends BaseAdapter {
1727
1800
  /**
1728
1801
  * 从 delta 中提取 StreamChunk
1729
1802
  * Nova 返回 reasoning_content 作为思考过程
1803
+ * 支持多种字段名:reasoning_content / reasoning / thoughts
1804
+ */
1805
+ extractStreamChunk(delta: Record<string, unknown>): StreamChunk | null;
1806
+ /**
1807
+ * 获取 API 端点 URL
1808
+ */
1809
+ getEndpointUrl(baseUrl: string): string;
1810
+ }
1811
+
1812
+ /**
1813
+ * 智谱AI (Zhipu AI) 适配器实现
1814
+ * 将智谱AI API 适配为统一接口
1815
+ *
1816
+ * 智谱AI 特点:
1817
+ * - 使用 OpenAI 兼容格式
1818
+ * - API 端点: https://open.bigmodel.cn/api/paas/v4/chat/completions
1819
+ * - 支持模型: glm-4-plus, glm-4-0520, glm-4, glm-4-air, glm-4-airx, glm-4-flash 等
1820
+ * - 支持流式和非流式响应
1821
+ */
1822
+
1823
+ /**
1824
+ * 智谱AI 适配器
1825
+ * 实现 ProviderAdapter 接口,处理智谱AI特定的 API 格式
1826
+ */
1827
+ declare class ZhipuAdapter extends BaseAdapter {
1828
+ readonly name: ProviderType;
1829
+ readonly defaultBaseUrl = "https://open.bigmodel.cn";
1830
+ /**
1831
+ * 构建聊天请求体
1832
+ * 智谱AI 使用 OpenAI 兼容格式
1833
+ */
1834
+ buildChatRequest(options: ChatOptions, stream?: boolean): Record<string, unknown>;
1835
+ /**
1836
+ * 构建智谱AI格式的 reasoning 参数
1837
+ * 智谱AI 目前使用标准 OpenAI 格式,暂不支持特殊的 reasoning 参数
1838
+ */
1839
+ buildReasoningParams(_config?: ReasoningConfig): Record<string, unknown>;
1840
+ /**
1841
+ * 从 delta 中提取 StreamChunk
1842
+ * 智谱AI 使用标准 OpenAI 格式的流式响应
1843
+ * 支持多种字段名:reasoning_content / reasoning / thoughts
1730
1844
  */
1731
1845
  extractStreamChunk(delta: Record<string, unknown>): StreamChunk | null;
1732
1846
  /**
@@ -1751,6 +1865,32 @@ declare function createBuiltInAdapters(): Map<ProviderType, ProviderAdapter>;
1751
1865
  * 提供链式调用和预设实例的类型支持
1752
1866
  */
1753
1867
 
1868
+ /**
1869
+ * 图像配置选项
1870
+ */
1871
+ interface ImageOptions {
1872
+ /** 细节级别 */
1873
+ detail?: 'auto' | 'low' | 'high';
1874
+ }
1875
+ /**
1876
+ * 视频配置选项
1877
+ */
1878
+ interface VideoOptions {
1879
+ /** 细节级别 */
1880
+ detail?: 'auto' | 'low' | 'high';
1881
+ /** 最大提取帧数 */
1882
+ maxFrames?: number;
1883
+ /** 每秒提取帧数 */
1884
+ fps?: number;
1885
+ }
1886
+ /**
1887
+ * 多模态内容项(内部使用)
1888
+ */
1889
+ interface MultimodalItem {
1890
+ type: 'image' | 'video' | 'audio';
1891
+ url: string;
1892
+ options?: ImageOptions | VideoOptions;
1893
+ }
1754
1894
  /**
1755
1895
  * 问答选项
1756
1896
  * 用于配置单次 AI 调用的参数
@@ -1844,6 +1984,8 @@ interface BuilderConfig {
1844
1984
  reasoning?: ReasoningConfig;
1845
1985
  /** 是否流式请求 */
1846
1986
  isStream?: boolean;
1987
+ /** 多模态内容列表 */
1988
+ multimodal?: MultimodalItem[];
1847
1989
  }
1848
1990
  /**
1849
1991
  * 链式调用构建器接口
@@ -1851,12 +1993,21 @@ interface BuilderConfig {
1851
1993
  *
1852
1994
  * @example
1853
1995
  * ```typescript
1996
+ * // 纯文本请求
1854
1997
  * const answer = await oiiai
1855
1998
  * .use('deepseek')
1856
1999
  * .key('your-api-key')
1857
2000
  * .model('deepseek-chat')
1858
2001
  * .system('你是助手')
1859
2002
  * .ask('你好');
2003
+ *
2004
+ * // 多模态请求
2005
+ * const answer = await oiiai
2006
+ * .use('siliconflow')
2007
+ * .key('your-api-key')
2008
+ * .model('Qwen/Qwen2.5-VL-72B-Instruct')
2009
+ * .image('https://example.com/image.jpg', { detail: 'high' })
2010
+ * .ask('描述这张图片');
1860
2011
  * ```
1861
2012
  */
1862
2013
  interface OiiaiBuilder {
@@ -1908,6 +2059,55 @@ interface OiiaiBuilder {
1908
2059
  * @returns this 支持链式调用
1909
2060
  */
1910
2061
  baseUrl(url: string): this;
2062
+ /**
2063
+ * 添加图像内容(多模态)
2064
+ * 支持 URL 或 base64 编码的图像数据
2065
+ * @param url - 图像 URL 或 base64 data URL
2066
+ * @param options - 图像配置选项
2067
+ * @returns this 支持链式调用
2068
+ *
2069
+ * @example
2070
+ * ```typescript
2071
+ * // 使用 URL
2072
+ * builder.image('https://example.com/image.jpg')
2073
+ *
2074
+ * // 使用 base64
2075
+ * builder.image('data:image/jpeg;base64,...', { detail: 'high' })
2076
+ *
2077
+ * // 多张图片
2078
+ * builder.image(url1).image(url2).ask('比较这两张图片')
2079
+ * ```
2080
+ */
2081
+ image(url: string, options?: ImageOptions): this;
2082
+ /**
2083
+ * 添加视频内容(多模态)
2084
+ * 支持 URL 或 base64 编码的视频数据
2085
+ * @param url - 视频 URL 或 base64 data URL
2086
+ * @param options - 视频配置选项
2087
+ * @returns this 支持链式调用
2088
+ *
2089
+ * @example
2090
+ * ```typescript
2091
+ * builder
2092
+ * .video('https://example.com/video.mp4', { maxFrames: 8, fps: 1 })
2093
+ * .ask('描述这个视频的内容')
2094
+ * ```
2095
+ */
2096
+ video(url: string, options?: VideoOptions): this;
2097
+ /**
2098
+ * 添加音频内容(多模态)
2099
+ * 支持 URL 或 base64 编码的音频数据
2100
+ * @param url - 音频 URL 或 base64 data URL
2101
+ * @returns this 支持链式调用
2102
+ *
2103
+ * @example
2104
+ * ```typescript
2105
+ * builder
2106
+ * .audio('data:audio/mp3;base64,...')
2107
+ * .ask('这段音频说了什么?')
2108
+ * ```
2109
+ */
2110
+ audio(url: string): this;
1911
2111
  /**
1912
2112
  * 标记为流式请求
1913
2113
  * 调用后 ask() 将返回 AsyncGenerator
@@ -2125,5 +2325,16 @@ declare const poe: PresetProvider;
2125
2325
  * 环境变量: NOVA_API_KEY
2126
2326
  */
2127
2327
  declare const nova: PresetProvider;
2328
+ /**
2329
+ * 智谱AI 预设实例
2330
+ * 环境变量: ZHIPU_API_KEY
2331
+ */
2332
+ declare const zhipu: PresetProvider;
2333
+ /**
2334
+ * SiliconFlow 预设实例
2335
+ * 环境变量: SILICONFLOW_API_KEY
2336
+ * 支持多模态模型(视觉/音频/视频)
2337
+ */
2338
+ declare const siliconflow: PresetProvider;
2128
2339
 
2129
- export { type AIProvider, APIError, type AdapterConfig, type AskOptions, BaseAdapter, BaseProvider, type BuilderConfig, CONFIG_DEFAULTS, type ChatMessage, type ChatOptions, type ChatResult, type ChatSession, type ChatSessionOptions, ConfigManager, ConfigValidator, ConfigurationError, DeepSeekAdapter, type DeltaExtractor, EFFORT_TOKEN_MAP, ValidationError as FluentValidationError, GeminiAdapter, GeminiProvider, GroqAdapter, GroqProvider, HttpProviderClient, HuggingFaceAdapter, HuggingFaceProvider, type LegacyProviderConfig, type ModelInfo, type ModelPricing, ModelScopeAdapter, ModelScopeProvider, NetworkError, NovaAdapter, type OiiaiBuilder, OpenRouterAdapter, type OpenRouterModelInfo, OpenRouterProvider, PoeAdapter, type PresetConfigOptions, type PresetProvider, type ProviderAdapter, type ProviderCapabilities, type ProviderClient, type ProviderClientConfig, type ProviderConfig, ProviderError, ProviderRegistry, type ProviderType$2 as ProviderType, type ReasoningConfig, type ReasoningEffort, type RegistryConfig, RegistryError, RequestBuilder, type StreamBuilder, type StreamCallbacks, type StreamChunk, StreamProcessor, TimeoutError, type TokenUsage, type UnifiedProviderConfig, VALID_PROVIDERS, type ValidationError$1 as ValidationError, type ValidationResult, ai, createBuilder, createBuiltInAdapters, createProvider, deepseek, gemini, groq, huggingface, modelscope, nova, oiiai, openrouter, poe };
2340
+ export { type AIProvider, APIError, type AdapterConfig, type AskOptions, type AudioContentPart, type AudioUrlConfig, BaseAdapter, BaseProvider, type BuilderConfig, CONFIG_DEFAULTS, type ChatMessage, type ChatOptions, type ChatResult, type ChatSession, type ChatSessionOptions, ConfigManager, ConfigValidator, ConfigurationError, type ContentPart, DeepSeekAdapter, type DeltaExtractor, EFFORT_TOKEN_MAP, ValidationError as FluentValidationError, GeminiAdapter, GeminiProvider, GroqAdapter, GroqProvider, HttpProviderClient, HuggingFaceAdapter, HuggingFaceProvider, type ImageContentPart, type ImageUrlConfig, type LegacyProviderConfig, type MessageContent, type ModelInfo, type ModelPricing, ModelScopeAdapter, ModelScopeProvider, NetworkError, NovaAdapter, type OiiaiBuilder, OpenRouterAdapter, type OpenRouterModelInfo, OpenRouterProvider, PoeAdapter, type PresetConfigOptions, type PresetProvider, type ProviderAdapter, type ProviderCapabilities, type ProviderClient, type ProviderClientConfig, type ProviderConfig, ProviderError, ProviderRegistry, type ProviderType$2 as ProviderType, type ReasoningConfig, type ReasoningEffort, type RegistryConfig, RegistryError, RequestBuilder, type StreamBuilder, type StreamCallbacks, type StreamChunk, StreamProcessor, type TextContentPart, TimeoutError, type TokenUsage, type UnifiedProviderConfig, VALID_PROVIDERS, type ValidationError$1 as ValidationError, type ValidationResult, type VideoContentPart, type VideoUrlConfig, ZhipuAdapter, ai, createBuilder, createBuiltInAdapters, createProvider, deepseek, gemini, groq, huggingface, modelscope, nova, oiiai, openrouter, poe, siliconflow, zhipu };