@aihubmix/ai-sdk-provider 0.0.2 → 0.0.3

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.ja.md ADDED
@@ -0,0 +1,301 @@
1
+ # AI SDK - Aihubmix Provider
2
+
3
+ <div align="center">
4
+ <a href="README.md">🇺🇸 English</a> |
5
+ <a href="README.zh.md">🇨🇳 中文</a> |
6
+ <a href="README.ja.md">🇯🇵 日本語</a>
7
+ </div>
8
+
9
+ > **🎉 10% 割引!**
10
+ app-codeが内蔵されており、この方法でモデルをリクエストすると10%割引になります。
11
+
12
+ **[Aihubmix 公式サイト](https://aihubmix.com/)** | **[モデルスクエア](https://aihubmix.com/models)**
13
+
14
+ [AI SDK](https://ai-sdk.dev/docs)用の **[Aihubmix provider](https://v5.ai-sdk.dev/providers/community-providers/aihubmix)**
15
+ 一つのゲートウェイ、無限のモデル;ワンストップリクエスト:OpenAI、Claude、Gemini、DeepSeek、Qwen、そして500以上のAIモデル。
16
+
17
+ ## サポートされている機能
18
+
19
+ Aihubmix providerは以下のAI機能をサポートしています:
20
+
21
+ - **テキスト生成**:様々なモデルでのチャット完了
22
+ - **ストリーミングテキスト**:リアルタイムテキストストリーミング
23
+ - **画像生成**:テキストプロンプトから画像を作成
24
+ - **埋め込み**:単一およびバッチテキスト埋め込み
25
+ - **オブジェクト生成**:スキーマを使用した構造化データ生成
26
+ - **ストリーミングオブジェクト**:リアルタイム構造化データストリーミング
27
+ - **音声合成**:テキストから音声への変換
28
+ - **転写**:音声からテキストへの変換
29
+ - **ツール**:ウェブ検索およびその他のツール
30
+
31
+ ## セットアップ
32
+
33
+ Aihubmix providerは`@aihubmix/ai-sdk-provider`モジュールで利用可能です。[@aihubmix/ai-sdk-provider](https://www.npmjs.com/package/@aihubmix/ai-sdk-provider)でインストールできます
34
+
35
+ ```bash
36
+ npm i @aihubmix/ai-sdk-provider
37
+ ```
38
+
39
+ ## Provider インスタンス
40
+
41
+ `@aihubmix/ai-sdk-provider`からデフォルトのproviderインスタンス`aihubmix`をインポートできます:
42
+
43
+ ```ts
44
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
45
+ ```
46
+
47
+ ## 設定
48
+
49
+ Aihubmix APIキーを環境変数として設定:
50
+
51
+ ```bash
52
+ export AIHUBMIX_API_KEY="your-api-key-here"
53
+ ```
54
+
55
+ または直接providerに渡す:
56
+
57
+ ```ts
58
+ import { createAihubmix } from '@aihubmix/ai-sdk-provider';
59
+
60
+ const aihubmix = createAihubmix({
61
+ apiKey: 'your-api-key-here',
62
+ });
63
+ ```
64
+
65
+ ## 使用
66
+
67
+ まず、必要な関数をインポートします:
68
+
69
+ ```ts
70
+ import { createAihubmix } from '@aihubmix/ai-sdk-provider';
71
+ import {
72
+ generateText,
73
+ streamText,
74
+ generateImage,
75
+ embed,
76
+ embedMany,
77
+ generateObject,
78
+ streamObject,
79
+ generateSpeech,
80
+ transcribe
81
+ } from 'ai';
82
+ import { z } from 'zod';
83
+ ```
84
+
85
+ ### テキスト生成
86
+
87
+ ```ts
88
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
89
+ import { generateText } from 'ai';
90
+
91
+ const { text } = await generateText({
92
+ model: aihubmix('o4-mini'),
93
+ prompt: '4人用のベジタリアンラザニアのレシピを書いてください。',
94
+ });
95
+ ```
96
+
97
+ ### Claudeモデル
98
+
99
+ ```ts
100
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
101
+ import { generateText } from 'ai';
102
+
103
+ const { text } = await generateText({
104
+ model: aihubmix('claude-3-7-sonnet-20250219'),
105
+ prompt: '簡単な言葉で量子コンピューティングを説明してください。',
106
+ });
107
+ ```
108
+
109
+ ### Geminiモデル
110
+
111
+ ```ts
112
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
113
+ import { generateText } from 'ai';
114
+
115
+ const { text } = await generateText({
116
+ model: aihubmix('gemini-2.5-flash'),
117
+ prompt: '数字のリストをソートするPythonスクリプトを作成してください。',
118
+ });
119
+ ```
120
+
121
+ ### 画像生成
122
+
123
+ ```ts
124
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
125
+ import { generateImage } from 'ai';
126
+
127
+ const { image } = await generateImage({
128
+ model: aihubmix.image('gpt-image-1'),
129
+ prompt: '山々の上に美しい夕日',
130
+ });
131
+ ```
132
+
133
+ ### 埋め込み
134
+
135
+ ```ts
136
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
137
+ import { embed } from 'ai';
138
+
139
+ const { embedding } = await embed({
140
+ model: aihubmix.embedding('text-embedding-ada-002'),
141
+ value: 'こんにちは、世界!',
142
+ });
143
+ ```
144
+
145
+ ### 転写
146
+
147
+ ```ts
148
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
149
+ import { transcribe } from 'ai';
150
+
151
+ const { text } = await transcribe({
152
+ model: aihubmix.transcription('whisper-1'),
153
+ audio: audioFile,
154
+ });
155
+ ```
156
+
157
+ ### ストリーミングテキスト
158
+
159
+ ```ts
160
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
161
+ import { streamText } from 'ai';
162
+
163
+ const result = streamText({
164
+ model: aihubmix('gpt-3.5-turbo'),
165
+ prompt: 'ロボットが絵を学ぶ短編小説を書いてください。',
166
+ maxOutputTokens: 256,
167
+ temperature: 0.3,
168
+ maxRetries: 3,
169
+ });
170
+
171
+ let fullText = '';
172
+ for await (const textPart of result.textStream) {
173
+ fullText += textPart;
174
+ process.stdout.write(textPart);
175
+ }
176
+
177
+ console.log('\n使用量:', await result.usage);
178
+ console.log('完了理由:', await result.finishReason);
179
+ ```
180
+
181
+ ### オブジェクト生成
182
+
183
+ ```ts
184
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
185
+ import { generateObject } from 'ai';
186
+ import { z } from 'zod';
187
+
188
+ const result = await generateObject({
189
+ model: aihubmix('gpt-4o-mini'),
190
+ schema: z.object({
191
+ recipe: z.object({
192
+ name: z.string(),
193
+ ingredients: z.array(
194
+ z.object({
195
+ name: z.string(),
196
+ amount: z.string(),
197
+ }),
198
+ ),
199
+ steps: z.array(z.string()),
200
+ }),
201
+ }),
202
+ prompt: 'ラザニアのレシピを生成してください。',
203
+ });
204
+
205
+ console.log(JSON.stringify(result.object.recipe, null, 2));
206
+ console.log('Token使用量:', result.usage);
207
+ console.log('完了理由:', result.finishReason);
208
+ ```
209
+
210
+ ### ストリーミングオブジェクト
211
+
212
+ ```ts
213
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
214
+ import { streamObject } from 'ai';
215
+ import { z } from 'zod';
216
+
217
+ const result = await streamObject({
218
+ model: aihubmix('gpt-4o-mini'),
219
+ schema: z.object({
220
+ recipe: z.object({
221
+ name: z.string(),
222
+ ingredients: z.array(
223
+ z.object({
224
+ name: z.string(),
225
+ amount: z.string(),
226
+ }),
227
+ ),
228
+ steps: z.array(z.string()),
229
+ }),
230
+ }),
231
+ prompt: 'ラザニアのレシピを生成してください。',
232
+ });
233
+
234
+ for await (const objectPart of result.partialObjectStream) {
235
+ console.log(objectPart);
236
+ }
237
+
238
+ console.log('Token使用量:', result.usage);
239
+ console.log('最終オブジェクト:', result.object);
240
+ ```
241
+
242
+ ### バッチ埋め込み
243
+
244
+ ```ts
245
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
246
+ import { embedMany } from 'ai';
247
+
248
+ const { embeddings, usage } = await embedMany({
249
+ model: aihubmix.embedding('text-embedding-3-small'),
250
+ values: [
251
+ 'ビーチでの晴れた日',
252
+ '街での雨の午後',
253
+ '山での雪の夜',
254
+ ],
255
+ });
256
+
257
+ console.log('埋め込み:', embeddings);
258
+ console.log('使用量:', usage);
259
+ ```
260
+
261
+ ### 音声合成
262
+
263
+ ```ts
264
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
265
+ import { generateSpeech } from 'ai';
266
+
267
+ const { audio } = await generateSpeech({
268
+ model: aihubmix.speech('tts-1'),
269
+ text: 'こんにちは、これは音声合成のテストです。',
270
+ });
271
+
272
+ // 音声ファイルを保存
273
+ await saveAudioFile(audio);
274
+ console.log('音声生成成功:', audio);
275
+ ```
276
+
277
+ ### ツール
278
+
279
+ Aihubmix providerはウェブ検索を含む様々なツールをサポートしています:
280
+
281
+ ```ts
282
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
283
+ import { generateText } from 'ai';
284
+
285
+ const { text } = await generateText({
286
+ model: aihubmix('gpt-4'),
287
+ prompt: 'AIの最新の進歩は何ですか?',
288
+ tools: {
289
+ webSearchPreview: aihubmix.tools.webSearchPreview({
290
+ searchContextSize: 'high',
291
+ }),
292
+ },
293
+ });
294
+ ```
295
+
296
+ ## 追加リソース
297
+
298
+ - [Aihubmix Provider リポジトリ](https://github.com/inferera/aihubmix)
299
+ - [Aihubmix ドキュメント](https://docs.aihubmix.com/en)
300
+ - [Aihubmix ダッシュボード](https://aihubmix.com)
301
+ - [Aihubmix ビジネス協力](mailto:business@aihubmix.com)
package/README.md CHANGED
@@ -1,13 +1,35 @@
1
1
  # AI SDK - Aihubmix Provider
2
2
 
3
+ <div align="center">
4
+ <a href="README.md">🇺🇸 English</a> |
5
+ <a href="README.zh.md">🇨🇳 中文</a> |
6
+ <a href="README.ja.md">🇯🇵 日本語</a>
7
+ </div>
8
+
3
9
  > **🎉 10% discount!**
4
- Added app-code; this way, requesting all models through ai-sdk offers a 10% discount.
10
+ Built-in app-code; using this method to request all models offers a 10% discount.
5
11
 
6
12
  **[Aihubmix Official Website](https://aihubmix.com/)** | **[Model Square](https://aihubmix.com/models)**
7
13
 
8
- The **[Aihubmix provider](https://ai-sdk.dev/providers/ai-sdk-providers/aihubmix)** for the [AI SDK](https://ai-sdk.dev/docs)
14
+ The **[Aihubmix provider](https://v5.ai-sdk.dev/providers/community-providers/aihubmix)** for the [AI SDK](https://ai-sdk.dev/docs)
9
15
  One Gateway, Infinite Models;one-stop request: OpenAI, Claude, Gemini, DeepSeek, Qwen, and over 500 AI models.
10
16
 
17
+
18
+ ## Supported Features
19
+
20
+ The Aihubmix provider supports the following AI features:
21
+
22
+ - **Text Generation**: Chat completion with various models
23
+ - **Streaming Text**: Real-time text streaming
24
+ - **Image Generation**: Create images from text prompts
25
+ - **Embeddings**: Single and batch text embeddings
26
+ - **Object Generation**: Structured data generation with schemas
27
+ - **Streaming Objects**: Real-time structured data streaming
28
+ - **Speech Synthesis**: Text-to-speech conversion
29
+ - **Transcription**: Speech-to-text conversion
30
+ - **Tools**: Web search and other tools
31
+
32
+
11
33
  ## Setup
12
34
 
13
35
  The Aihubmix provider is available in the `@aihubmix/ai-sdk-provider` module. You can install it with [@aihubmix/ai-sdk-provider](https://www.npmjs.com/package/@aihubmix/ai-sdk-provider)
@@ -42,32 +64,27 @@ const aihubmix = createAihubmix({
42
64
  });
43
65
  ```
44
66
 
45
- ## Supported Models
46
-
47
- ### OpenAI-Compatible Models
67
+ ## Usage
48
68
 
49
- - GPT-4, GPT-3.5, and other OpenAI models
50
- - Image generation models
51
- - Embedding models
52
- - Transcription models
53
- - Speech synthesis models
69
+ First, import the necessary functions:
54
70
 
55
- ### Anthropic Claude Models
56
-
57
- - Claude-3 models (claude-3-opus, claude-3-sonnet, claude-3-haiku)
58
- - Claude-2 models
59
-
60
- ### Google Gemini Models
61
-
62
- - Gemini Pro models
63
- - Gemini Flash models
64
- - Imagen models
65
-
66
- ### Other Models => [Model Square](https://aihubmix.com/models)
67
-
68
- ## Examples
71
+ ```ts
72
+ import { createAihubmix } from '@aihubmix/ai-sdk-provider';
73
+ import {
74
+ generateText,
75
+ streamText,
76
+ generateImage,
77
+ embed,
78
+ embedMany,
79
+ generateObject,
80
+ streamObject,
81
+ generateSpeech,
82
+ transcribe
83
+ } from 'ai';
84
+ import { z } from 'zod';
85
+ ```
69
86
 
70
- ### Chat Completion
87
+ ### Generate Text
71
88
 
72
89
  ```ts
73
90
  import { aihubmix } from '@aihubmix/ai-sdk-provider';
@@ -139,7 +156,127 @@ const { text } = await transcribe({
139
156
  });
140
157
  ```
141
158
 
142
- ## Tools
159
+ ### Stream Text
160
+
161
+ ```ts
162
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
163
+ import { streamText } from 'ai';
164
+
165
+ const result = streamText({
166
+ model: aihubmix('gpt-3.5-turbo'),
167
+ prompt: 'Write a short story about a robot learning to paint.',
168
+ maxOutputTokens: 256,
169
+ temperature: 0.3,
170
+ maxRetries: 3,
171
+ });
172
+
173
+ let fullText = '';
174
+ for await (const textPart of result.textStream) {
175
+ fullText += textPart;
176
+ process.stdout.write(textPart);
177
+ }
178
+
179
+ console.log('\nUsage:', await result.usage);
180
+ console.log('Finish reason:', await result.finishReason);
181
+ ```
182
+
183
+ ### Generate Object
184
+
185
+ ```ts
186
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
187
+ import { generateObject } from 'ai';
188
+ import { z } from 'zod';
189
+
190
+ const result = await generateObject({
191
+ model: aihubmix('gpt-4o-mini'),
192
+ schema: z.object({
193
+ recipe: z.object({
194
+ name: z.string(),
195
+ ingredients: z.array(
196
+ z.object({
197
+ name: z.string(),
198
+ amount: z.string(),
199
+ }),
200
+ ),
201
+ steps: z.array(z.string()),
202
+ }),
203
+ }),
204
+ prompt: 'Generate a lasagna recipe.',
205
+ });
206
+
207
+ console.log(JSON.stringify(result.object.recipe, null, 2));
208
+ console.log('Token usage:', result.usage);
209
+ console.log('Finish reason:', result.finishReason);
210
+ ```
211
+
212
+ ### Stream Object
213
+
214
+ ```ts
215
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
216
+ import { streamObject } from 'ai';
217
+ import { z } from 'zod';
218
+
219
+ const result = await streamObject({
220
+ model: aihubmix('gpt-4o-mini'),
221
+ schema: z.object({
222
+ recipe: z.object({
223
+ name: z.string(),
224
+ ingredients: z.array(
225
+ z.object({
226
+ name: z.string(),
227
+ amount: z.string(),
228
+ }),
229
+ ),
230
+ steps: z.array(z.string()),
231
+ }),
232
+ }),
233
+ prompt: 'Generate a lasagna recipe.',
234
+ });
235
+
236
+ for await (const objectPart of result.partialObjectStream) {
237
+ console.log(objectPart);
238
+ }
239
+
240
+ console.log('Token usage:', result.usage);
241
+ console.log('Final object:', result.object);
242
+ ```
243
+
244
+ ### Embed Many
245
+
246
+ ```ts
247
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
248
+ import { embedMany } from 'ai';
249
+
250
+ const { embeddings, usage } = await embedMany({
251
+ model: aihubmix.embedding('text-embedding-3-small'),
252
+ values: [
253
+ 'sunny day at the beach',
254
+ 'rainy afternoon in the city',
255
+ 'snowy night in the mountains',
256
+ ],
257
+ });
258
+
259
+ console.log('Embeddings:', embeddings);
260
+ console.log('Usage:', usage);
261
+ ```
262
+
263
+ ### Speech Synthesis
264
+
265
+ ```ts
266
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
267
+ import { generateSpeech } from 'ai';
268
+
269
+ const { audio } = await generateSpeech({
270
+ model: aihubmix.speech('tts-1'),
271
+ text: 'Hello, this is a test for speech synthesis.',
272
+ });
273
+
274
+ // Save the audio file
275
+ await saveAudioFile(audio);
276
+ console.log('Audio generated successfully:', audio);
277
+ ```
278
+
279
+ ### Tools
143
280
 
144
281
  The Aihubmix provider supports various tools including web search:
145
282
 
@@ -158,6 +295,10 @@ const { text } = await generateText({
158
295
  });
159
296
  ```
160
297
 
161
- ## Documentation
162
298
 
163
- Please check out the **[Aihubmix provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/aihubmix)** for more information.
299
+ ## Additional Resources
300
+
301
+ - [Aihubmix Provider Repository](https://github.com/inferera/aihubmix)
302
+ - [Aihubmix Documentation](https://docs.aihubmix.com/en)
303
+ - [Aihubmix Dashboard](https://aihubmix.com)
304
+ - [Aihubmix Cooperation](mailto:business@aihubmix.com)
package/README.zh.md ADDED
@@ -0,0 +1,301 @@
1
+ # AI SDK - Aihubmix Provider
2
+
3
+ <div align="center">
4
+ <a href="README.md">🇺🇸 English</a> |
5
+ <a href="README.zh.md">🇨🇳 中文</a> |
6
+ <a href="README.ja.md">🇯🇵 日本語</a>
7
+ </div>
8
+
9
+ > **🎉 10% 折扣!**
10
+ 已内置app-code,使用此方式请求所有模型可享受 10% 折扣。
11
+
12
+ **[Aihubmix 官方网站](https://aihubmix.com/)** | **[模型广场](https://aihubmix.com/models)**
13
+
14
+ **[Aihubmix provider](https://v5.ai-sdk.dev/providers/community-providers/aihubmix)** 适用于 [AI SDK](https://ai-sdk.dev/docs)
15
+ 一个网关,无限模型;一站式请求:OpenAI、Claude、Gemini、DeepSeek、Qwen 以及超过 500 个 AI 模型。
16
+
17
+ ## 支持的功能
18
+
19
+ Aihubmix provider 支持以下 AI 功能:
20
+
21
+ - **文本生成**:使用各种模型进行聊天完成
22
+ - **流式文本**:实时文本流式传输
23
+ - **图像生成**:从文本提示创建图像
24
+ - **嵌入**:单个和批量文本嵌入
25
+ - **对象生成**:使用模式的结构化数据生成
26
+ - **流式对象**:实时结构化数据流式传输
27
+ - **语音合成**:文本转语音转换
28
+ - **转录**:语音转文本转换
29
+ - **工具**:网络搜索和其他工具
30
+
31
+ ## 安装
32
+
33
+ Aihubmix 在 `@aihubmix/ai-sdk-provider` 模块中可用。您可以通过 [@aihubmix/ai-sdk-provider](https://www.npmjs.com/package/@aihubmix/ai-sdk-provider) 安装它
34
+
35
+ ```bash
36
+ npm i @aihubmix/ai-sdk-provider
37
+ ```
38
+
39
+ ## Provider 实例
40
+
41
+ 您可以从 `@aihubmix/ai-sdk-provider` 导入默认的 provider 实例 `aihubmix`:
42
+
43
+ ```ts
44
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
45
+ ```
46
+
47
+ ## 配置
48
+
49
+ 将您的 Aihubmix API 密钥设置为环境变量:
50
+
51
+ ```bash
52
+ export AIHUBMIX_API_KEY="your-api-key-here"
53
+ ```
54
+
55
+ 或直接传递给 provider:
56
+
57
+ ```ts
58
+ import { createAihubmix } from '@aihubmix/ai-sdk-provider';
59
+
60
+ const aihubmix = createAihubmix({
61
+ apiKey: 'your-api-key-here',
62
+ });
63
+ ```
64
+
65
+ ## 使用
66
+
67
+ 首先,导入必要的函数:
68
+
69
+ ```ts
70
+ import { createAihubmix } from '@aihubmix/ai-sdk-provider';
71
+ import {
72
+ generateText,
73
+ streamText,
74
+ generateImage,
75
+ embed,
76
+ embedMany,
77
+ generateObject,
78
+ streamObject,
79
+ generateSpeech,
80
+ transcribe
81
+ } from 'ai';
82
+ import { z } from 'zod';
83
+ ```
84
+
85
+ ### 生成文本
86
+
87
+ ```ts
88
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
89
+ import { generateText } from 'ai';
90
+
91
+ const { text } = await generateText({
92
+ model: aihubmix('o4-mini'),
93
+ prompt: '为4个人写一个素食千层面食谱。',
94
+ });
95
+ ```
96
+
97
+ ### Claude 模型
98
+
99
+ ```ts
100
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
101
+ import { generateText } from 'ai';
102
+
103
+ const { text } = await generateText({
104
+ model: aihubmix('claude-3-7-sonnet-20250219'),
105
+ prompt: '用简单的术语解释量子计算。',
106
+ });
107
+ ```
108
+
109
+ ### Gemini 模型
110
+
111
+ ```ts
112
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
113
+ import { generateText } from 'ai';
114
+
115
+ const { text } = await generateText({
116
+ model: aihubmix('gemini-2.5-flash'),
117
+ prompt: '创建一个Python脚本来对数字列表进行排序。',
118
+ });
119
+ ```
120
+
121
+ ### 图像生成
122
+
123
+ ```ts
124
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
125
+ import { generateImage } from 'ai';
126
+
127
+ const { image } = await generateImage({
128
+ model: aihubmix.image('gpt-image-1'),
129
+ prompt: '山间美丽的日落',
130
+ });
131
+ ```
132
+
133
+ ### 嵌入
134
+
135
+ ```ts
136
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
137
+ import { embed } from 'ai';
138
+
139
+ const { embedding } = await embed({
140
+ model: aihubmix.embedding('text-embedding-ada-002'),
141
+ value: '你好,世界!',
142
+ });
143
+ ```
144
+
145
+ ### 转录
146
+
147
+ ```ts
148
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
149
+ import { transcribe } from 'ai';
150
+
151
+ const { text } = await transcribe({
152
+ model: aihubmix.transcription('whisper-1'),
153
+ audio: audioFile,
154
+ });
155
+ ```
156
+
157
+ ### 流式文本
158
+
159
+ ```ts
160
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
161
+ import { streamText } from 'ai';
162
+
163
+ const result = streamText({
164
+ model: aihubmix('gpt-3.5-turbo'),
165
+ prompt: '写一个关于机器人学习绘画的短故事。',
166
+ maxOutputTokens: 256,
167
+ temperature: 0.3,
168
+ maxRetries: 3,
169
+ });
170
+
171
+ let fullText = '';
172
+ for await (const textPart of result.textStream) {
173
+ fullText += textPart;
174
+ process.stdout.write(textPart);
175
+ }
176
+
177
+ console.log('\n使用情况:', await result.usage);
178
+ console.log('完成原因:', await result.finishReason);
179
+ ```
180
+
181
+ ### 生成对象
182
+
183
+ ```ts
184
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
185
+ import { generateObject } from 'ai';
186
+ import { z } from 'zod';
187
+
188
+ const result = await generateObject({
189
+ model: aihubmix('gpt-4o-mini'),
190
+ schema: z.object({
191
+ recipe: z.object({
192
+ name: z.string(),
193
+ ingredients: z.array(
194
+ z.object({
195
+ name: z.string(),
196
+ amount: z.string(),
197
+ }),
198
+ ),
199
+ steps: z.array(z.string()),
200
+ }),
201
+ }),
202
+ prompt: '生成一个千层面食谱。',
203
+ });
204
+
205
+ console.log(JSON.stringify(result.object.recipe, null, 2));
206
+ console.log('Token使用情况:', result.usage);
207
+ console.log('完成原因:', result.finishReason);
208
+ ```
209
+
210
+ ### 流式对象
211
+
212
+ ```ts
213
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
214
+ import { streamObject } from 'ai';
215
+ import { z } from 'zod';
216
+
217
+ const result = await streamObject({
218
+ model: aihubmix('gpt-4o-mini'),
219
+ schema: z.object({
220
+ recipe: z.object({
221
+ name: z.string(),
222
+ ingredients: z.array(
223
+ z.object({
224
+ name: z.string(),
225
+ amount: z.string(),
226
+ }),
227
+ ),
228
+ steps: z.array(z.string()),
229
+ }),
230
+ }),
231
+ prompt: '生成一个千层面食谱。',
232
+ });
233
+
234
+ for await (const objectPart of result.partialObjectStream) {
235
+ console.log(objectPart);
236
+ }
237
+
238
+ console.log('Token使用情况:', result.usage);
239
+ console.log('最终对象:', result.object);
240
+ ```
241
+
242
+ ### 批量嵌入
243
+
244
+ ```ts
245
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
246
+ import { embedMany } from 'ai';
247
+
248
+ const { embeddings, usage } = await embedMany({
249
+ model: aihubmix.embedding('text-embedding-3-small'),
250
+ values: [
251
+ '海滩上的晴天',
252
+ '城市里的雨天下午',
253
+ '山间的雪夜',
254
+ ],
255
+ });
256
+
257
+ console.log('嵌入向量:', embeddings);
258
+ console.log('使用情况:', usage);
259
+ ```
260
+
261
+ ### 语音合成
262
+
263
+ ```ts
264
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
265
+ import { generateSpeech } from 'ai';
266
+
267
+ const { audio } = await generateSpeech({
268
+ model: aihubmix.speech('tts-1'),
269
+ text: '你好,这是语音合成的测试。',
270
+ });
271
+
272
+ // 保存音频文件
273
+ await saveAudioFile(audio);
274
+ console.log('音频生成成功:', audio);
275
+ ```
276
+
277
+ ### 工具
278
+
279
+ Aihubmix provider 支持各种工具,包括网络搜索:
280
+
281
+ ```ts
282
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
283
+ import { generateText } from 'ai';
284
+
285
+ const { text } = await generateText({
286
+ model: aihubmix('gpt-4'),
287
+ prompt: 'AI的最新发展是什么?',
288
+ tools: {
289
+ webSearchPreview: aihubmix.tools.webSearchPreview({
290
+ searchContextSize: 'high',
291
+ }),
292
+ },
293
+ });
294
+ ```
295
+
296
+ ## 附加资源
297
+
298
+ - [Aihubmix Provider 仓库](https://github.com/inferera/aihubmix)
299
+ - [Aihubmix 文档](https://docs.aihubmix.com/en)
300
+ - [Aihubmix 控制台](https://aihubmix.com)
301
+ - [Aihubmix 商务合作](mailto:business@aihubmix.com)
package/dist/index.d.mts CHANGED
@@ -14,10 +14,12 @@ declare function webSearchPreviewTool({ searchContextSize, userLocation, }?: {
14
14
  timezone?: string;
15
15
  };
16
16
  }): {
17
- type: 'provider-defined';
18
- id: 'aihubmix.web_search_preview';
19
- args: {};
20
- parameters: typeof WebSearchPreviewParameters;
17
+ type: 'function';
18
+ function: {
19
+ name: string;
20
+ description: string;
21
+ parameters: typeof WebSearchPreviewParameters;
22
+ };
21
23
  };
22
24
  declare const aihubmixTools: {
23
25
  webSearchPreview: typeof webSearchPreviewTool;
package/dist/index.d.ts CHANGED
@@ -14,10 +14,12 @@ declare function webSearchPreviewTool({ searchContextSize, userLocation, }?: {
14
14
  timezone?: string;
15
15
  };
16
16
  }): {
17
- type: 'provider-defined';
18
- id: 'aihubmix.web_search_preview';
19
- args: {};
20
- parameters: typeof WebSearchPreviewParameters;
17
+ type: 'function';
18
+ function: {
19
+ name: string;
20
+ description: string;
21
+ parameters: typeof WebSearchPreviewParameters;
22
+ };
21
23
  };
22
24
  declare const aihubmixTools: {
23
25
  webSearchPreview: typeof webSearchPreviewTool;
package/dist/index.js CHANGED
@@ -39,13 +39,12 @@ function webSearchPreviewTool({
39
39
  userLocation
40
40
  } = {}) {
41
41
  return {
42
- type: "provider-defined",
43
- id: "aihubmix.web_search_preview",
44
- args: {
45
- searchContextSize,
46
- userLocation
47
- },
48
- parameters: WebSearchPreviewParameters
42
+ type: "function",
43
+ function: {
44
+ name: "aihubmix.web_search_preview",
45
+ description: "Search the web for current information and preview results",
46
+ parameters: WebSearchPreviewParameters
47
+ }
49
48
  };
50
49
  }
51
50
  var aihubmixTools = {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/aihubmix-provider.ts","../src/aihubmix-tools.ts"],"sourcesContent":["export { aihubmix, createAihubmix } from './aihubmix-provider';\nexport type {\n AihubmixProvider,\n AihubmixProviderSettings,\n} from './aihubmix-provider';\n","import {\n OpenAIChatLanguageModel,\n OpenAICompletionLanguageModel,\n OpenAIEmbeddingModel,\n OpenAIImageModel,\n OpenAIResponsesLanguageModel,\n OpenAITranscriptionModel,\n OpenAISpeechModel,\n} from '@ai-sdk/openai/internal';\nimport { AnthropicMessagesLanguageModel } from '@ai-sdk/anthropic/internal';\nimport { GoogleGenerativeAILanguageModel } from '@ai-sdk/google/internal';\nimport {\n EmbeddingModelV2,\n LanguageModelV2,\n ProviderV2,\n ImageModelV2,\n TranscriptionModelV2,\n SpeechModelV2,\n TranscriptionModelV2CallOptions,\n} from '@ai-sdk/provider';\nimport { FetchFunction, loadApiKey } from '@ai-sdk/provider-utils';\nimport { aihubmixTools } from './aihubmix-tools';\n\n// 导入设置类型\nimport type { OpenAIProviderSettings } from '@ai-sdk/openai';\n\n\nexport interface AihubmixProvider extends ProviderV2 {\n (deploymentId: string, settings?: OpenAIProviderSettings): LanguageModelV2;\n\n languageModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV2;\n\n chat(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV2;\n\n responses(deploymentId: string): LanguageModelV2;\n\n completion(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV2;\n\n embedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV2<string>;\n\n image(deploymentId: string, settings?: OpenAIProviderSettings): ImageModelV2;\n\n imageModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): ImageModelV2;\n\n textEmbedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV2<string>;\n\n textEmbeddingModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV2<string>;\n\n transcription(deploymentId: string): TranscriptionModelV2;\n\n speech(deploymentId: string): SpeechModelV2;\n\n speechModel(deploymentId: string): SpeechModelV2;\n\n tools: typeof aihubmixTools;\n}\n\nexport interface AihubmixProviderSettings {\n apiKey?: string;\n fetch?: FetchFunction;\n compatibility?: 'strict' | 'compatible';\n}\n\nclass AihubmixTranscriptionModel extends OpenAITranscriptionModel {\n async doGenerate(options: TranscriptionModelV2CallOptions) {\n // 根据MIME类型设置正确的文件扩展名\n if (options.mediaType) {\n const mimeTypeMap: Record<string, string> = {\n 'audio/mpeg': 'mp3',\n 'audio/mp3': 'mp3',\n 'audio/wav': 'wav',\n 'audio/flac': 'flac',\n 'audio/m4a': 'm4a',\n 'audio/mp4': 'mp4',\n 'audio/ogg': 'ogg',\n 'audio/webm': 'webm',\n 'audio/oga': 'oga',\n 'audio/mpga': 'mpga',\n };\n \n const extension = mimeTypeMap[options.mediaType];\n if (extension) {\n // 重写getArgs方法来设置正确的文件名\n const originalGetArgs = (this as any).getArgs;\n (this as any).getArgs = async function(args: any) {\n const result = await originalGetArgs.call(this, args);\n if (result.formData) {\n // 找到file字段并修改文件名\n const fileEntry = result.formData.get('file');\n if (fileEntry && typeof fileEntry === 'object' && 'name' in fileEntry) {\n // 创建新的 File 对象,设置正确的文件名\n try {\n const newFile = new File([fileEntry], `audio.${extension}`, { \n type: options.mediaType \n });\n result.formData.set('file', newFile);\n } catch (error) {\n console.log('Failed to create new File object:', error);\n // 如果创建新 File 对象失败,尝试其他方法\n // 在 Node.js 环境中,可能需要使用 Buffer 或其他方式\n if (fileEntry && typeof fileEntry === 'object' && 'arrayBuffer' in fileEntry) {\n try {\n const arrayBuffer = await (fileEntry as any).arrayBuffer();\n const newFile = new File([arrayBuffer], `audio.${extension}`, { \n type: options.mediaType \n });\n result.formData.set('file', newFile);\n console.log('Created new file from arrayBuffer with name:', `audio.${extension}`);\n } catch (bufferError) {\n console.log('Failed to create file from arrayBuffer:', bufferError);\n }\n }\n }\n }\n }\n return result;\n };\n }\n }\n \n return super.doGenerate(options);\n }\n}\n\nexport function createAihubmix(\n options: AihubmixProviderSettings = {},\n): AihubmixProvider {\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': 'WHVL9885',\n 'Content-Type': 'application/json',\n });\n\n const getTranscriptionHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': 'WHVL9885',\n });\n\n const url = ({ path, modelId }: { path: string; modelId: string }) => {\n const baseURL = 'https://aihubmix.com/v1';\n return `${baseURL}${path}`;\n };\n\n const createChatModel = (\n deploymentName: string,\n settings: OpenAIProviderSettings = {},\n ) => {\n const headers = getHeaders();\n if (deploymentName.startsWith('claude-')) {\n return new AnthropicMessagesLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n baseURL: url({ path: '', modelId: deploymentName }),\n headers: {\n ...headers,\n 'x-api-key': headers['Authorization'].split(' ')[1],\n },\n supportedUrls: () => ({\n 'image/*': [/^https?:\\/\\/.*$/],\n }),\n });\n }\n if (\n (deploymentName.startsWith('gemini') ||\n deploymentName.startsWith('imagen')) &&\n !deploymentName.endsWith('-nothink') &&\n !deploymentName.endsWith('-search')\n ) {\n return new GoogleGenerativeAILanguageModel(\n deploymentName,\n {\n provider: 'aihubmix.chat',\n baseURL: 'https://aihubmix.com/gemini/v1beta',\n headers: {\n ...headers,\n 'x-goog-api-key': headers['Authorization'].split(' ')[1],\n },\n generateId: () => `aihubmix-${Date.now()}`,\n supportedUrls: () => ({}),\n },\n );\n }\n\n return new OpenAIChatLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n };\n\n const createCompletionModel = (\n modelId: string,\n settings: any = {},\n ) =>\n new OpenAICompletionLanguageModel(modelId, {\n provider: 'aihubmix.completion',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createEmbeddingModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAIEmbeddingModel(modelId, {\n provider: 'aihubmix.embeddings',\n headers: getHeaders,\n url,\n fetch: options.fetch,\n });\n };\n\n const createResponsesModel = (modelId: string) =>\n new OpenAIResponsesLanguageModel(modelId, {\n provider: 'aihubmix.responses',\n url,\n headers: getHeaders,\n });\n\n const createImageModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAIImageModel(modelId, {\n provider: 'aihubmix.image',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n };\n\n const createTranscriptionModel = (modelId: string) =>\n new AihubmixTranscriptionModel(modelId, {\n provider: 'aihubmix.transcription',\n url,\n headers: getTranscriptionHeaders,\n fetch: options.fetch,\n });\n const createSpeechModel = (modelId: string) =>\n new OpenAISpeechModel(modelId, {\n provider: 'aihubmix.speech',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n const provider = function (\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ) {\n if (new.target) {\n throw new Error(\n 'The Aihubmix model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(deploymentId, settings);\n };\n\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.completion = createCompletionModel;\n provider.responses = createResponsesModel;\n provider.embedding = createEmbeddingModel;\n provider.textEmbedding = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n\n provider.tools = aihubmixTools;\n\n return provider as AihubmixProvider;\n}\n\nexport const aihubmix = createAihubmix();\n","import { z } from 'zod';\n\nconst WebSearchPreviewParameters = z.object({});\n\nfunction webSearchPreviewTool({\n searchContextSize,\n userLocation,\n}: {\n searchContextSize?: 'low' | 'medium' | 'high';\n userLocation?: {\n type?: 'approximate';\n city?: string;\n region?: string;\n country?: string;\n timezone?: string;\n };\n} = {}): {\n type: 'provider-defined';\n id: 'aihubmix.web_search_preview';\n args: {};\n parameters: typeof WebSearchPreviewParameters;\n} {\n return {\n type: 'provider-defined',\n id: 'aihubmix.web_search_preview',\n args: {\n searchContextSize,\n userLocation,\n },\n parameters: WebSearchPreviewParameters,\n };\n}\n\nexport const aihubmixTools = {\n webSearchPreview: webSearchPreviewTool,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAQO;AACP,IAAAA,mBAA+C;AAC/C,IAAAA,mBAAgD;AAUhD,4BAA0C;;;ACpB1C,iBAAkB;AAElB,IAAM,6BAA6B,aAAE,OAAO,CAAC,CAAC;AAE9C,SAAS,qBAAqB;AAAA,EAC5B;AAAA,EACA;AACF,IASI,CAAC,GAKH;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,IAAI;AAAA,IACJ,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AACF;AAEO,IAAM,gBAAgB;AAAA,EAC3B,kBAAkB;AACpB;;;ADiDA,IAAM,6BAAN,cAAyC,yCAAyB;AAAA,EAChE,MAAM,WAAW,SAA0C;AAEzD,QAAI,QAAQ,WAAW;AACrB,YAAM,cAAsC;AAAA,QAC1C,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QACb,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QACb,aAAa;AAAA,QACb,cAAc;AAAA,QACd,aAAa;AAAA,QACb,cAAc;AAAA,MAChB;AAEA,YAAM,YAAY,YAAY,QAAQ,SAAS;AAC/C,UAAI,WAAW;AAEb,cAAM,kBAAmB,KAAa;AACtC,QAAC,KAAa,UAAU,eAAe,MAAW;AAChD,gBAAM,SAAS,MAAM,gBAAgB,KAAK,MAAM,IAAI;AACpD,cAAI,OAAO,UAAU;AAEnB,kBAAM,YAAY,OAAO,SAAS,IAAI,MAAM;AAC5C,gBAAI,aAAa,OAAO,cAAc,YAAY,UAAU,WAAW;AAErE,kBAAI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ACvC,UAAU;AAAA,MACV,SAAS;AAAA,MACT;AAAA,MACA,OAAO,QAAQ;AAAA,IACjB,CAAC;AAAA,EACH;AAEA,QAAM,uBAAuB,CAAC,YAC5B,IAAI,6CAA6B,SAAS;AAAA,IACxC,UAAU;AAAA,IACV;AAAA,IACA,SAAS;AAAA,EACX,CAAC;AAEH,QAAM,mBAAmB,CACvB,SACA,WAAgB,CAAC,MACd;AACH,WAAO,IAAI,iCAAiB,SAAS;AAAA,MACnC,UAAU;AAAA,MACV;AAAA,MACA,SAAS;AAAA,MACT,OAAO,QAAQ;AAAA,IACjB,CAAC;AAAA,EACH;AAEA,QAAM,2BAA2B,CAAC,YAChC,IAAI,2BAA2B,SAAS;AAAA,IACtC,UAAU;AAAA,IACV;AAAA,IACA,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB,CAAC;AACH,QAAM,oBAAoB,CAAC,YACzB,IAAI,kCAAkB,SAAS;AAAA,IAC7B,UAAU;AAAA,IACV;AAAA,IACA,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB,CAAC;AACH,QAAM,WAAW,SACf,cACA,UACA;AACA,QAAI,YAAY;AACd,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,gBAAgB,cAAc,QAAQ;AAAA,EAC/C;AAEA,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAChB,WAAS,aAAa;AACtB,WAAS,YAAY;AACrB,WAAS,YAAY;AACrB,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAE9B,WAAS,QAAQ;AACjB,WAAS,aAAa;AAEtB,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAE9B,WAAS,SAAS;AAClB,WAAS,cAAc;AAEvB,WAAS,QAAQ;AAEjB,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":["import_internal"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/aihubmix-provider.ts","../src/aihubmix-tools.ts"],"sourcesContent":["export { aihubmix, createAihubmix } from './aihubmix-provider';\nexport type {\n AihubmixProvider,\n AihubmixProviderSettings,\n} from './aihubmix-provider';\n","import {\n OpenAIChatLanguageModel,\n OpenAICompletionLanguageModel,\n OpenAIEmbeddingModel,\n OpenAIImageModel,\n OpenAIResponsesLanguageModel,\n OpenAITranscriptionModel,\n OpenAISpeechModel,\n} from '@ai-sdk/openai/internal';\nimport { AnthropicMessagesLanguageModel } from '@ai-sdk/anthropic/internal';\nimport { GoogleGenerativeAILanguageModel } from '@ai-sdk/google/internal';\nimport {\n EmbeddingModelV2,\n LanguageModelV2,\n ProviderV2,\n ImageModelV2,\n TranscriptionModelV2,\n SpeechModelV2,\n TranscriptionModelV2CallOptions,\n} from '@ai-sdk/provider';\nimport { FetchFunction, loadApiKey } from '@ai-sdk/provider-utils';\nimport { aihubmixTools } from './aihubmix-tools';\n\n// 导入设置类型\nimport type { OpenAIProviderSettings } from '@ai-sdk/openai';\n\n\nexport interface AihubmixProvider extends ProviderV2 {\n (deploymentId: string, settings?: OpenAIProviderSettings): LanguageModelV2;\n\n languageModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV2;\n\n chat(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV2;\n\n responses(deploymentId: string): LanguageModelV2;\n\n completion(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV2;\n\n embedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV2<string>;\n\n image(deploymentId: string, settings?: OpenAIProviderSettings): ImageModelV2;\n\n imageModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): ImageModelV2;\n\n textEmbedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV2<string>;\n\n textEmbeddingModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV2<string>;\n\n transcription(deploymentId: string): TranscriptionModelV2;\n\n speech(deploymentId: string): SpeechModelV2;\n\n speechModel(deploymentId: string): SpeechModelV2;\n\n tools: typeof aihubmixTools;\n}\n\nexport interface AihubmixProviderSettings {\n apiKey?: string;\n fetch?: FetchFunction;\n compatibility?: 'strict' | 'compatible';\n}\n\nclass AihubmixTranscriptionModel extends OpenAITranscriptionModel {\n async doGenerate(options: TranscriptionModelV2CallOptions) {\n // 根据MIME类型设置正确的文件扩展名\n if (options.mediaType) {\n const mimeTypeMap: Record<string, string> = {\n 'audio/mpeg': 'mp3',\n 'audio/mp3': 'mp3',\n 'audio/wav': 'wav',\n 'audio/flac': 'flac',\n 'audio/m4a': 'm4a',\n 'audio/mp4': 'mp4',\n 'audio/ogg': 'ogg',\n 'audio/webm': 'webm',\n 'audio/oga': 'oga',\n 'audio/mpga': 'mpga',\n };\n \n const extension = mimeTypeMap[options.mediaType];\n if (extension) {\n // 重写getArgs方法来设置正确的文件名\n const originalGetArgs = (this as any).getArgs;\n (this as any).getArgs = async function(args: any) {\n const result = await originalGetArgs.call(this, args);\n if (result.formData) {\n // 找到file字段并修改文件名\n const fileEntry = result.formData.get('file');\n if (fileEntry && typeof fileEntry === 'object' && 'name' in fileEntry) {\n // 创建新的 File 对象,设置正确的文件名\n try {\n const newFile = new File([fileEntry], `audio.${extension}`, { \n type: options.mediaType \n });\n result.formData.set('file', newFile);\n } catch (error) {\n console.log('Failed to create new File object:', error);\n // 如果创建新 File 对象失败,尝试其他方法\n // 在 Node.js 环境中,可能需要使用 Buffer 或其他方式\n if (fileEntry && typeof fileEntry === 'object' && 'arrayBuffer' in fileEntry) {\n try {\n const arrayBuffer = await (fileEntry as any).arrayBuffer();\n const newFile = new File([arrayBuffer], `audio.${extension}`, { \n type: options.mediaType \n });\n result.formData.set('file', newFile);\n console.log('Created new file from arrayBuffer with name:', `audio.${extension}`);\n } catch (bufferError) {\n console.log('Failed to create file from arrayBuffer:', bufferError);\n }\n }\n }\n }\n }\n return result;\n };\n }\n }\n \n return super.doGenerate(options);\n }\n}\n\nexport function createAihubmix(\n options: AihubmixProviderSettings = {},\n): AihubmixProvider {\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': 'WHVL9885',\n 'Content-Type': 'application/json',\n });\n\n const getTranscriptionHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': 'WHVL9885',\n });\n\n const url = ({ path, modelId }: { path: string; modelId: string }) => {\n const baseURL = 'https://aihubmix.com/v1';\n return `${baseURL}${path}`;\n };\n\n const createChatModel = (\n deploymentName: string,\n settings: OpenAIProviderSettings = {},\n ) => {\n const headers = getHeaders();\n if (deploymentName.startsWith('claude-')) {\n return new AnthropicMessagesLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n baseURL: url({ path: '', modelId: deploymentName }),\n headers: {\n ...headers,\n 'x-api-key': headers['Authorization'].split(' ')[1],\n },\n supportedUrls: () => ({\n 'image/*': [/^https?:\\/\\/.*$/],\n }),\n });\n }\n if (\n (deploymentName.startsWith('gemini') ||\n deploymentName.startsWith('imagen')) &&\n !deploymentName.endsWith('-nothink') &&\n !deploymentName.endsWith('-search')\n ) {\n return new GoogleGenerativeAILanguageModel(\n deploymentName,\n {\n provider: 'aihubmix.chat',\n baseURL: 'https://aihubmix.com/gemini/v1beta',\n headers: {\n ...headers,\n 'x-goog-api-key': headers['Authorization'].split(' ')[1],\n },\n generateId: () => `aihubmix-${Date.now()}`,\n supportedUrls: () => ({}),\n },\n );\n }\n\n return new OpenAIChatLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n };\n\n const createCompletionModel = (\n modelId: string,\n settings: any = {},\n ) =>\n new OpenAICompletionLanguageModel(modelId, {\n provider: 'aihubmix.completion',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createEmbeddingModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAIEmbeddingModel(modelId, {\n provider: 'aihubmix.embeddings',\n headers: getHeaders,\n url,\n fetch: options.fetch,\n });\n };\n\n const createResponsesModel = (modelId: string) =>\n new OpenAIResponsesLanguageModel(modelId, {\n provider: 'aihubmix.responses',\n url,\n headers: getHeaders,\n });\n\n const createImageModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAIImageModel(modelId, {\n provider: 'aihubmix.image',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n };\n\n const createTranscriptionModel = (modelId: string) =>\n new AihubmixTranscriptionModel(modelId, {\n provider: 'aihubmix.transcription',\n url,\n headers: getTranscriptionHeaders,\n fetch: options.fetch,\n });\n const createSpeechModel = (modelId: string) =>\n new OpenAISpeechModel(modelId, {\n provider: 'aihubmix.speech',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n const provider = function (\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ) {\n if (new.target) {\n throw new Error(\n 'The Aihubmix model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(deploymentId, settings);\n };\n\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.completion = createCompletionModel;\n provider.responses = createResponsesModel;\n provider.embedding = createEmbeddingModel;\n provider.textEmbedding = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n\n provider.tools = aihubmixTools;\n\n return provider as AihubmixProvider;\n}\n\nexport const aihubmix = createAihubmix();\n","import { z } from 'zod';\n\nconst WebSearchPreviewParameters = z.object({});\n\nfunction webSearchPreviewTool({\n searchContextSize,\n userLocation,\n}: {\n searchContextSize?: 'low' | 'medium' | 'high';\n userLocation?: {\n type?: 'approximate';\n city?: string;\n region?: string;\n country?: string;\n timezone?: string;\n };\n} = {}): {\n type: 'function';\n function: {\n name: string;\n description: string;\n parameters: typeof WebSearchPreviewParameters;\n };\n} {\n return {\n type: 'function',\n function: {\n name: 'aihubmix.web_search_preview',\n description: 'Search the web for current information and preview results',\n parameters: WebSearchPreviewParameters,\n },\n };\n}\n\nexport const aihubmixTools = {\n webSearchPreview: webSearchPreviewTool,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAQO;AACP,IAAAA,mBAA+C;AAC/C,IAAAA,mBAAgD;AAUhD,4BAA0C;;;ACpB1C,iBAAkB;AAElB,IAAM,6BAA6B,aAAE,OAAO,CAAC,CAAC;AAE9C,SAAS,qBAAqB;AAAA,EAC5B;AAAA,EACA;AACF,IASI,CAAC,GAOH;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,IACd;AAAA,EACF;AACF;AAEO,IAAM,gBAAgB;AAAA,EAC3B,kBAAkB;AACpB;;;ADgDA,IAAM,6BAAN,cAAyC,yCAAyB;AAAA,EAChE,MAAM,WAAW,SAA0C;AAEzD,QAAI,QAAQ,WAAW;AACrB,YAAM,cAAsC;AAAA,QAC1C,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QACb,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QACb,aAAa;AAAA,QACb,cAAc;AAAA,QACd,aAAa;AAAA,QACb,cAAc;AAAA,MAChB;AAEA,YAAM,YAAY,YAAY,QAAQ,SAAS;AAC/C,UAAI,WAAW;AAEb,cAAM,kBAAmB,KAAa;AACtC,QAAC,KAAa,UAAU,eAAe,MAAW;AAChD,gBAAM,SAAS,MAAM,gBAAgB,KAAK,MAAM,IAAI;AACpD,cAAI,OAAO,UAAU;AAEnB,kBAAM,YAAY,OAAO,SAAS,IAAI,MAAM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13 +20,12 @@ function webSearchPreviewTool({
20
20
  userLocation
21
21
  } = {}) {
22
22
  return {
23
- type: "provider-defined",
24
- id: "aihubmix.web_search_preview",
25
- args: {
26
- searchContextSize,
27
- userLocation
28
- },
29
- parameters: WebSearchPreviewParameters
23
+ type: "function",
24
+ function: {
25
+ name: "aihubmix.web_search_preview",
26
+ description: "Search the web for current information and preview results",
27
+ parameters: WebSearchPreviewParameters
28
+ }
30
29
  };
31
30
  }
32
31
  var aihubmixTools = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/aihubmix-provider.ts","../src/aihubmix-tools.ts"],"sourcesContent":["import {\n OpenAIChatLanguageModel,\n OpenAICompletionLanguageModel,\n OpenAIEmbeddingModel,\n OpenAIImageModel,\n OpenAIResponsesLanguageModel,\n OpenAITranscriptionModel,\n OpenAISpeechModel,\n} from '@ai-sdk/openai/internal';\nimport { AnthropicMessagesLanguageModel } from '@ai-sdk/anthropic/internal';\nimport { GoogleGenerativeAILanguageModel } from '@ai-sdk/google/internal';\nimport {\n EmbeddingModelV2,\n LanguageModelV2,\n ProviderV2,\n ImageModelV2,\n TranscriptionModelV2,\n SpeechModelV2,\n TranscriptionModelV2CallOptions,\n} from '@ai-sdk/provider';\nimport { FetchFunction, loadApiKey } from '@ai-sdk/provider-utils';\nimport { aihubmixTools } from './aihubmix-tools';\n\n// 导入设置类型\nimport type { OpenAIProviderSettings } from '@ai-sdk/openai';\n\n\nexport interface AihubmixProvider extends ProviderV2 {\n (deploymentId: string, settings?: OpenAIProviderSettings): LanguageModelV2;\n\n languageModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV2;\n\n chat(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV2;\n\n responses(deploymentId: string): LanguageModelV2;\n\n completion(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV2;\n\n embedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV2<string>;\n\n image(deploymentId: string, settings?: OpenAIProviderSettings): ImageModelV2;\n\n imageModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): ImageModelV2;\n\n textEmbedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV2<string>;\n\n textEmbeddingModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV2<string>;\n\n transcription(deploymentId: string): TranscriptionModelV2;\n\n speech(deploymentId: string): SpeechModelV2;\n\n speechModel(deploymentId: string): SpeechModelV2;\n\n tools: typeof aihubmixTools;\n}\n\nexport interface AihubmixProviderSettings {\n apiKey?: string;\n fetch?: FetchFunction;\n compatibility?: 'strict' | 'compatible';\n}\n\nclass AihubmixTranscriptionModel extends OpenAITranscriptionModel {\n async doGenerate(options: TranscriptionModelV2CallOptions) {\n // 根据MIME类型设置正确的文件扩展名\n if (options.mediaType) {\n const mimeTypeMap: Record<string, string> = {\n 'audio/mpeg': 'mp3',\n 'audio/mp3': 'mp3',\n 'audio/wav': 'wav',\n 'audio/flac': 'flac',\n 'audio/m4a': 'm4a',\n 'audio/mp4': 'mp4',\n 'audio/ogg': 'ogg',\n 'audio/webm': 'webm',\n 'audio/oga': 'oga',\n 'audio/mpga': 'mpga',\n };\n \n const extension = mimeTypeMap[options.mediaType];\n if (extension) {\n // 重写getArgs方法来设置正确的文件名\n const originalGetArgs = (this as any).getArgs;\n (this as any).getArgs = async function(args: any) {\n const result = await originalGetArgs.call(this, args);\n if (result.formData) {\n // 找到file字段并修改文件名\n const fileEntry = result.formData.get('file');\n if (fileEntry && typeof fileEntry === 'object' && 'name' in fileEntry) {\n // 创建新的 File 对象,设置正确的文件名\n try {\n const newFile = new File([fileEntry], `audio.${extension}`, { \n type: options.mediaType \n });\n result.formData.set('file', newFile);\n } catch (error) {\n console.log('Failed to create new File object:', error);\n // 如果创建新 File 对象失败,尝试其他方法\n // 在 Node.js 环境中,可能需要使用 Buffer 或其他方式\n if (fileEntry && typeof fileEntry === 'object' && 'arrayBuffer' in fileEntry) {\n try {\n const arrayBuffer = await (fileEntry as any).arrayBuffer();\n const newFile = new File([arrayBuffer], `audio.${extension}`, { \n type: options.mediaType \n });\n result.formData.set('file', newFile);\n console.log('Created new file from arrayBuffer with name:', `audio.${extension}`);\n } catch (bufferError) {\n console.log('Failed to create file from arrayBuffer:', bufferError);\n }\n }\n }\n }\n }\n return result;\n };\n }\n }\n \n return super.doGenerate(options);\n }\n}\n\nexport function createAihubmix(\n options: AihubmixProviderSettings = {},\n): AihubmixProvider {\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': 'WHVL9885',\n 'Content-Type': 'application/json',\n });\n\n const getTranscriptionHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': 'WHVL9885',\n });\n\n const url = ({ path, modelId }: { path: string; modelId: string }) => {\n const baseURL = 'https://aihubmix.com/v1';\n return `${baseURL}${path}`;\n };\n\n const createChatModel = (\n deploymentName: string,\n settings: OpenAIProviderSettings = {},\n ) => {\n const headers = getHeaders();\n if (deploymentName.startsWith('claude-')) {\n return new AnthropicMessagesLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n baseURL: url({ path: '', modelId: deploymentName }),\n headers: {\n ...headers,\n 'x-api-key': headers['Authorization'].split(' ')[1],\n },\n supportedUrls: () => ({\n 'image/*': [/^https?:\\/\\/.*$/],\n }),\n });\n }\n if (\n (deploymentName.startsWith('gemini') ||\n deploymentName.startsWith('imagen')) &&\n !deploymentName.endsWith('-nothink') &&\n !deploymentName.endsWith('-search')\n ) {\n return new GoogleGenerativeAILanguageModel(\n deploymentName,\n {\n provider: 'aihubmix.chat',\n baseURL: 'https://aihubmix.com/gemini/v1beta',\n headers: {\n ...headers,\n 'x-goog-api-key': headers['Authorization'].split(' ')[1],\n },\n generateId: () => `aihubmix-${Date.now()}`,\n supportedUrls: () => ({}),\n },\n );\n }\n\n return new OpenAIChatLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n };\n\n const createCompletionModel = (\n modelId: string,\n settings: any = {},\n ) =>\n new OpenAICompletionLanguageModel(modelId, {\n provider: 'aihubmix.completion',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createEmbeddingModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAIEmbeddingModel(modelId, {\n provider: 'aihubmix.embeddings',\n headers: getHeaders,\n url,\n fetch: options.fetch,\n });\n };\n\n const createResponsesModel = (modelId: string) =>\n new OpenAIResponsesLanguageModel(modelId, {\n provider: 'aihubmix.responses',\n url,\n headers: getHeaders,\n });\n\n const createImageModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAIImageModel(modelId, {\n provider: 'aihubmix.image',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n };\n\n const createTranscriptionModel = (modelId: string) =>\n new AihubmixTranscriptionModel(modelId, {\n provider: 'aihubmix.transcription',\n url,\n headers: getTranscriptionHeaders,\n fetch: options.fetch,\n });\n const createSpeechModel = (modelId: string) =>\n new OpenAISpeechModel(modelId, {\n provider: 'aihubmix.speech',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n const provider = function (\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ) {\n if (new.target) {\n throw new Error(\n 'The Aihubmix model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(deploymentId, settings);\n };\n\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.completion = createCompletionModel;\n provider.responses = createResponsesModel;\n provider.embedding = createEmbeddingModel;\n provider.textEmbedding = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n\n provider.tools = aihubmixTools;\n\n return provider as AihubmixProvider;\n}\n\nexport const aihubmix = createAihubmix();\n","import { z } from 'zod';\n\nconst WebSearchPreviewParameters = z.object({});\n\nfunction webSearchPreviewTool({\n searchContextSize,\n userLocation,\n}: {\n searchContextSize?: 'low' | 'medium' | 'high';\n userLocation?: {\n type?: 'approximate';\n city?: string;\n region?: string;\n country?: string;\n timezone?: string;\n };\n} = {}): {\n type: 'provider-defined';\n id: 'aihubmix.web_search_preview';\n args: {};\n parameters: typeof WebSearchPreviewParameters;\n} {\n return {\n type: 'provider-defined',\n id: 'aihubmix.web_search_preview',\n args: {\n searchContextSize,\n userLocation,\n },\n parameters: WebSearchPreviewParameters,\n };\n}\n\nexport const aihubmixTools = {\n webSearchPreview: webSearchPreviewTool,\n};\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sCAAsC;AAC/C,SAAS,uCAAuC;AAUhD,SAAwB,kBAAkB;;;ACpB1C,SAAS,SAAS;AAElB,IAAM,6BAA6B,EAAE,OAAO,CAAC,CAAC;AAE9C,SAAS,qBAAqB;AAAA,EAC5B;AAAA,EACA;AACF,IASI,CAAC,GAKH;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,IAAI;AAAA,IACJ,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AACF;AAEO,IAAM,gBAAgB;AAAA,EAC3B,kBAAkB;AACpB;;;ADiDA,IAAM,6BAAN,cAAyC,yBAAyB;AAAA,EAChE,MAAM,WAAW,SAA0C;AAEzD,QAAI,QAAQ,WAAW;AACrB,YAAM,cAAsC;AAAA,QAC1C,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QACb,c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AEA,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAChB,WAAS,aAAa;AACtB,WAAS,YAAY;AACrB,WAAS,YAAY;AACrB,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAE9B,WAAS,QAAQ;AACjB,WAAS,aAAa;AAEtB,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAE9B,WAAS,SAAS;AAClB,WAAS,cAAc;AAEvB,WAAS,QAAQ;AAEjB,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":[]}
1
+ {"version":3,"sources":["../src/aihubmix-provider.ts","../src/aihubmix-tools.ts"],"sourcesContent":["import {\n OpenAIChatLanguageModel,\n OpenAICompletionLanguageModel,\n OpenAIEmbeddingModel,\n OpenAIImageModel,\n OpenAIResponsesLanguageModel,\n OpenAITranscriptionModel,\n OpenAISpeechModel,\n} from '@ai-sdk/openai/internal';\nimport { AnthropicMessagesLanguageModel } from '@ai-sdk/anthropic/internal';\nimport { GoogleGenerativeAILanguageModel } from '@ai-sdk/google/internal';\nimport {\n EmbeddingModelV2,\n LanguageModelV2,\n ProviderV2,\n ImageModelV2,\n TranscriptionModelV2,\n SpeechModelV2,\n TranscriptionModelV2CallOptions,\n} from '@ai-sdk/provider';\nimport { FetchFunction, loadApiKey } from '@ai-sdk/provider-utils';\nimport { aihubmixTools } from './aihubmix-tools';\n\n// 导入设置类型\nimport type { OpenAIProviderSettings } from '@ai-sdk/openai';\n\n\nexport interface AihubmixProvider extends ProviderV2 {\n (deploymentId: string, settings?: OpenAIProviderSettings): LanguageModelV2;\n\n languageModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV2;\n\n chat(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV2;\n\n responses(deploymentId: string): LanguageModelV2;\n\n completion(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV2;\n\n embedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV2<string>;\n\n image(deploymentId: string, settings?: OpenAIProviderSettings): ImageModelV2;\n\n imageModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): ImageModelV2;\n\n textEmbedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV2<string>;\n\n textEmbeddingModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV2<string>;\n\n transcription(deploymentId: string): TranscriptionModelV2;\n\n speech(deploymentId: string): SpeechModelV2;\n\n speechModel(deploymentId: string): SpeechModelV2;\n\n tools: typeof aihubmixTools;\n}\n\nexport interface AihubmixProviderSettings {\n apiKey?: string;\n fetch?: FetchFunction;\n compatibility?: 'strict' | 'compatible';\n}\n\nclass AihubmixTranscriptionModel extends OpenAITranscriptionModel {\n async doGenerate(options: TranscriptionModelV2CallOptions) {\n // 根据MIME类型设置正确的文件扩展名\n if (options.mediaType) {\n const mimeTypeMap: Record<string, string> = {\n 'audio/mpeg': 'mp3',\n 'audio/mp3': 'mp3',\n 'audio/wav': 'wav',\n 'audio/flac': 'flac',\n 'audio/m4a': 'm4a',\n 'audio/mp4': 'mp4',\n 'audio/ogg': 'ogg',\n 'audio/webm': 'webm',\n 'audio/oga': 'oga',\n 'audio/mpga': 'mpga',\n };\n \n const extension = mimeTypeMap[options.mediaType];\n if (extension) {\n // 重写getArgs方法来设置正确的文件名\n const originalGetArgs = (this as any).getArgs;\n (this as any).getArgs = async function(args: any) {\n const result = await originalGetArgs.call(this, args);\n if (result.formData) {\n // 找到file字段并修改文件名\n const fileEntry = result.formData.get('file');\n if (fileEntry && typeof fileEntry === 'object' && 'name' in fileEntry) {\n // 创建新的 File 对象,设置正确的文件名\n try {\n const newFile = new File([fileEntry], `audio.${extension}`, { \n type: options.mediaType \n });\n result.formData.set('file', newFile);\n } catch (error) {\n console.log('Failed to create new File object:', error);\n // 如果创建新 File 对象失败,尝试其他方法\n // 在 Node.js 环境中,可能需要使用 Buffer 或其他方式\n if (fileEntry && typeof fileEntry === 'object' && 'arrayBuffer' in fileEntry) {\n try {\n const arrayBuffer = await (fileEntry as any).arrayBuffer();\n const newFile = new File([arrayBuffer], `audio.${extension}`, { \n type: options.mediaType \n });\n result.formData.set('file', newFile);\n console.log('Created new file from arrayBuffer with name:', `audio.${extension}`);\n } catch (bufferError) {\n console.log('Failed to create file from arrayBuffer:', bufferError);\n }\n }\n }\n }\n }\n return result;\n };\n }\n }\n \n return super.doGenerate(options);\n }\n}\n\nexport function createAihubmix(\n options: AihubmixProviderSettings = {},\n): AihubmixProvider {\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': 'WHVL9885',\n 'Content-Type': 'application/json',\n });\n\n const getTranscriptionHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': 'WHVL9885',\n });\n\n const url = ({ path, modelId }: { path: string; modelId: string }) => {\n const baseURL = 'https://aihubmix.com/v1';\n return `${baseURL}${path}`;\n };\n\n const createChatModel = (\n deploymentName: string,\n settings: OpenAIProviderSettings = {},\n ) => {\n const headers = getHeaders();\n if (deploymentName.startsWith('claude-')) {\n return new AnthropicMessagesLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n baseURL: url({ path: '', modelId: deploymentName }),\n headers: {\n ...headers,\n 'x-api-key': headers['Authorization'].split(' ')[1],\n },\n supportedUrls: () => ({\n 'image/*': [/^https?:\\/\\/.*$/],\n }),\n });\n }\n if (\n (deploymentName.startsWith('gemini') ||\n deploymentName.startsWith('imagen')) &&\n !deploymentName.endsWith('-nothink') &&\n !deploymentName.endsWith('-search')\n ) {\n return new GoogleGenerativeAILanguageModel(\n deploymentName,\n {\n provider: 'aihubmix.chat',\n baseURL: 'https://aihubmix.com/gemini/v1beta',\n headers: {\n ...headers,\n 'x-goog-api-key': headers['Authorization'].split(' ')[1],\n },\n generateId: () => `aihubmix-${Date.now()}`,\n supportedUrls: () => ({}),\n },\n );\n }\n\n return new OpenAIChatLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n };\n\n const createCompletionModel = (\n modelId: string,\n settings: any = {},\n ) =>\n new OpenAICompletionLanguageModel(modelId, {\n provider: 'aihubmix.completion',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createEmbeddingModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAIEmbeddingModel(modelId, {\n provider: 'aihubmix.embeddings',\n headers: getHeaders,\n url,\n fetch: options.fetch,\n });\n };\n\n const createResponsesModel = (modelId: string) =>\n new OpenAIResponsesLanguageModel(modelId, {\n provider: 'aihubmix.responses',\n url,\n headers: getHeaders,\n });\n\n const createImageModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAIImageModel(modelId, {\n provider: 'aihubmix.image',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n };\n\n const createTranscriptionModel = (modelId: string) =>\n new AihubmixTranscriptionModel(modelId, {\n provider: 'aihubmix.transcription',\n url,\n headers: getTranscriptionHeaders,\n fetch: options.fetch,\n });\n const createSpeechModel = (modelId: string) =>\n new OpenAISpeechModel(modelId, {\n provider: 'aihubmix.speech',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n const provider = function (\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ) {\n if (new.target) {\n throw new Error(\n 'The Aihubmix model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(deploymentId, settings);\n };\n\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.completion = createCompletionModel;\n provider.responses = createResponsesModel;\n provider.embedding = createEmbeddingModel;\n provider.textEmbedding = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n\n provider.tools = aihubmixTools;\n\n return provider as AihubmixProvider;\n}\n\nexport const aihubmix = createAihubmix();\n","import { z } from 'zod';\n\nconst WebSearchPreviewParameters = z.object({});\n\nfunction webSearchPreviewTool({\n searchContextSize,\n userLocation,\n}: {\n searchContextSize?: 'low' | 'medium' | 'high';\n userLocation?: {\n type?: 'approximate';\n city?: string;\n region?: string;\n country?: string;\n timezone?: string;\n };\n} = {}): {\n type: 'function';\n function: {\n name: string;\n description: string;\n parameters: typeof WebSearchPreviewParameters;\n };\n} {\n return {\n type: 'function',\n function: {\n name: 'aihubmix.web_search_preview',\n description: 'Search the web for current information and preview results',\n parameters: WebSearchPreviewParameters,\n },\n };\n}\n\nexport const aihubmixTools = {\n webSearchPreview: webSearchPreviewTool,\n};\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sCAAsC;AAC/C,SAAS,uCAAuC;AAUhD,SAAwB,kBAAkB;;;ACpB1C,SAAS,SAAS;AAElB,IAAM,6BAA6B,EAAE,OAAO,CAAC,CAAC;AAE9C,SAAS,qBAAqB;AAAA,EAC5B;AAAA,EACA;AACF,IASI,CAAC,GAOH;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,IACd;AAAA,EACF;AACF;AAEO,IAAM,gBAAgB;AAAA,EAC3B,kBAAkB;AACpB;;;ADgDA,IAAM,6BAAN,cAAyC,yBAAyB;AAAA,EAChE,MAAM,WAAW,SAA0C;AAEzD,QAAI,QAAQ,WAAW;AACrB,YAAM,cAAsC;AAAA,QAC1C,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QACb,cAAc;AAAA,QACd,a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B;AACzB,WAAS,OAAO;AAChB,WAAS,aAAa;AACtB,WAAS,YAAY;AACrB,WAAS,YAAY;AACrB,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAE9B,WAAS,QAAQ;AACjB,WAAS,aAAa;AAEtB,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAE9B,WAAS,SAAS;AAClB,WAAS,cAAc;AAEvB,WAAS,QAAQ;AAEjB,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aihubmix/ai-sdk-provider",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -10,6 +10,18 @@
10
10
  "dist/**/*",
11
11
  "CHANGELOG.md"
12
12
  ],
13
+ "scripts": {
14
+ "build": "tsup",
15
+ "build:watch": "tsup --watch",
16
+ "clean": "rm -rf dist",
17
+ "lint": "eslint \"./**/*.ts*\"",
18
+ "type-check": "tsc --noEmit",
19
+ "prettier-check": "prettier --check \"./**/*.ts*\" --write",
20
+ "test": "pnpm test:node && pnpm test:edge",
21
+ "test:edge": "vitest --config vitest.edge.config.js --run",
22
+ "test:node": "vitest --config vitest.node.config.js --run",
23
+ "test:node:watch": "vitest --config vitest.node.config.js"
24
+ },
13
25
  "exports": {
14
26
  "./package.json": "./package.json",
15
27
  ".": {
@@ -19,23 +31,23 @@
19
31
  }
20
32
  },
21
33
  "dependencies": {
22
- "@ai-sdk/anthropic": "2.0.0-beta.3",
23
- "@ai-sdk/google": "2.0.0-beta.6",
24
- "@ai-sdk/openai": "2.0.0-beta.3",
25
- "@ai-sdk/provider": "2.0.0-beta.1",
26
- "@ai-sdk/provider-utils": "3.0.0-beta.5"
34
+ "@ai-sdk/anthropic": "2.0.17",
35
+ "@ai-sdk/google": "2.0.15",
36
+ "@ai-sdk/openai": "2.0.32",
37
+ "@ai-sdk/provider": "2.0.0",
38
+ "@ai-sdk/provider-utils": "3.0.9"
27
39
  },
28
40
  "devDependencies": {
29
41
  "@types/node": "20.17.24",
30
42
  "tsup": "^8",
31
43
  "typescript": "5.6.3",
32
- "zod": "^3.25.0",
44
+ "zod": "3.23.8",
33
45
  "vitest": "^2.0.0",
34
46
  "jsdom": "^24.0.0",
35
47
  "@edge-runtime/vm": "^2.0.0"
36
48
  },
37
49
  "peerDependencies": {
38
- "zod": "^3.25.0"
50
+ "zod": "^3.0.0"
39
51
  },
40
52
  "engines": {
41
53
  "node": ">=18"
@@ -56,17 +68,5 @@
56
68
  "aihubmix",
57
69
  "ai-sdk-provider",
58
70
  "ai-sdk"
59
- ],
60
- "scripts": {
61
- "build": "tsup",
62
- "build:watch": "tsup --watch",
63
- "clean": "rm -rf dist",
64
- "lint": "eslint \"./**/*.ts*\"",
65
- "type-check": "tsc --noEmit",
66
- "prettier-check": "prettier --check \"./**/*.ts*\" --write",
67
- "test": "pnpm test:node && pnpm test:edge",
68
- "test:edge": "vitest --config vitest.edge.config.js --run",
69
- "test:node": "vitest --config vitest.node.config.js --run",
70
- "test:node:watch": "vitest --config vitest.node.config.js"
71
- }
72
- }
71
+ ]
72
+ }
package/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.