@aihubmix/ai-sdk-provider 2.0.6 → 2.2.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @aihubmix/ai-sdk-provider
2
2
 
3
+ ## 2.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 新增 `baseURL` 配置项:`createAihubmix({ baseURL })` 可覆盖请求 host(默认 `https://aihubmix.com`,末尾斜杠会自动去除)。`/v1`、`/gemini/v1beta` 等路径自动拼接,适用于自建网关 / 代理场景。
8
+ - 修复 `fetch` 透传:为 Claude、Gemini、Responses 三类模型补上 `fetch` 选项,使自定义 `fetch` 对所有 sub-model 生效(此前仅 OpenAI-compatible / completion / transcription / speech 生效)。
9
+
10
+ ## 2.1.0
11
+
12
+ ### Minor Changes
13
+
14
+ - 新增 `appCode` 配置项:`createAihubmix({ appCode })` 可覆盖请求头 `APP-Code`。不传时仍使用项目内置默认值 `WHVL9885`,行为向后兼容。
15
+
3
16
  ## 2.0.6
4
17
 
5
18
  ### Patch Changes
package/README.ja.md CHANGED
@@ -66,6 +66,43 @@ const aihubmix = createAihubmix({
66
66
  });
67
67
  ```
68
68
 
69
+ ### `appCode`(任意)
70
+
71
+ すべてのリクエストには `APP-Code` ヘッダーが付与されます。デフォルトでは本パッケージに組み込まれた値が使われるため、**通常は設定不要です**。独自の app code がある場合は、`appCode` を渡してデフォルト値を上書きできます:
72
+
73
+ ```ts
74
+ import { createAihubmix } from '@aihubmix/ai-sdk-provider';
75
+
76
+ const aihubmix = createAihubmix({
77
+ apiKey: 'your-api-key-here',
78
+ appCode: 'YOUR-APP-CODE', // 任意;省略時は組み込みのデフォルト値にフォールバック
79
+ });
80
+ ```
81
+
82
+ ### `baseURL`(任意)
83
+
84
+ デフォルトではすべてのリクエストは `https://aihubmix.com` に送信されます。独自のゲートウェイやプロキシ経由にする場合は `baseURL` を渡します(末尾のスラッシュは自動的に除去されます)。`/v1` や `/gemini/v1beta` などのパスは自動的に付与されます:
85
+
86
+ ```ts
87
+ import { createAihubmix } from '@aihubmix/ai-sdk-provider';
88
+
89
+ const aihubmix = createAihubmix({
90
+ apiKey: 'your-api-key-here',
91
+ baseURL: 'https://your-gateway.example.com', // 任意;デフォルトは https://aihubmix.com
92
+ });
93
+ ```
94
+
95
+ ### カスタム `fetch`
96
+
97
+ カスタム `fetch` 実装(プロキシ、ロギング、テスト用)を渡せます。OpenAI互換、Claude、Gemini、Responses、文字起こし、音声のすべてのモデルに転送されます:
98
+
99
+ ```ts
100
+ const aihubmix = createAihubmix({
101
+ apiKey: 'your-api-key-here',
102
+ fetch: myCustomFetch,
103
+ });
104
+ ```
105
+
69
106
  ## 使用
70
107
 
71
108
  まず、必要な関数をインポートします:
package/README.md CHANGED
@@ -67,6 +67,50 @@ const aihubmix = createAihubmix({
67
67
  });
68
68
  ```
69
69
 
70
+ ### `appCode` (optional)
71
+
72
+ Every request carries an `APP-Code` header. By default it uses the value
73
+ built into this package, so **you do not need to set it**. If you have your
74
+ own app code, pass `appCode` to override the default:
75
+
76
+ ```ts
77
+ import { createAihubmix } from '@aihubmix/ai-sdk-provider';
78
+
79
+ const aihubmix = createAihubmix({
80
+ apiKey: 'your-api-key-here',
81
+ appCode: 'YOUR-APP-CODE', // optional; falls back to the built-in default when omitted
82
+ });
83
+ ```
84
+
85
+ ### `baseURL` (optional)
86
+
87
+ By default all requests go to `https://aihubmix.com`. To route through your
88
+ own gateway or proxy, pass `baseURL` (a trailing slash is allowed and
89
+ stripped). Paths such as `/v1` and `/gemini/v1beta` are appended
90
+ automatically:
91
+
92
+ ```ts
93
+ import { createAihubmix } from '@aihubmix/ai-sdk-provider';
94
+
95
+ const aihubmix = createAihubmix({
96
+ apiKey: 'your-api-key-here',
97
+ baseURL: 'https://your-gateway.example.com', // optional; defaults to https://aihubmix.com
98
+ });
99
+ ```
100
+
101
+ ### Custom `fetch`
102
+
103
+ You may pass a custom `fetch` implementation (for proxies, logging, or
104
+ testing). It is forwarded to every model — OpenAI-compatible, Claude,
105
+ Gemini, Responses, transcription, and speech:
106
+
107
+ ```ts
108
+ const aihubmix = createAihubmix({
109
+ apiKey: 'your-api-key-here',
110
+ fetch: myCustomFetch,
111
+ });
112
+ ```
113
+
70
114
  ## Usage
71
115
 
72
116
  First, import the necessary functions:
package/README.zh.md CHANGED
@@ -66,6 +66,43 @@ const aihubmix = createAihubmix({
66
66
  });
67
67
  ```
68
68
 
69
+ ### `appCode`(可选)
70
+
71
+ 每个请求都会携带 `APP-Code` 请求头。默认使用本包内置的值,因此**通常无需设置**。如果你有自己的 app code,可传入 `appCode` 覆盖默认值:
72
+
73
+ ```ts
74
+ import { createAihubmix } from '@aihubmix/ai-sdk-provider';
75
+
76
+ const aihubmix = createAihubmix({
77
+ apiKey: 'your-api-key-here',
78
+ appCode: 'YOUR-APP-CODE', // 可选;不传时回退到内置默认值
79
+ });
80
+ ```
81
+
82
+ ### `baseURL`(可选)
83
+
84
+ 默认所有请求发往 `https://aihubmix.com`。若要走自建网关或代理,可传入 `baseURL`(末尾斜杠会自动去除)。`/v1`、`/gemini/v1beta` 等路径会自动拼接:
85
+
86
+ ```ts
87
+ import { createAihubmix } from '@aihubmix/ai-sdk-provider';
88
+
89
+ const aihubmix = createAihubmix({
90
+ apiKey: 'your-api-key-here',
91
+ baseURL: 'https://your-gateway.example.com', // 可选;默认 https://aihubmix.com
92
+ });
93
+ ```
94
+
95
+ ### 自定义 `fetch`
96
+
97
+ 可传入自定义 `fetch` 实现(用于代理、日志或测试)。它会透传给所有模型 —— OpenAI 兼容、Claude、Gemini、Responses、转录与语音:
98
+
99
+ ```ts
100
+ const aihubmix = createAihubmix({
101
+ apiKey: 'your-api-key-here',
102
+ fetch: myCustomFetch,
103
+ });
104
+ ```
105
+
69
106
  ## 使用
70
107
 
71
108
  首先,导入必要的函数:
package/dist/index.d.mts CHANGED
@@ -223,6 +223,11 @@ interface AihubmixProviderSettings {
223
223
  apiKey?: string;
224
224
  fetch?: FetchFunction;
225
225
  compatibility?: 'strict' | 'compatible';
226
+ /**
227
+ * APP-Code header sent with every request. Defaults to the project's
228
+ * built-in app code; pass a value here to override it.
229
+ */
230
+ appCode?: string;
226
231
  }
227
232
  declare function createAihubmix(options?: AihubmixProviderSettings): AihubmixProvider;
228
233
  declare const aihubmix: AihubmixProvider;
package/dist/index.d.ts CHANGED
@@ -223,6 +223,11 @@ interface AihubmixProviderSettings {
223
223
  apiKey?: string;
224
224
  fetch?: FetchFunction;
225
225
  compatibility?: 'strict' | 'compatible';
226
+ /**
227
+ * APP-Code header sent with every request. Defaults to the project's
228
+ * built-in app code; pass a value here to override it.
229
+ */
230
+ appCode?: string;
226
231
  }
227
232
  declare function createAihubmix(options?: AihubmixProviderSettings): AihubmixProvider;
228
233
  declare const aihubmix: AihubmixProvider;
package/dist/index.js CHANGED
@@ -297,6 +297,7 @@ var aihubmixTools = {
297
297
  };
298
298
 
299
299
  // src/aihubmix-provider.ts
300
+ var DEFAULT_APP_CODE = "WHVL9885";
300
301
  var AihubmixTranscriptionModel = class extends import_internal.OpenAITranscriptionModel {
301
302
  async doGenerate(options) {
302
303
  if (options.mediaType) {
@@ -357,13 +358,14 @@ function transformRequestBody(body) {
357
358
  return body;
358
359
  }
359
360
  function createAihubmix(options = {}) {
361
+ const appCode = options.appCode ?? DEFAULT_APP_CODE;
360
362
  const getHeaders = () => ({
361
363
  Authorization: `Bearer ${(0, import_provider_utils6.loadApiKey)({
362
364
  apiKey: options.apiKey,
363
365
  environmentVariableName: "AIHUBMIX_API_KEY",
364
366
  description: "Aihubmix"
365
367
  })}`,
366
- "APP-Code": "WHVL9885",
368
+ "APP-Code": appCode,
367
369
  "Content-Type": "application/json"
368
370
  });
369
371
  const getTranscriptionHeaders = () => ({
@@ -372,7 +374,7 @@ function createAihubmix(options = {}) {
372
374
  environmentVariableName: "AIHUBMIX_API_KEY",
373
375
  description: "Aihubmix"
374
376
  })}`,
375
- "APP-Code": "WHVL9885"
377
+ "APP-Code": appCode
376
378
  });
377
379
  const url = ({ path, modelId }) => {
378
380
  const baseURL = "https://aihubmix.com/v1";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/aihubmix-provider.ts","../src/tool/code-interpreter.ts","../src/tool/file-search.ts","../src/tool/image-generation.ts","../src/tool/web-search.ts","../src/tool/web-search-preview.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 OpenAICompatibleChatLanguageModel,\n OpenAICompatibleCompletionLanguageModel,\n OpenAICompatibleEmbeddingModel,\n OpenAICompatibleImageModel,\n} from '@ai-sdk/openai-compatible';\nimport {\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 EmbeddingModelV3,\n LanguageModelV3,\n ProviderV3,\n ImageModelV3,\n TranscriptionModelV3,\n SpeechModelV3,\n TranscriptionModelV3CallOptions,\n} from '@ai-sdk/provider';\nimport { FetchFunction, loadApiKey } from '@ai-sdk/provider-utils';\nimport { aihubmixTools } from './aihubmix-tools';\n\n// OpenAI Provider 设置类型\ninterface OpenAIProviderSettings {\n [key: string]: unknown;\n}\n\n\nexport interface AihubmixProvider extends ProviderV3 {\n (deploymentId: string, settings?: OpenAIProviderSettings): LanguageModelV3;\n\n readonly specificationVersion: 'v3';\n\n languageModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV3;\n\n chat(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV3;\n\n responses(deploymentId: string): LanguageModelV3;\n\n completion(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV3;\n\n embedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV3;\n\n embeddingModel(modelId: string): EmbeddingModelV3;\n\n image(deploymentId: string, settings?: OpenAIProviderSettings): ImageModelV3;\n\n imageModel(modelId: string): ImageModelV3;\n\n textEmbedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV3;\n\n textEmbeddingModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV3;\n\n transcription(deploymentId: string): TranscriptionModelV3;\n\n speech(deploymentId: string): SpeechModelV3;\n\n speechModel(deploymentId: string): SpeechModelV3;\n\n tools: typeof aihubmixTools;\n}\nexport interface AihubmixProviderSettings {\n apiKey?: string;\n fetch?: FetchFunction;\n compatibility?: 'strict' | 'compatible';\n}\n\nclass AihubmixTranscriptionModel extends OpenAITranscriptionModel {\n async doGenerate(options: TranscriptionModelV3CallOptions) {\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\n// 修复空工具时的 tool_choice 问题\nfunction transformRequestBody(body: Record<string, any>): Record<string, any> {\n if (body.tools && Array.isArray(body.tools) && body.tools.length === 0 && body.tool_choice) {\n const { tool_choice, ...rest } = body;\n return rest;\n }\n return body;\n}export 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 const { Authorization, ...restHeaders } = headers;\n return new AnthropicMessagesLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n baseURL: url({ path: '', modelId: deploymentName }),\n headers: {\n ...restHeaders,\n 'x-api-key': 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 const { Authorization, ...restHeaders } = headers;\n return new GoogleGenerativeAILanguageModel(\n deploymentName,\n {\n provider: 'aihubmix.chat',\n baseURL: 'https://aihubmix.com/gemini/v1beta',\n headers: {\n ...restHeaders,\n 'x-goog-api-key': Authorization.split(' ')[1],\n },\n generateId: () => `aihubmix-${Date.now()}`,\n supportedUrls: () => ({}),\n },\n );\n }\n\n return new OpenAICompatibleChatLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n includeUsage: true,\n supportsStructuredOutputs: true,\n transformRequestBody,\n });\n };\n\n const createCompletionModel = (\n modelId: string,\n settings: any = {},\n ) =>\n new OpenAICompatibleCompletionLanguageModel(modelId, {\n provider: 'aihubmix.completion',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n includeUsage: true,\n });\n\n const createEmbeddingModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAICompatibleEmbeddingModel(modelId, {\n provider: 'aihubmix.embeddings',\n url,\n headers: getHeaders,\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 OpenAICompatibleImageModel(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\n const providerFn = 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 对象\n const provider = Object.assign(providerFn, {\n specificationVersion: 'v3' as const,\n languageModel: createChatModel,\n chat: createChatModel,\n completion: createCompletionModel,\n responses: createResponsesModel,\n embedding: createEmbeddingModel,\n embeddingModel: createEmbeddingModel,\n textEmbedding: createEmbeddingModel,\n textEmbeddingModel: createEmbeddingModel,\n image: createImageModel,\n imageModel: createImageModel,\n transcription: createTranscriptionModel,\n transcriptionModel: createTranscriptionModel,\n speech: createSpeechModel,\n speechModel: createSpeechModel,\n tools: aihubmixTools,\n });\n\n return provider as AihubmixProvider;\n}\n\nexport const aihubmix = createAihubmix();\n","import { createProviderToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\nexport const codeInterpreterInputSchema = z.object({\n code: z.string().nullish(),\n containerId: z.string(),\n});\n\nexport const codeInterpreterOutputSchema = z.object({\n outputs: z\n .array(\n z.discriminatedUnion('type', [\n z.object({ type: z.literal('logs'), logs: z.string() }),\n z.object({ type: z.literal('image'), url: z.string() }),\n ]),\n )\n .nullish(),\n});\n\nexport const codeInterpreterArgsSchema = z.object({\n container: z\n .union([\n z.string(),\n z.object({\n fileIds: z.array(z.string()).optional(),\n }),\n ])\n .optional(),\n});\n\ntype CodeInterpreterArgs = {\n /**\n * The code interpreter container.\n * Can be a container ID\n * or an object that specifies uploaded file IDs to make available to your code.\n */\n container?: string | { fileIds?: string[] };\n};\n\nexport const codeInterpreterToolFactory =\n createProviderToolFactoryWithOutputSchema<\n {\n /**\n * The code to run, or null if not available.\n */\n code?: string | null;\n\n /**\n * The ID of the container used to run the code.\n */\n containerId: string;\n },\n {\n /**\n * The outputs generated by the code interpreter, such as logs or images.\n * Can be null if no outputs are available.\n */\n outputs?: Array<\n | {\n type: 'logs';\n\n /**\n * The logs output from the code interpreter.\n */\n logs: string;\n }\n | {\n type: 'image';\n\n /**\n * The URL of the image output from the code interpreter.\n */\n url: string;\n }\n > | null;\n },\n CodeInterpreterArgs\n >({\n id: 'aihubmix.code_interpreter',\n inputSchema: codeInterpreterInputSchema,\n outputSchema: codeInterpreterOutputSchema,\n });\n\nexport const codeInterpreter = (\n args: CodeInterpreterArgs = {}, // default\n) => {\n return codeInterpreterToolFactory(args);\n};\n","import { createProviderToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\n/**\n * A filter used to compare a specified attribute key to a given value using a defined comparison operation.\n */\nexport type OpenAIResponsesFileSearchToolComparisonFilter = {\n /**\n * The key to compare against the value.\n */\n key: string;\n\n /**\n * Specifies the comparison operator: eq, ne, gt, gte, lt, lte.\n */\n type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';\n\n /**\n * The value to compare against the attribute key; supports string, number, or boolean types.\n */\n value: string | number | boolean;\n};\n\n/**\n * Combine multiple filters using and or or.\n */\nexport type OpenAIResponsesFileSearchToolCompoundFilter = {\n /**\n * Type of operation: and or or.\n */\n type: 'and' | 'or';\n\n /**\n * Array of filters to combine. Items can be ComparisonFilter or CompoundFilter.\n */\n filters: Array<\n | OpenAIResponsesFileSearchToolComparisonFilter\n | OpenAIResponsesFileSearchToolCompoundFilter\n >;\n};\n\nconst comparisonFilterSchema = z.object({\n key: z.string(),\n type: z.enum(['eq', 'ne', 'gt', 'gte', 'lt', 'lte']),\n value: z.union([z.string(), z.number(), z.boolean()]),\n});\n\nconst compoundFilterSchema: z.ZodType<any> = z.object({\n type: z.enum(['and', 'or']),\n filters: z.array(\n z.union([comparisonFilterSchema, z.lazy(() => compoundFilterSchema)]),\n ),\n});\n\nexport const fileSearchArgsSchema = z.object({\n vectorStoreIds: z.array(z.string()),\n maxNumResults: z.number().optional(),\n ranking: z\n .object({\n ranker: z.string().optional(),\n scoreThreshold: z.number().optional(),\n })\n .optional(),\n filters: z.union([comparisonFilterSchema, compoundFilterSchema]).optional(),\n});\n\nexport const fileSearchOutputSchema = z.object({\n queries: z.array(z.string()),\n results: z\n .array(\n z.object({\n attributes: z.record(z.string(), z.unknown()),\n fileId: z.string(),\n filename: z.string(),\n score: z.number(),\n text: z.string(),\n }),\n )\n .nullable(),\n});\n\nexport const fileSearch = createProviderToolFactoryWithOutputSchema<\n {},\n {\n /**\n * The search query to execute.\n */\n queries: string[];\n\n /**\n * The results of the file search tool call.\n */\n results:\n | null\n | {\n /**\n * Set of 16 key-value pairs that can be attached to an object.\n * This can be useful for storing additional information about the object\n * in a structured format, and querying for objects via API or the dashboard.\n * Keys are strings with a maximum length of 64 characters.\n * Values are strings with a maximum length of 512 characters, booleans, or numbers.\n */\n attributes: Record<string, unknown>;\n\n /**\n * The unique ID of the file.\n */\n fileId: string;\n\n /**\n * The name of the file.\n */\n filename: string;\n\n /**\n * The relevance score of the file - a value between 0 and 1.\n */\n score: number;\n\n /**\n * The text that was retrieved from the file.\n */\n text: string;\n }[];\n },\n {\n /**\n * List of vector store IDs to search through.\n */\n vectorStoreIds: string[];\n\n /**\n * Maximum number of search results to return. Defaults to 10.\n */\n maxNumResults?: number;\n\n /**\n * Ranking options for the search.\n */\n ranking?: {\n /**\n * The ranker to use for the file search.\n */\n ranker?: string;\n\n /**\n * The score threshold for the file search, a number between 0 and 1.\n * Numbers closer to 1 will attempt to return only the most relevant results,\n * but may return fewer results.\n */\n scoreThreshold?: number;\n };\n\n /**\n * A filter to apply.\n */\n filters?:\n | OpenAIResponsesFileSearchToolComparisonFilter\n | OpenAIResponsesFileSearchToolCompoundFilter;\n }\n>({\n id: 'aihubmix.file_search',\n inputSchema: z.object({}),\n outputSchema: fileSearchOutputSchema,\n});\n","import { createProviderToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\nexport const imageGenerationArgsSchema = z\n .object({\n background: z.enum(['auto', 'opaque', 'transparent']).optional(),\n inputFidelity: z.enum(['low', 'high']).optional(),\n inputImageMask: z\n .object({\n fileId: z.string().optional(),\n imageUrl: z.string().optional(),\n })\n .optional(),\n model: z.string().optional(),\n moderation: z.enum(['auto']).optional(),\n outputCompression: z.number().int().min(0).max(100).optional(),\n outputFormat: z.enum(['png', 'jpeg', 'webp']).optional(),\n quality: z.enum(['auto', 'low', 'medium', 'high']).optional(),\n size: z.enum(['1024x1024', '1024x1536', '1536x1024', 'auto']).optional(),\n })\n .strict();\n\nexport const imageGenerationOutputSchema = z.object({\n result: z.string(),\n});\n\ntype ImageGenerationArgs = {\n /**\n * Background type for the generated image. Default is 'auto'.\n */\n background?: 'auto' | 'opaque' | 'transparent';\n\n /**\n * Input fidelity for the generated image. Default is 'low'.\n */\n inputFidelity?: 'low' | 'high';\n\n /**\n * Optional mask for inpainting.\n * Contains image_url (string, optional) and file_id (string, optional).\n */\n inputImageMask?: {\n /**\n * File ID for the mask image.\n */\n fileId?: string;\n\n /**\n * Base64-encoded mask image.\n */\n imageUrl?: string;\n };\n\n /**\n * The image generation model to use. Default: gpt-image-1.\n */\n model?: string;\n\n /**\n * Moderation level for the generated image. Default: auto.\n */\n moderation?: 'auto';\n\n /**\n * Compression level for the output image. Default: 100.\n */\n outputCompression?: number;\n\n /**\n * The output format of the generated image. One of png, webp, or jpeg.\n * Default: png\n */\n outputFormat?: 'png' | 'jpeg' | 'webp';\n\n /**\n * The quality of the generated image.\n * One of low, medium, high, or auto. Default: auto.\n */\n quality?: 'auto' | 'low' | 'medium' | 'high';\n\n /**\n * The size of the generated image.\n * One of 1024x1024, 1024x1536, 1536x1024, or auto.\n * Default: auto.\n */\n size?: 'auto' | '1024x1024' | '1024x1536' | '1536x1024';\n};\n\nconst imageGenerationToolFactory =\n createProviderToolFactoryWithOutputSchema<\n {},\n {\n /**\n * The generated image encoded in base64.\n */\n result: string;\n },\n ImageGenerationArgs\n >({\n id: 'aihubmix.image_generation',\n inputSchema: z.object({}),\n outputSchema: imageGenerationOutputSchema,\n });\n\nexport const imageGeneration = (\n args: ImageGenerationArgs = {}, // default\n) => {\n return imageGenerationToolFactory(args);\n};\n","import { createProviderToolFactory } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\nexport const webSearchArgsSchema = z.object({\n filters: z\n .object({\n allowedDomains: z.array(z.string()).optional(),\n })\n .optional(),\n\n searchContextSize: z.enum(['low', 'medium', 'high']).optional(),\n\n userLocation: z\n .object({\n type: z.literal('approximate'),\n country: z.string().optional(),\n city: z.string().optional(),\n region: z.string().optional(),\n timezone: z.string().optional(),\n })\n .optional(),\n});\n\nexport const webSearchToolFactory = createProviderToolFactory<\n {\n // Web search doesn't take input parameters - it's controlled by the prompt\n },\n {\n /**\n * Filters for the search.\n */\n filters?: {\n /**\n * Allowed domains for the search.\n * If not provided, all domains are allowed.\n * Subdomains of the provided domains are allowed as well.\n */\n allowedDomains?: string[];\n };\n\n /**\n * Search context size to use for the web search.\n * - high: Most comprehensive context, highest cost, slower response\n * - medium: Balanced context, cost, and latency (default)\n * - low: Least context, lowest cost, fastest response\n */\n searchContextSize?: 'low' | 'medium' | 'high';\n\n /**\n * User location information to provide geographically relevant search results.\n */\n userLocation?: {\n /**\n * Type of location (always 'approximate')\n */\n type: 'approximate';\n /**\n * Two-letter ISO country code (e.g., 'US', 'GB')\n */\n country?: string;\n /**\n * City name (free text, e.g., 'Minneapolis')\n */\n city?: string;\n /**\n * Region name (free text, e.g., 'Minnesota')\n */\n region?: string;\n /**\n * IANA timezone (e.g., 'America/Chicago')\n */\n timezone?: string;\n };\n }\n>({\n id: 'aihubmix.web_search',\n inputSchema: z.object({\n action: z\n .discriminatedUnion('type', [\n z.object({\n type: z.literal('search'),\n query: z.string().nullish(),\n }),\n z.object({\n type: z.literal('open_page'),\n url: z.string(),\n }),\n z.object({\n type: z.literal('find'),\n url: z.string(),\n pattern: z.string(),\n }),\n ])\n .nullish(),\n }),\n});\n\nexport const webSearch = (\n args: Parameters<typeof webSearchToolFactory>[0] = {}, // default\n) => {\n return webSearchToolFactory(args);\n};\n","import { createProviderToolFactory } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\n// Args validation schema\nexport const webSearchPreviewArgsSchema = z.object({\n /**\n * Search context size to use for the web search.\n * - high: Most comprehensive context, highest cost, slower response\n * - medium: Balanced context, cost, and latency (default)\n * - low: Least context, lowest cost, fastest response\n */\n searchContextSize: z.enum(['low', 'medium', 'high']).optional(),\n\n /**\n * User location information to provide geographically relevant search results.\n */\n userLocation: z\n .object({\n /**\n * Type of location (always 'approximate')\n */\n type: z.literal('approximate'),\n /**\n * Two-letter ISO country code (e.g., 'US', 'GB')\n */\n country: z.string().optional(),\n /**\n * City name (free text, e.g., 'Minneapolis')\n */\n city: z.string().optional(),\n /**\n * Region name (free text, e.g., 'Minnesota')\n */\n region: z.string().optional(),\n /**\n * IANA timezone (e.g., 'America/Chicago')\n */\n timezone: z.string().optional(),\n })\n .optional(),\n});\n\nexport const webSearchPreview = createProviderToolFactory<\n {\n // Web search doesn't take input parameters - it's controlled by the prompt\n },\n {\n /**\n * Search context size to use for the web search.\n * - high: Most comprehensive context, highest cost, slower response\n * - medium: Balanced context, cost, and latency (default)\n * - low: Least context, lowest cost, fastest response\n */\n searchContextSize?: 'low' | 'medium' | 'high';\n\n /**\n * User location information to provide geographically relevant search results.\n */\n userLocation?: {\n /**\n * Type of location (always 'approximate')\n */\n type: 'approximate';\n /**\n * Two-letter ISO country code (e.g., 'US', 'GB')\n */\n country?: string;\n /**\n * City name (free text, e.g., 'Minneapolis')\n */\n city?: string;\n /**\n * Region name (free text, e.g., 'Minnesota')\n */\n region?: string;\n /**\n * IANA timezone (e.g., 'America/Chicago')\n */\n timezone?: string;\n };\n }\n>({\n id: 'aihubmix.web_search_preview',\n inputSchema: z.object({\n action: z\n .discriminatedUnion('type', [\n z.object({\n type: z.literal('search'),\n query: z.string().nullish(),\n }),\n z.object({\n type: z.literal('open_page'),\n url: z.string(),\n }),\n z.object({\n type: z.literal('find'),\n url: z.string(),\n pattern: z.string(),\n }),\n ])\n .nullish(),\n }),\n});\n","import { codeInterpreter } from './tool/code-interpreter';\nimport { fileSearch } from './tool/file-search';\nimport { imageGeneration } from './tool/image-generation';\nimport { webSearch } from './tool/web-search';\nimport { webSearchPreview } from './tool/web-search-preview';\n\nexport const aihubmixTools = {\n /**\n * The Code Interpreter tool allows models to write and run Python code in a\n * sandboxed environment to solve complex problems in domains like data analysis,\n * coding, and math.\n *\n * @param container - The container to use for the code interpreter.\n *\n * Must have name `code_interpreter`.\n */\n codeInterpreter,\n\n /**\n * File search is a tool available in the Responses API. It enables models to\n * retrieve information in a knowledge base of previously uploaded files through\n * semantic and keyword search.\n *\n * Must have name `file_search`.\n *\n * @param vectorStoreIds - The vector store IDs to use for the file search.\n * @param maxNumResults - The maximum number of results to return.\n * @param ranking - The ranking options to use for the file search.\n * @param filters - The filters to use for the file search.\n */\n fileSearch,\n\n /**\n * The image generation tool allows you to generate images using a text prompt,\n * and optionally image inputs. It leverages the GPT Image model,\n * and automatically optimizes text inputs for improved performance.\n *\n * Must have name `image_generation`.\n *\n * @param size - Image dimensions (e.g., 1024x1024, 1024x1536)\n * @param quality - Rendering quality (e.g. low, medium, high)\n * @param format - File output format\n * @param compression - Compression level (0-100%) for JPEG and WebP formats\n * @param background - Transparent or opaque\n */\n imageGeneration,\n\n /**\n * Web search allows models to access up-to-date information from the internet\n * and provide answers with sourced citations.\n *\n * Must have name `web_search_preview`.\n *\n * @param searchContextSize - The search context size to use for the web search.\n * @param userLocation - The user location to use for the web search.\n *\n * @deprecated Use `webSearch` instead.\n */\n webSearchPreview,\n\n /**\n * Web search allows models to access up-to-date information from the internet\n * and provide answers with sourced citations.\n *\n * Must have name `web_search`.\n *\n * @param filters - The filters to use for the web search.\n * @param searchContextSize - The search context size to use for the web search.\n * @param userLocation - The user location to use for the web search.\n */\n webSearch,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,+BAKO;A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AA,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;AAEH,QAAM,aAAa,SACjB,cACA,UACA;AACA,QAAI,YAAY;AACd,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,gBAAgB,cAAc,QAAQ;AAAA,EAC/C;AAGA,QAAM,WAAW,OAAO,OAAO,YAAY;AAAA,IACzC,sBAAsB;AAAA,IACtB,eAAe;AAAA,IACf,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,oBAAoB;AAAA,IACpB,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,oBAAoB;AAAA,IACpB,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,OAAO;AAAA,EACT,CAAC;AAED,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":["import_internal","import_provider_utils","import_provider_utils","import_zod","import_provider_utils","import_zod","import_provider_utils","import_zod","import_provider_utils","import_zod"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/aihubmix-provider.ts","../src/tool/code-interpreter.ts","../src/tool/file-search.ts","../src/tool/image-generation.ts","../src/tool/web-search.ts","../src/tool/web-search-preview.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 OpenAICompatibleChatLanguageModel,\n OpenAICompatibleCompletionLanguageModel,\n OpenAICompatibleEmbeddingModel,\n OpenAICompatibleImageModel,\n} from '@ai-sdk/openai-compatible';\nimport {\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 EmbeddingModelV3,\n LanguageModelV3,\n ProviderV3,\n ImageModelV3,\n TranscriptionModelV3,\n SpeechModelV3,\n TranscriptionModelV3CallOptions,\n} from '@ai-sdk/provider';\nimport { FetchFunction, loadApiKey } from '@ai-sdk/provider-utils';\nimport { aihubmixTools } from './aihubmix-tools';\n\n// OpenAI Provider 设置类型\ninterface OpenAIProviderSettings {\n [key: string]: unknown;\n}\n\n\nexport interface AihubmixProvider extends ProviderV3 {\n (deploymentId: string, settings?: OpenAIProviderSettings): LanguageModelV3;\n\n readonly specificationVersion: 'v3';\n\n languageModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV3;\n\n chat(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV3;\n\n responses(deploymentId: string): LanguageModelV3;\n\n completion(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV3;\n\n embedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV3;\n\n embeddingModel(modelId: string): EmbeddingModelV3;\n\n image(deploymentId: string, settings?: OpenAIProviderSettings): ImageModelV3;\n\n imageModel(modelId: string): ImageModelV3;\n\n textEmbedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV3;\n\n textEmbeddingModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV3;\n\n transcription(deploymentId: string): TranscriptionModelV3;\n\n speech(deploymentId: string): SpeechModelV3;\n\n speechModel(deploymentId: string): SpeechModelV3;\n\n tools: typeof aihubmixTools;\n}\nexport interface AihubmixProviderSettings {\n apiKey?: string;\n fetch?: FetchFunction;\n compatibility?: 'strict' | 'compatible';\n /**\n * APP-Code header sent with every request. Defaults to the project's\n * built-in app code; pass a value here to override it.\n */\n appCode?: string;\n}\n\n// 默认 APP-Code(项目内置),可通过 AihubmixProviderSettings.appCode 覆盖\nconst DEFAULT_APP_CODE = 'WHVL9885';\n\nclass AihubmixTranscriptionModel extends OpenAITranscriptionModel {\n async doGenerate(options: TranscriptionModelV3CallOptions) {\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\n// 修复空工具时的 tool_choice 问题\nfunction transformRequestBody(body: Record<string, any>): Record<string, any> {\n if (body.tools && Array.isArray(body.tools) && body.tools.length === 0 && body.tool_choice) {\n const { tool_choice, ...rest } = body;\n return rest;\n }\n return body;\n}export function createAihubmix(\n options: AihubmixProviderSettings = {},\n): AihubmixProvider {\n const appCode = options.appCode ?? DEFAULT_APP_CODE;\n\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': appCode,\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': appCode,\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 const { Authorization, ...restHeaders } = headers;\n return new AnthropicMessagesLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n baseURL: url({ path: '', modelId: deploymentName }),\n headers: {\n ...restHeaders,\n 'x-api-key': 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 const { Authorization, ...restHeaders } = headers;\n return new GoogleGenerativeAILanguageModel(\n deploymentName,\n {\n provider: 'aihubmix.chat',\n baseURL: 'https://aihubmix.com/gemini/v1beta',\n headers: {\n ...restHeaders,\n 'x-goog-api-key': Authorization.split(' ')[1],\n },\n generateId: () => `aihubmix-${Date.now()}`,\n supportedUrls: () => ({}),\n },\n );\n }\n\n return new OpenAICompatibleChatLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n includeUsage: true,\n supportsStructuredOutputs: true,\n transformRequestBody,\n });\n };\n\n const createCompletionModel = (\n modelId: string,\n settings: any = {},\n ) =>\n new OpenAICompatibleCompletionLanguageModel(modelId, {\n provider: 'aihubmix.completion',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n includeUsage: true,\n });\n\n const createEmbeddingModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAICompatibleEmbeddingModel(modelId, {\n provider: 'aihubmix.embeddings',\n url,\n headers: getHeaders,\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 OpenAICompatibleImageModel(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\n const providerFn = 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 对象\n const provider = Object.assign(providerFn, {\n specificationVersion: 'v3' as const,\n languageModel: createChatModel,\n chat: createChatModel,\n completion: createCompletionModel,\n responses: createResponsesModel,\n embedding: createEmbeddingModel,\n embeddingModel: createEmbeddingModel,\n textEmbedding: createEmbeddingModel,\n textEmbeddingModel: createEmbeddingModel,\n image: createImageModel,\n imageModel: createImageModel,\n transcription: createTranscriptionModel,\n transcriptionModel: createTranscriptionModel,\n speech: createSpeechModel,\n speechModel: createSpeechModel,\n tools: aihubmixTools,\n });\n\n return provider as AihubmixProvider;\n}\n\nexport const aihubmix = createAihubmix();\n","import { createProviderToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\nexport const codeInterpreterInputSchema = z.object({\n code: z.string().nullish(),\n containerId: z.string(),\n});\n\nexport const codeInterpreterOutputSchema = z.object({\n outputs: z\n .array(\n z.discriminatedUnion('type', [\n z.object({ type: z.literal('logs'), logs: z.string() }),\n z.object({ type: z.literal('image'), url: z.string() }),\n ]),\n )\n .nullish(),\n});\n\nexport const codeInterpreterArgsSchema = z.object({\n container: z\n .union([\n z.string(),\n z.object({\n fileIds: z.array(z.string()).optional(),\n }),\n ])\n .optional(),\n});\n\ntype CodeInterpreterArgs = {\n /**\n * The code interpreter container.\n * Can be a container ID\n * or an object that specifies uploaded file IDs to make available to your code.\n */\n container?: string | { fileIds?: string[] };\n};\n\nexport const codeInterpreterToolFactory =\n createProviderToolFactoryWithOutputSchema<\n {\n /**\n * The code to run, or null if not available.\n */\n code?: string | null;\n\n /**\n * The ID of the container used to run the code.\n */\n containerId: string;\n },\n {\n /**\n * The outputs generated by the code interpreter, such as logs or images.\n * Can be null if no outputs are available.\n */\n outputs?: Array<\n | {\n type: 'logs';\n\n /**\n * The logs output from the code interpreter.\n */\n logs: string;\n }\n | {\n type: 'image';\n\n /**\n * The URL of the image output from the code interpreter.\n */\n url: string;\n }\n > | null;\n },\n CodeInterpreterArgs\n >({\n id: 'aihubmix.code_interpreter',\n inputSchema: codeInterpreterInputSchema,\n outputSchema: codeInterpreterOutputSchema,\n });\n\nexport const codeInterpreter = (\n args: CodeInterpreterArgs = {}, // default\n) => {\n return codeInterpreterToolFactory(args);\n};\n","import { createProviderToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\n/**\n * A filter used to compare a specified attribute key to a given value using a defined comparison operation.\n */\nexport type OpenAIResponsesFileSearchToolComparisonFilter = {\n /**\n * The key to compare against the value.\n */\n key: string;\n\n /**\n * Specifies the comparison operator: eq, ne, gt, gte, lt, lte.\n */\n type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';\n\n /**\n * The value to compare against the attribute key; supports string, number, or boolean types.\n */\n value: string | number | boolean;\n};\n\n/**\n * Combine multiple filters using and or or.\n */\nexport type OpenAIResponsesFileSearchToolCompoundFilter = {\n /**\n * Type of operation: and or or.\n */\n type: 'and' | 'or';\n\n /**\n * Array of filters to combine. Items can be ComparisonFilter or CompoundFilter.\n */\n filters: Array<\n | OpenAIResponsesFileSearchToolComparisonFilter\n | OpenAIResponsesFileSearchToolCompoundFilter\n >;\n};\n\nconst comparisonFilterSchema = z.object({\n key: z.string(),\n type: z.enum(['eq', 'ne', 'gt', 'gte', 'lt', 'lte']),\n value: z.union([z.string(), z.number(), z.boolean()]),\n});\n\nconst compoundFilterSchema: z.ZodType<any> = z.object({\n type: z.enum(['and', 'or']),\n filters: z.array(\n z.union([comparisonFilterSchema, z.lazy(() => compoundFilterSchema)]),\n ),\n});\n\nexport const fileSearchArgsSchema = z.object({\n vectorStoreIds: z.array(z.string()),\n maxNumResults: z.number().optional(),\n ranking: z\n .object({\n ranker: z.string().optional(),\n scoreThreshold: z.number().optional(),\n })\n .optional(),\n filters: z.union([comparisonFilterSchema, compoundFilterSchema]).optional(),\n});\n\nexport const fileSearchOutputSchema = z.object({\n queries: z.array(z.string()),\n results: z\n .array(\n z.object({\n attributes: z.record(z.string(), z.unknown()),\n fileId: z.string(),\n filename: z.string(),\n score: z.number(),\n text: z.string(),\n }),\n )\n .nullable(),\n});\n\nexport const fileSearch = createProviderToolFactoryWithOutputSchema<\n {},\n {\n /**\n * The search query to execute.\n */\n queries: string[];\n\n /**\n * The results of the file search tool call.\n */\n results:\n | null\n | {\n /**\n * Set of 16 key-value pairs that can be attached to an object.\n * This can be useful for storing additional information about the object\n * in a structured format, and querying for objects via API or the dashboard.\n * Keys are strings with a maximum length of 64 characters.\n * Values are strings with a maximum length of 512 characters, booleans, or numbers.\n */\n attributes: Record<string, unknown>;\n\n /**\n * The unique ID of the file.\n */\n fileId: string;\n\n /**\n * The name of the file.\n */\n filename: string;\n\n /**\n * The relevance score of the file - a value between 0 and 1.\n */\n score: number;\n\n /**\n * The text that was retrieved from the file.\n */\n text: string;\n }[];\n },\n {\n /**\n * List of vector store IDs to search through.\n */\n vectorStoreIds: string[];\n\n /**\n * Maximum number of search results to return. Defaults to 10.\n */\n maxNumResults?: number;\n\n /**\n * Ranking options for the search.\n */\n ranking?: {\n /**\n * The ranker to use for the file search.\n */\n ranker?: string;\n\n /**\n * The score threshold for the file search, a number between 0 and 1.\n * Numbers closer to 1 will attempt to return only the most relevant results,\n * but may return fewer results.\n */\n scoreThreshold?: number;\n };\n\n /**\n * A filter to apply.\n */\n filters?:\n | OpenAIResponsesFileSearchToolComparisonFilter\n | OpenAIResponsesFileSearchToolCompoundFilter;\n }\n>({\n id: 'aihubmix.file_search',\n inputSchema: z.object({}),\n outputSchema: fileSearchOutputSchema,\n});\n","import { createProviderToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\nexport const imageGenerationArgsSchema = z\n .object({\n background: z.enum(['auto', 'opaque', 'transparent']).optional(),\n inputFidelity: z.enum(['low', 'high']).optional(),\n inputImageMask: z\n .object({\n fileId: z.string().optional(),\n imageUrl: z.string().optional(),\n })\n .optional(),\n model: z.string().optional(),\n moderation: z.enum(['auto']).optional(),\n outputCompression: z.number().int().min(0).max(100).optional(),\n outputFormat: z.enum(['png', 'jpeg', 'webp']).optional(),\n quality: z.enum(['auto', 'low', 'medium', 'high']).optional(),\n size: z.enum(['1024x1024', '1024x1536', '1536x1024', 'auto']).optional(),\n })\n .strict();\n\nexport const imageGenerationOutputSchema = z.object({\n result: z.string(),\n});\n\ntype ImageGenerationArgs = {\n /**\n * Background type for the generated image. Default is 'auto'.\n */\n background?: 'auto' | 'opaque' | 'transparent';\n\n /**\n * Input fidelity for the generated image. Default is 'low'.\n */\n inputFidelity?: 'low' | 'high';\n\n /**\n * Optional mask for inpainting.\n * Contains image_url (string, optional) and file_id (string, optional).\n */\n inputImageMask?: {\n /**\n * File ID for the mask image.\n */\n fileId?: string;\n\n /**\n * Base64-encoded mask image.\n */\n imageUrl?: string;\n };\n\n /**\n * The image generation model to use. Default: gpt-image-1.\n */\n model?: string;\n\n /**\n * Moderation level for the generated image. Default: auto.\n */\n moderation?: 'auto';\n\n /**\n * Compression level for the output image. Default: 100.\n */\n outputCompression?: number;\n\n /**\n * The output format of the generated image. One of png, webp, or jpeg.\n * Default: png\n */\n outputFormat?: 'png' | 'jpeg' | 'webp';\n\n /**\n * The quality of the generated image.\n * One of low, medium, high, or auto. Default: auto.\n */\n quality?: 'auto' | 'low' | 'medium' | 'high';\n\n /**\n * The size of the generated image.\n * One of 1024x1024, 1024x1536, 1536x1024, or auto.\n * Default: auto.\n */\n size?: 'auto' | '1024x1024' | '1024x1536' | '1536x1024';\n};\n\nconst imageGenerationToolFactory =\n createProviderToolFactoryWithOutputSchema<\n {},\n {\n /**\n * The generated image encoded in base64.\n */\n result: string;\n },\n ImageGenerationArgs\n >({\n id: 'aihubmix.image_generation',\n inputSchema: z.object({}),\n outputSchema: imageGenerationOutputSchema,\n });\n\nexport const imageGeneration = (\n args: ImageGenerationArgs = {}, // default\n) => {\n return imageGenerationToolFactory(args);\n};\n","import { createProviderToolFactory } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\nexport const webSearchArgsSchema = z.object({\n filters: z\n .object({\n allowedDomains: z.array(z.string()).optional(),\n })\n .optional(),\n\n searchContextSize: z.enum(['low', 'medium', 'high']).optional(),\n\n userLocation: z\n .object({\n type: z.literal('approximate'),\n country: z.string().optional(),\n city: z.string().optional(),\n region: z.string().optional(),\n timezone: z.string().optional(),\n })\n .optional(),\n});\n\nexport const webSearchToolFactory = createProviderToolFactory<\n {\n // Web search doesn't take input parameters - it's controlled by the prompt\n },\n {\n /**\n * Filters for the search.\n */\n filters?: {\n /**\n * Allowed domains for the search.\n * If not provided, all domains are allowed.\n * Subdomains of the provided domains are allowed as well.\n */\n allowedDomains?: string[];\n };\n\n /**\n * Search context size to use for the web search.\n * - high: Most comprehensive context, highest cost, slower response\n * - medium: Balanced context, cost, and latency (default)\n * - low: Least context, lowest cost, fastest response\n */\n searchContextSize?: 'low' | 'medium' | 'high';\n\n /**\n * User location information to provide geographically relevant search results.\n */\n userLocation?: {\n /**\n * Type of location (always 'approximate')\n */\n type: 'approximate';\n /**\n * Two-letter ISO country code (e.g., 'US', 'GB')\n */\n country?: string;\n /**\n * City name (free text, e.g., 'Minneapolis')\n */\n city?: string;\n /**\n * Region name (free text, e.g., 'Minnesota')\n */\n region?: string;\n /**\n * IANA timezone (e.g., 'America/Chicago')\n */\n timezone?: string;\n };\n }\n>({\n id: 'aihubmix.web_search',\n inputSchema: z.object({\n action: z\n .discriminatedUnion('type', [\n z.object({\n type: z.literal('search'),\n query: z.string().nullish(),\n }),\n z.object({\n type: z.literal('open_page'),\n url: z.string(),\n }),\n z.object({\n type: z.literal('find'),\n url: z.string(),\n pattern: z.string(),\n }),\n ])\n .nullish(),\n }),\n});\n\nexport const webSearch = (\n args: Parameters<typeof webSearchToolFactory>[0] = {}, // default\n) => {\n return webSearchToolFactory(args);\n};\n","import { createProviderToolFactory } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\n// Args validation schema\nexport const webSearchPreviewArgsSchema = z.object({\n /**\n * Search context size to use for the web search.\n * - high: Most comprehensive context, highest cost, slower response\n * - medium: Balanced context, cost, and latency (default)\n * - low: Least context, lowest cost, fastest response\n */\n searchContextSize: z.enum(['low', 'medium', 'high']).optional(),\n\n /**\n * User location information to provide geographically relevant search results.\n */\n userLocation: z\n .object({\n /**\n * Type of location (always 'approximate')\n */\n type: z.literal('approximate'),\n /**\n * Two-letter ISO country code (e.g., 'US', 'GB')\n */\n country: z.string().optional(),\n /**\n * City name (free text, e.g., 'Minneapolis')\n */\n city: z.string().optional(),\n /**\n * Region name (free text, e.g., 'Minnesota')\n */\n region: z.string().optional(),\n /**\n * IANA timezone (e.g., 'America/Chicago')\n */\n timezone: z.string().optional(),\n })\n .optional(),\n});\n\nexport const webSearchPreview = createProviderToolFactory<\n {\n // Web search doesn't take input parameters - it's controlled by the prompt\n },\n {\n /**\n * Search context size to use for the web search.\n * - high: Most comprehensive context, highest cost, slower response\n * - medium: Balanced context, cost, and latency (default)\n * - low: Least context, lowest cost, fastest response\n */\n searchContextSize?: 'low' | 'medium' | 'high';\n\n /**\n * User location information to provide geographically relevant search results.\n */\n userLocation?: {\n /**\n * Type of location (always 'approximate')\n */\n type: 'approximate';\n /**\n * Two-letter ISO country code (e.g., 'US', 'GB')\n */\n country?: string;\n /**\n * City name (free text, e.g., 'Minneapolis')\n */\n city?: string;\n /**\n * Region name (free text, e.g., 'Minnesota')\n */\n region?: string;\n /**\n * IANA timezone (e.g., 'America/Chicago')\n */\n timezone?: string;\n };\n }\n>({\n id: 'aihubmix.web_search_preview',\n inputSchema: z.object({\n action: z\n .discriminatedUnion('type', [\n z.object({\n type: z.literal('search'),\n query: z.string().nullish(),\n }),\n z.object({\n type: z.literal('open_page'),\n url: z.string(),\n }),\n z.object({\n type: z.literal('find'),\n url: z.string(),\n pattern: z.string(),\n }),\n ])\n .nullish(),\n }),\n});\n","import { codeInterpreter } from './tool/code-interpreter';\nimport { fileSearch } from './tool/file-search';\nimport { imageGeneration } from './tool/image-generation';\nimport { webSearch } from './tool/web-search';\nimport { webSearchPreview } from './tool/web-search-preview';\n\nexport const aihubmixTools = {\n /**\n * The Code Interpreter tool allows models to write and run Python code in a\n * sandboxed environment to solve complex problems in domains like data analysis,\n * coding, and math.\n *\n * @param container - The container to use for the code interpreter.\n *\n * Must have name `code_interpreter`.\n */\n codeInterpreter,\n\n /**\n * File search is a tool available in the Responses API. It enables models to\n * retrieve information in a knowledge base of previously uploaded files through\n * semantic and keyword search.\n *\n * Must have name `file_search`.\n *\n * @param vectorStoreIds - The vector store IDs to use for the file search.\n * @param maxNumResults - The maximum number of results to return.\n * @param ranking - The ranking options to use for the file search.\n * @param filters - The filters to use for the file search.\n */\n fileSearch,\n\n /**\n * The image generation tool allows you to generate images using a text prompt,\n * and optionally image inputs. It leverages the GPT Image model,\n * and automatically optimizes text inputs for improved performance.\n *\n * Must have name `image_generation`.\n *\n * @param size - Image dimensions (e.g., 1024x1024, 1024x1536)\n * @param quality - Rendering quality (e.g. low, medium, high)\n * @param format - File output format\n * @param compression - Compression level (0-100%) for JPEG and WebP formats\n * @param background - Transparent or opaque\n */\n imageGeneration,\n\n /**\n * Web search allows models to access up-to-date information from the internet\n * and provide answers with sourced citations.\n *\n * Must have name `web_search_preview`.\n *\n * @param searchContextSize - The search context size to use for the web search.\n * @param userLocation - The user location to use for the web search.\n *\n * @deprecated Use `webSearch` instead.\n */\n webSearchPreview,\n\n /**\n * Web search allows models to access up-to-date information from the internet\n * and provide answers with sourced citations.\n *\n * Must have name `web_search`.\n *\n * @param filters - The filters to use for the web search.\n * @param searchContextSize - The search context size to use for the web search.\n * @param userLocation - The user location to use for the web search.\n */\n webSearch,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,+BAKO;AACP,sBAIO;AACP,IAAAA,mBAA+C;AAC/C,IAAAA,mBAAgD;AAUhD,IAAAC,yBAA0C;;;ACtB1C,4BAA0D;AAC1D,iBAAkB;AAEX,IAAM,6BAA6B,aAAE,OAAO;AAAA,EACjD,MAAM,aAAE,OAAO,EAAE,QAAQ;AAAA,EACzB,aAAa,aAAE,OAAO;AACxB,CAAC;AAEM,IAAM,8BAA8B,aAAE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AI,kCAAkB,SAAS;AAAA,IAC7B,UAAU;AAAA,IACV;AAAA,IACA,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB,CAAC;AAEH,QAAM,aAAa,SACjB,cACA,UACA;AACA,QAAI,YAAY;AACd,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,gBAAgB,cAAc,QAAQ;AAAA,EAC/C;AAGA,QAAM,WAAW,OAAO,OAAO,YAAY;AAAA,IACzC,sBAAsB;AAAA,IACtB,eAAe;AAAA,IACf,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,oBAAoB;AAAA,IACpB,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,oBAAoB;AAAA,IACpB,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,OAAO;AAAA,EACT,CAAC;AAED,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":["import_internal","import_provider_utils","import_provider_utils","import_zod","import_provider_utils","import_zod","import_provider_utils","import_zod","import_provider_utils","import_zod"]}
package/dist/index.mjs CHANGED
@@ -279,6 +279,7 @@ var aihubmixTools = {
279
279
  };
280
280
 
281
281
  // src/aihubmix-provider.ts
282
+ var DEFAULT_APP_CODE = "WHVL9885";
282
283
  var AihubmixTranscriptionModel = class extends OpenAITranscriptionModel {
283
284
  async doGenerate(options) {
284
285
  if (options.mediaType) {
@@ -339,13 +340,14 @@ function transformRequestBody(body) {
339
340
  return body;
340
341
  }
341
342
  function createAihubmix(options = {}) {
343
+ const appCode = options.appCode ?? DEFAULT_APP_CODE;
342
344
  const getHeaders = () => ({
343
345
  Authorization: `Bearer ${loadApiKey({
344
346
  apiKey: options.apiKey,
345
347
  environmentVariableName: "AIHUBMIX_API_KEY",
346
348
  description: "Aihubmix"
347
349
  })}`,
348
- "APP-Code": "WHVL9885",
350
+ "APP-Code": appCode,
349
351
  "Content-Type": "application/json"
350
352
  });
351
353
  const getTranscriptionHeaders = () => ({
@@ -354,7 +356,7 @@ function createAihubmix(options = {}) {
354
356
  environmentVariableName: "AIHUBMIX_API_KEY",
355
357
  description: "Aihubmix"
356
358
  })}`,
357
- "APP-Code": "WHVL9885"
359
+ "APP-Code": appCode
358
360
  });
359
361
  const url = ({ path, modelId }) => {
360
362
  const baseURL = "https://aihubmix.com/v1";
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/aihubmix-provider.ts","../src/tool/code-interpreter.ts","../src/tool/file-search.ts","../src/tool/image-generation.ts","../src/tool/web-search.ts","../src/tool/web-search-preview.ts","../src/aihubmix-tools.ts"],"sourcesContent":["import {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleCompletionLanguageModel,\n OpenAICompatibleEmbeddingModel,\n OpenAICompatibleImageModel,\n} from '@ai-sdk/openai-compatible';\nimport {\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 EmbeddingModelV3,\n LanguageModelV3,\n ProviderV3,\n ImageModelV3,\n TranscriptionModelV3,\n SpeechModelV3,\n TranscriptionModelV3CallOptions,\n} from '@ai-sdk/provider';\nimport { FetchFunction, loadApiKey } from '@ai-sdk/provider-utils';\nimport { aihubmixTools } from './aihubmix-tools';\n\n// OpenAI Provider 设置类型\ninterface OpenAIProviderSettings {\n [key: string]: unknown;\n}\n\n\nexport interface AihubmixProvider extends ProviderV3 {\n (deploymentId: string, settings?: OpenAIProviderSettings): LanguageModelV3;\n\n readonly specificationVersion: 'v3';\n\n languageModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV3;\n\n chat(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV3;\n\n responses(deploymentId: string): LanguageModelV3;\n\n completion(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV3;\n\n embedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV3;\n\n embeddingModel(modelId: string): EmbeddingModelV3;\n\n image(deploymentId: string, settings?: OpenAIProviderSettings): ImageModelV3;\n\n imageModel(modelId: string): ImageModelV3;\n\n textEmbedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV3;\n\n textEmbeddingModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV3;\n\n transcription(deploymentId: string): TranscriptionModelV3;\n\n speech(deploymentId: string): SpeechModelV3;\n\n speechModel(deploymentId: string): SpeechModelV3;\n\n tools: typeof aihubmixTools;\n}\nexport interface AihubmixProviderSettings {\n apiKey?: string;\n fetch?: FetchFunction;\n compatibility?: 'strict' | 'compatible';\n}\n\nclass AihubmixTranscriptionModel extends OpenAITranscriptionModel {\n async doGenerate(options: TranscriptionModelV3CallOptions) {\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\n// 修复空工具时的 tool_choice 问题\nfunction transformRequestBody(body: Record<string, any>): Record<string, any> {\n if (body.tools && Array.isArray(body.tools) && body.tools.length === 0 && body.tool_choice) {\n const { tool_choice, ...rest } = body;\n return rest;\n }\n return body;\n}export 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 const { Authorization, ...restHeaders } = headers;\n return new AnthropicMessagesLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n baseURL: url({ path: '', modelId: deploymentName }),\n headers: {\n ...restHeaders,\n 'x-api-key': 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 const { Authorization, ...restHeaders } = headers;\n return new GoogleGenerativeAILanguageModel(\n deploymentName,\n {\n provider: 'aihubmix.chat',\n baseURL: 'https://aihubmix.com/gemini/v1beta',\n headers: {\n ...restHeaders,\n 'x-goog-api-key': Authorization.split(' ')[1],\n },\n generateId: () => `aihubmix-${Date.now()}`,\n supportedUrls: () => ({}),\n },\n );\n }\n\n return new OpenAICompatibleChatLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n includeUsage: true,\n supportsStructuredOutputs: true,\n transformRequestBody,\n });\n };\n\n const createCompletionModel = (\n modelId: string,\n settings: any = {},\n ) =>\n new OpenAICompatibleCompletionLanguageModel(modelId, {\n provider: 'aihubmix.completion',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n includeUsage: true,\n });\n\n const createEmbeddingModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAICompatibleEmbeddingModel(modelId, {\n provider: 'aihubmix.embeddings',\n url,\n headers: getHeaders,\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 OpenAICompatibleImageModel(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\n const providerFn = 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 对象\n const provider = Object.assign(providerFn, {\n specificationVersion: 'v3' as const,\n languageModel: createChatModel,\n chat: createChatModel,\n completion: createCompletionModel,\n responses: createResponsesModel,\n embedding: createEmbeddingModel,\n embeddingModel: createEmbeddingModel,\n textEmbedding: createEmbeddingModel,\n textEmbeddingModel: createEmbeddingModel,\n image: createImageModel,\n imageModel: createImageModel,\n transcription: createTranscriptionModel,\n transcriptionModel: createTranscriptionModel,\n speech: createSpeechModel,\n speechModel: createSpeechModel,\n tools: aihubmixTools,\n });\n\n return provider as AihubmixProvider;\n}\n\nexport const aihubmix = createAihubmix();\n","import { createProviderToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\nexport const codeInterpreterInputSchema = z.object({\n code: z.string().nullish(),\n containerId: z.string(),\n});\n\nexport const codeInterpreterOutputSchema = z.object({\n outputs: z\n .array(\n z.discriminatedUnion('type', [\n z.object({ type: z.literal('logs'), logs: z.string() }),\n z.object({ type: z.literal('image'), url: z.string() }),\n ]),\n )\n .nullish(),\n});\n\nexport const codeInterpreterArgsSchema = z.object({\n container: z\n .union([\n z.string(),\n z.object({\n fileIds: z.array(z.string()).optional(),\n }),\n ])\n .optional(),\n});\n\ntype CodeInterpreterArgs = {\n /**\n * The code interpreter container.\n * Can be a container ID\n * or an object that specifies uploaded file IDs to make available to your code.\n */\n container?: string | { fileIds?: string[] };\n};\n\nexport const codeInterpreterToolFactory =\n createProviderToolFactoryWithOutputSchema<\n {\n /**\n * The code to run, or null if not available.\n */\n code?: string | null;\n\n /**\n * The ID of the container used to run the code.\n */\n containerId: string;\n },\n {\n /**\n * The outputs generated by the code interpreter, such as logs or images.\n * Can be null if no outputs are available.\n */\n outputs?: Array<\n | {\n type: 'logs';\n\n /**\n * The logs output from the code interpreter.\n */\n logs: string;\n }\n | {\n type: 'image';\n\n /**\n * The URL of the image output from the code interpreter.\n */\n url: string;\n }\n > | null;\n },\n CodeInterpreterArgs\n >({\n id: 'aihubmix.code_interpreter',\n inputSchema: codeInterpreterInputSchema,\n outputSchema: codeInterpreterOutputSchema,\n });\n\nexport const codeInterpreter = (\n args: CodeInterpreterArgs = {}, // default\n) => {\n return codeInterpreterToolFactory(args);\n};\n","import { createProviderToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\n/**\n * A filter used to compare a specified attribute key to a given value using a defined comparison operation.\n */\nexport type OpenAIResponsesFileSearchToolComparisonFilter = {\n /**\n * The key to compare against the value.\n */\n key: string;\n\n /**\n * Specifies the comparison operator: eq, ne, gt, gte, lt, lte.\n */\n type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';\n\n /**\n * The value to compare against the attribute key; supports string, number, or boolean types.\n */\n value: string | number | boolean;\n};\n\n/**\n * Combine multiple filters using and or or.\n */\nexport type OpenAIResponsesFileSearchToolCompoundFilter = {\n /**\n * Type of operation: and or or.\n */\n type: 'and' | 'or';\n\n /**\n * Array of filters to combine. Items can be ComparisonFilter or CompoundFilter.\n */\n filters: Array<\n | OpenAIResponsesFileSearchToolComparisonFilter\n | OpenAIResponsesFileSearchToolCompoundFilter\n >;\n};\n\nconst comparisonFilterSchema = z.object({\n key: z.string(),\n type: z.enum(['eq', 'ne', 'gt', 'gte', 'lt', 'lte']),\n value: z.union([z.string(), z.number(), z.boolean()]),\n});\n\nconst compoundFilterSchema: z.ZodType<any> = z.object({\n type: z.enum(['and', 'or']),\n filters: z.array(\n z.union([comparisonFilterSchema, z.lazy(() => compoundFilterSchema)]),\n ),\n});\n\nexport const fileSearchArgsSchema = z.object({\n vectorStoreIds: z.array(z.string()),\n maxNumResults: z.number().optional(),\n ranking: z\n .object({\n ranker: z.string().optional(),\n scoreThreshold: z.number().optional(),\n })\n .optional(),\n filters: z.union([comparisonFilterSchema, compoundFilterSchema]).optional(),\n});\n\nexport const fileSearchOutputSchema = z.object({\n queries: z.array(z.string()),\n results: z\n .array(\n z.object({\n attributes: z.record(z.string(), z.unknown()),\n fileId: z.string(),\n filename: z.string(),\n score: z.number(),\n text: z.string(),\n }),\n )\n .nullable(),\n});\n\nexport const fileSearch = createProviderToolFactoryWithOutputSchema<\n {},\n {\n /**\n * The search query to execute.\n */\n queries: string[];\n\n /**\n * The results of the file search tool call.\n */\n results:\n | null\n | {\n /**\n * Set of 16 key-value pairs that can be attached to an object.\n * This can be useful for storing additional information about the object\n * in a structured format, and querying for objects via API or the dashboard.\n * Keys are strings with a maximum length of 64 characters.\n * Values are strings with a maximum length of 512 characters, booleans, or numbers.\n */\n attributes: Record<string, unknown>;\n\n /**\n * The unique ID of the file.\n */\n fileId: string;\n\n /**\n * The name of the file.\n */\n filename: string;\n\n /**\n * The relevance score of the file - a value between 0 and 1.\n */\n score: number;\n\n /**\n * The text that was retrieved from the file.\n */\n text: string;\n }[];\n },\n {\n /**\n * List of vector store IDs to search through.\n */\n vectorStoreIds: string[];\n\n /**\n * Maximum number of search results to return. Defaults to 10.\n */\n maxNumResults?: number;\n\n /**\n * Ranking options for the search.\n */\n ranking?: {\n /**\n * The ranker to use for the file search.\n */\n ranker?: string;\n\n /**\n * The score threshold for the file search, a number between 0 and 1.\n * Numbers closer to 1 will attempt to return only the most relevant results,\n * but may return fewer results.\n */\n scoreThreshold?: number;\n };\n\n /**\n * A filter to apply.\n */\n filters?:\n | OpenAIResponsesFileSearchToolComparisonFilter\n | OpenAIResponsesFileSearchToolCompoundFilter;\n }\n>({\n id: 'aihubmix.file_search',\n inputSchema: z.object({}),\n outputSchema: fileSearchOutputSchema,\n});\n","import { createProviderToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\nexport const imageGenerationArgsSchema = z\n .object({\n background: z.enum(['auto', 'opaque', 'transparent']).optional(),\n inputFidelity: z.enum(['low', 'high']).optional(),\n inputImageMask: z\n .object({\n fileId: z.string().optional(),\n imageUrl: z.string().optional(),\n })\n .optional(),\n model: z.string().optional(),\n moderation: z.enum(['auto']).optional(),\n outputCompression: z.number().int().min(0).max(100).optional(),\n outputFormat: z.enum(['png', 'jpeg', 'webp']).optional(),\n quality: z.enum(['auto', 'low', 'medium', 'high']).optional(),\n size: z.enum(['1024x1024', '1024x1536', '1536x1024', 'auto']).optional(),\n })\n .strict();\n\nexport const imageGenerationOutputSchema = z.object({\n result: z.string(),\n});\n\ntype ImageGenerationArgs = {\n /**\n * Background type for the generated image. Default is 'auto'.\n */\n background?: 'auto' | 'opaque' | 'transparent';\n\n /**\n * Input fidelity for the generated image. Default is 'low'.\n */\n inputFidelity?: 'low' | 'high';\n\n /**\n * Optional mask for inpainting.\n * Contains image_url (string, optional) and file_id (string, optional).\n */\n inputImageMask?: {\n /**\n * File ID for the mask image.\n */\n fileId?: string;\n\n /**\n * Base64-encoded mask image.\n */\n imageUrl?: string;\n };\n\n /**\n * The image generation model to use. Default: gpt-image-1.\n */\n model?: string;\n\n /**\n * Moderation level for the generated image. Default: auto.\n */\n moderation?: 'auto';\n\n /**\n * Compression level for the output image. Default: 100.\n */\n outputCompression?: number;\n\n /**\n * The output format of the generated image. One of png, webp, or jpeg.\n * Default: png\n */\n outputFormat?: 'png' | 'jpeg' | 'webp';\n\n /**\n * The quality of the generated image.\n * One of low, medium, high, or auto. Default: auto.\n */\n quality?: 'auto' | 'low' | 'medium' | 'high';\n\n /**\n * The size of the generated image.\n * One of 1024x1024, 1024x1536, 1536x1024, or auto.\n * Default: auto.\n */\n size?: 'auto' | '1024x1024' | '1024x1536' | '1536x1024';\n};\n\nconst imageGenerationToolFactory =\n createProviderToolFactoryWithOutputSchema<\n {},\n {\n /**\n * The generated image encoded in base64.\n */\n result: string;\n },\n ImageGenerationArgs\n >({\n id: 'aihubmix.image_generation',\n inputSchema: z.object({}),\n outputSchema: imageGenerationOutputSchema,\n });\n\nexport const imageGeneration = (\n args: ImageGenerationArgs = {}, // default\n) => {\n return imageGenerationToolFactory(args);\n};\n","import { createProviderToolFactory } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\nexport const webSearchArgsSchema = z.object({\n filters: z\n .object({\n allowedDomains: z.array(z.string()).optional(),\n })\n .optional(),\n\n searchContextSize: z.enum(['low', 'medium', 'high']).optional(),\n\n userLocation: z\n .object({\n type: z.literal('approximate'),\n country: z.string().optional(),\n city: z.string().optional(),\n region: z.string().optional(),\n timezone: z.string().optional(),\n })\n .optional(),\n});\n\nexport const webSearchToolFactory = createProviderToolFactory<\n {\n // Web search doesn't take input parameters - it's controlled by the prompt\n },\n {\n /**\n * Filters for the search.\n */\n filters?: {\n /**\n * Allowed domains for the search.\n * If not provided, all domains are allowed.\n * Subdomains of the provided domains are allowed as well.\n */\n allowedDomains?: string[];\n };\n\n /**\n * Search context size to use for the web search.\n * - high: Most comprehensive context, highest cost, slower response\n * - medium: Balanced context, cost, and latency (default)\n * - low: Least context, lowest cost, fastest response\n */\n searchContextSize?: 'low' | 'medium' | 'high';\n\n /**\n * User location information to provide geographically relevant search results.\n */\n userLocation?: {\n /**\n * Type of location (always 'approximate')\n */\n type: 'approximate';\n /**\n * Two-letter ISO country code (e.g., 'US', 'GB')\n */\n country?: string;\n /**\n * City name (free text, e.g., 'Minneapolis')\n */\n city?: string;\n /**\n * Region name (free text, e.g., 'Minnesota')\n */\n region?: string;\n /**\n * IANA timezone (e.g., 'America/Chicago')\n */\n timezone?: string;\n };\n }\n>({\n id: 'aihubmix.web_search',\n inputSchema: z.object({\n action: z\n .discriminatedUnion('type', [\n z.object({\n type: z.literal('search'),\n query: z.string().nullish(),\n }),\n z.object({\n type: z.literal('open_page'),\n url: z.string(),\n }),\n z.object({\n type: z.literal('find'),\n url: z.string(),\n pattern: z.string(),\n }),\n ])\n .nullish(),\n }),\n});\n\nexport const webSearch = (\n args: Parameters<typeof webSearchToolFactory>[0] = {}, // default\n) => {\n return webSearchToolFactory(args);\n};\n","import { createProviderToolFactory } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\n// Args validation schema\nexport const webSearchPreviewArgsSchema = z.object({\n /**\n * Search context size to use for the web search.\n * - high: Most comprehensive context, highest cost, slower response\n * - medium: Balanced context, cost, and latency (default)\n * - low: Least context, lowest cost, fastest response\n */\n searchContextSize: z.enum(['low', 'medium', 'high']).optional(),\n\n /**\n * User location information to provide geographically relevant search results.\n */\n userLocation: z\n .object({\n /**\n * Type of location (always 'approximate')\n */\n type: z.literal('approximate'),\n /**\n * Two-letter ISO country code (e.g., 'US', 'GB')\n */\n country: z.string().optional(),\n /**\n * City name (free text, e.g., 'Minneapolis')\n */\n city: z.string().optional(),\n /**\n * Region name (free text, e.g., 'Minnesota')\n */\n region: z.string().optional(),\n /**\n * IANA timezone (e.g., 'America/Chicago')\n */\n timezone: z.string().optional(),\n })\n .optional(),\n});\n\nexport const webSearchPreview = createProviderToolFactory<\n {\n // Web search doesn't take input parameters - it's controlled by the prompt\n },\n {\n /**\n * Search context size to use for the web search.\n * - high: Most comprehensive context, highest cost, slower response\n * - medium: Balanced context, cost, and latency (default)\n * - low: Least context, lowest cost, fastest response\n */\n searchContextSize?: 'low' | 'medium' | 'high';\n\n /**\n * User location information to provide geographically relevant search results.\n */\n userLocation?: {\n /**\n * Type of location (always 'approximate')\n */\n type: 'approximate';\n /**\n * Two-letter ISO country code (e.g., 'US', 'GB')\n */\n country?: string;\n /**\n * City name (free text, e.g., 'Minneapolis')\n */\n city?: string;\n /**\n * Region name (free text, e.g., 'Minnesota')\n */\n region?: string;\n /**\n * IANA timezone (e.g., 'America/Chicago')\n */\n timezone?: string;\n };\n }\n>({\n id: 'aihubmix.web_search_preview',\n inputSchema: z.object({\n action: z\n .discriminatedUnion('type', [\n z.object({\n type: z.literal('search'),\n query: z.string().nullish(),\n }),\n z.object({\n type: z.literal('open_page'),\n url: z.string(),\n }),\n z.object({\n type: z.literal('find'),\n url: z.string(),\n pattern: z.string(),\n }),\n ])\n .nullish(),\n }),\n});\n","import { codeInterpreter } from './tool/code-interpreter';\nimport { fileSearch } from './tool/file-search';\nimport { imageGeneration } from './tool/image-generation';\nimport { webSearch } from './tool/web-search';\nimport { webSearchPreview } from './tool/web-search-preview';\n\nexport const aihubmixTools = {\n /**\n * The Code Interpreter tool allows models to write and run Python code in a\n * sandboxed environment to solve complex problems in domains like data analysis,\n * coding, and math.\n *\n * @param container - The container to use for the code interpreter.\n *\n * Must have name `code_interpreter`.\n */\n codeInterpreter,\n\n /**\n * File search is a tool available in the Responses API. It enables models to\n * retrieve information in a knowledge base of previously uploaded files through\n * semantic and keyword search.\n *\n * Must have name `file_search`.\n *\n * @param vectorStoreIds - The vector store IDs to use for the file search.\n * @param maxNumResults - The maximum number of results to return.\n * @param ranking - The ranking options to use for the file search.\n * @param filters - The filters to use for the file search.\n */\n fileSearch,\n\n /**\n * The image generation tool allows you to generate images using a text prompt,\n * and optionally image inputs. It leverages the GPT Image model,\n * and automatically optimizes text inputs for improved performance.\n *\n * Must have name `image_generation`.\n *\n * @param size - Image dimensions (e.g., 1024x1024, 1024x1536)\n * @param quality - Rendering quality (e.g. low, medium, high)\n * @param format - File output format\n * @param compression - Compression level (0-100%) for JPEG and WebP formats\n * @param background - Transparent or opaque\n */\n imageGeneration,\n\n /**\n * Web search allows models to access up-to-date information from the internet\n * and provide answers with sourced citations.\n *\n * Must have name `web_search_preview`.\n *\n * @param searchContextSize - The search context size to use for the web search.\n * @param userLocation - The user location to use for the web search.\n *\n * @deprecated Use `webSearch` instead.\n */\n webSearchPreview,\n\n /**\n * Web search allows models to access up-to-date information from the internet\n * and provide answers with sourced citations.\n *\n * Must have name `web_search`.\n *\n * @param filters - The filters to use for the web search.\n * @param searchContextSize - The search context size to use for the web search.\n * @param userLocation - The user location to use for the web search.\n */\n webSearch,\n};\n"],"mappings":";AAAA;AAAA,EACE;AAAA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C,UAAU;AAAA,IACV;AAAA,IACA,SAAS;AAAA,EACX,CAAC;AAEH,QAAM,mBAAmB,CACvB,SACA,WAAgB,CAAC,MACd;AACH,WAAO,IAAI,2BAA2B,SAAS;AAAA,MAC7C,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,kBAAkB,SAAS;AAAA,IAC7B,UAAU;AAAA,IACV;AAAA,IACA,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB,CAAC;AAEH,QAAM,aAAa,SACjB,cACA,UACA;AACA,QAAI,YAAY;AACd,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,gBAAgB,cAAc,QAAQ;AAAA,EAC/C;AAGA,QAAM,WAAW,OAAO,OAAO,YAAY;AAAA,IACzC,sBAAsB;AAAA,IACtB,eAAe;AAAA,IACf,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,oBAAoB;AAAA,IACpB,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,oBAAoB;AAAA,IACpB,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,OAAO;AAAA,EACT,CAAC;AAED,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":["createProviderToolFactoryWithOutputSchema","z","createProviderToolFactoryWithOutputSchema","z","z","createProviderToolFactory","z"]}
1
+ {"version":3,"sources":["../src/aihubmix-provider.ts","../src/tool/code-interpreter.ts","../src/tool/file-search.ts","../src/tool/image-generation.ts","../src/tool/web-search.ts","../src/tool/web-search-preview.ts","../src/aihubmix-tools.ts"],"sourcesContent":["import {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleCompletionLanguageModel,\n OpenAICompatibleEmbeddingModel,\n OpenAICompatibleImageModel,\n} from '@ai-sdk/openai-compatible';\nimport {\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 EmbeddingModelV3,\n LanguageModelV3,\n ProviderV3,\n ImageModelV3,\n TranscriptionModelV3,\n SpeechModelV3,\n TranscriptionModelV3CallOptions,\n} from '@ai-sdk/provider';\nimport { FetchFunction, loadApiKey } from '@ai-sdk/provider-utils';\nimport { aihubmixTools } from './aihubmix-tools';\n\n// OpenAI Provider 设置类型\ninterface OpenAIProviderSettings {\n [key: string]: unknown;\n}\n\n\nexport interface AihubmixProvider extends ProviderV3 {\n (deploymentId: string, settings?: OpenAIProviderSettings): LanguageModelV3;\n\n readonly specificationVersion: 'v3';\n\n languageModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV3;\n\n chat(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV3;\n\n responses(deploymentId: string): LanguageModelV3;\n\n completion(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV3;\n\n embedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV3;\n\n embeddingModel(modelId: string): EmbeddingModelV3;\n\n image(deploymentId: string, settings?: OpenAIProviderSettings): ImageModelV3;\n\n imageModel(modelId: string): ImageModelV3;\n\n textEmbedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV3;\n\n textEmbeddingModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV3;\n\n transcription(deploymentId: string): TranscriptionModelV3;\n\n speech(deploymentId: string): SpeechModelV3;\n\n speechModel(deploymentId: string): SpeechModelV3;\n\n tools: typeof aihubmixTools;\n}\nexport interface AihubmixProviderSettings {\n apiKey?: string;\n fetch?: FetchFunction;\n compatibility?: 'strict' | 'compatible';\n /**\n * APP-Code header sent with every request. Defaults to the project's\n * built-in app code; pass a value here to override it.\n */\n appCode?: string;\n}\n\n// 默认 APP-Code(项目内置),可通过 AihubmixProviderSettings.appCode 覆盖\nconst DEFAULT_APP_CODE = 'WHVL9885';\n\nclass AihubmixTranscriptionModel extends OpenAITranscriptionModel {\n async doGenerate(options: TranscriptionModelV3CallOptions) {\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\n// 修复空工具时的 tool_choice 问题\nfunction transformRequestBody(body: Record<string, any>): Record<string, any> {\n if (body.tools && Array.isArray(body.tools) && body.tools.length === 0 && body.tool_choice) {\n const { tool_choice, ...rest } = body;\n return rest;\n }\n return body;\n}export function createAihubmix(\n options: AihubmixProviderSettings = {},\n): AihubmixProvider {\n const appCode = options.appCode ?? DEFAULT_APP_CODE;\n\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': appCode,\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': appCode,\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 const { Authorization, ...restHeaders } = headers;\n return new AnthropicMessagesLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n baseURL: url({ path: '', modelId: deploymentName }),\n headers: {\n ...restHeaders,\n 'x-api-key': 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 const { Authorization, ...restHeaders } = headers;\n return new GoogleGenerativeAILanguageModel(\n deploymentName,\n {\n provider: 'aihubmix.chat',\n baseURL: 'https://aihubmix.com/gemini/v1beta',\n headers: {\n ...restHeaders,\n 'x-goog-api-key': Authorization.split(' ')[1],\n },\n generateId: () => `aihubmix-${Date.now()}`,\n supportedUrls: () => ({}),\n },\n );\n }\n\n return new OpenAICompatibleChatLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n includeUsage: true,\n supportsStructuredOutputs: true,\n transformRequestBody,\n });\n };\n\n const createCompletionModel = (\n modelId: string,\n settings: any = {},\n ) =>\n new OpenAICompatibleCompletionLanguageModel(modelId, {\n provider: 'aihubmix.completion',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n includeUsage: true,\n });\n\n const createEmbeddingModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAICompatibleEmbeddingModel(modelId, {\n provider: 'aihubmix.embeddings',\n url,\n headers: getHeaders,\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 OpenAICompatibleImageModel(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\n const providerFn = 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 对象\n const provider = Object.assign(providerFn, {\n specificationVersion: 'v3' as const,\n languageModel: createChatModel,\n chat: createChatModel,\n completion: createCompletionModel,\n responses: createResponsesModel,\n embedding: createEmbeddingModel,\n embeddingModel: createEmbeddingModel,\n textEmbedding: createEmbeddingModel,\n textEmbeddingModel: createEmbeddingModel,\n image: createImageModel,\n imageModel: createImageModel,\n transcription: createTranscriptionModel,\n transcriptionModel: createTranscriptionModel,\n speech: createSpeechModel,\n speechModel: createSpeechModel,\n tools: aihubmixTools,\n });\n\n return provider as AihubmixProvider;\n}\n\nexport const aihubmix = createAihubmix();\n","import { createProviderToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\nexport const codeInterpreterInputSchema = z.object({\n code: z.string().nullish(),\n containerId: z.string(),\n});\n\nexport const codeInterpreterOutputSchema = z.object({\n outputs: z\n .array(\n z.discriminatedUnion('type', [\n z.object({ type: z.literal('logs'), logs: z.string() }),\n z.object({ type: z.literal('image'), url: z.string() }),\n ]),\n )\n .nullish(),\n});\n\nexport const codeInterpreterArgsSchema = z.object({\n container: z\n .union([\n z.string(),\n z.object({\n fileIds: z.array(z.string()).optional(),\n }),\n ])\n .optional(),\n});\n\ntype CodeInterpreterArgs = {\n /**\n * The code interpreter container.\n * Can be a container ID\n * or an object that specifies uploaded file IDs to make available to your code.\n */\n container?: string | { fileIds?: string[] };\n};\n\nexport const codeInterpreterToolFactory =\n createProviderToolFactoryWithOutputSchema<\n {\n /**\n * The code to run, or null if not available.\n */\n code?: string | null;\n\n /**\n * The ID of the container used to run the code.\n */\n containerId: string;\n },\n {\n /**\n * The outputs generated by the code interpreter, such as logs or images.\n * Can be null if no outputs are available.\n */\n outputs?: Array<\n | {\n type: 'logs';\n\n /**\n * The logs output from the code interpreter.\n */\n logs: string;\n }\n | {\n type: 'image';\n\n /**\n * The URL of the image output from the code interpreter.\n */\n url: string;\n }\n > | null;\n },\n CodeInterpreterArgs\n >({\n id: 'aihubmix.code_interpreter',\n inputSchema: codeInterpreterInputSchema,\n outputSchema: codeInterpreterOutputSchema,\n });\n\nexport const codeInterpreter = (\n args: CodeInterpreterArgs = {}, // default\n) => {\n return codeInterpreterToolFactory(args);\n};\n","import { createProviderToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\n/**\n * A filter used to compare a specified attribute key to a given value using a defined comparison operation.\n */\nexport type OpenAIResponsesFileSearchToolComparisonFilter = {\n /**\n * The key to compare against the value.\n */\n key: string;\n\n /**\n * Specifies the comparison operator: eq, ne, gt, gte, lt, lte.\n */\n type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';\n\n /**\n * The value to compare against the attribute key; supports string, number, or boolean types.\n */\n value: string | number | boolean;\n};\n\n/**\n * Combine multiple filters using and or or.\n */\nexport type OpenAIResponsesFileSearchToolCompoundFilter = {\n /**\n * Type of operation: and or or.\n */\n type: 'and' | 'or';\n\n /**\n * Array of filters to combine. Items can be ComparisonFilter or CompoundFilter.\n */\n filters: Array<\n | OpenAIResponsesFileSearchToolComparisonFilter\n | OpenAIResponsesFileSearchToolCompoundFilter\n >;\n};\n\nconst comparisonFilterSchema = z.object({\n key: z.string(),\n type: z.enum(['eq', 'ne', 'gt', 'gte', 'lt', 'lte']),\n value: z.union([z.string(), z.number(), z.boolean()]),\n});\n\nconst compoundFilterSchema: z.ZodType<any> = z.object({\n type: z.enum(['and', 'or']),\n filters: z.array(\n z.union([comparisonFilterSchema, z.lazy(() => compoundFilterSchema)]),\n ),\n});\n\nexport const fileSearchArgsSchema = z.object({\n vectorStoreIds: z.array(z.string()),\n maxNumResults: z.number().optional(),\n ranking: z\n .object({\n ranker: z.string().optional(),\n scoreThreshold: z.number().optional(),\n })\n .optional(),\n filters: z.union([comparisonFilterSchema, compoundFilterSchema]).optional(),\n});\n\nexport const fileSearchOutputSchema = z.object({\n queries: z.array(z.string()),\n results: z\n .array(\n z.object({\n attributes: z.record(z.string(), z.unknown()),\n fileId: z.string(),\n filename: z.string(),\n score: z.number(),\n text: z.string(),\n }),\n )\n .nullable(),\n});\n\nexport const fileSearch = createProviderToolFactoryWithOutputSchema<\n {},\n {\n /**\n * The search query to execute.\n */\n queries: string[];\n\n /**\n * The results of the file search tool call.\n */\n results:\n | null\n | {\n /**\n * Set of 16 key-value pairs that can be attached to an object.\n * This can be useful for storing additional information about the object\n * in a structured format, and querying for objects via API or the dashboard.\n * Keys are strings with a maximum length of 64 characters.\n * Values are strings with a maximum length of 512 characters, booleans, or numbers.\n */\n attributes: Record<string, unknown>;\n\n /**\n * The unique ID of the file.\n */\n fileId: string;\n\n /**\n * The name of the file.\n */\n filename: string;\n\n /**\n * The relevance score of the file - a value between 0 and 1.\n */\n score: number;\n\n /**\n * The text that was retrieved from the file.\n */\n text: string;\n }[];\n },\n {\n /**\n * List of vector store IDs to search through.\n */\n vectorStoreIds: string[];\n\n /**\n * Maximum number of search results to return. Defaults to 10.\n */\n maxNumResults?: number;\n\n /**\n * Ranking options for the search.\n */\n ranking?: {\n /**\n * The ranker to use for the file search.\n */\n ranker?: string;\n\n /**\n * The score threshold for the file search, a number between 0 and 1.\n * Numbers closer to 1 will attempt to return only the most relevant results,\n * but may return fewer results.\n */\n scoreThreshold?: number;\n };\n\n /**\n * A filter to apply.\n */\n filters?:\n | OpenAIResponsesFileSearchToolComparisonFilter\n | OpenAIResponsesFileSearchToolCompoundFilter;\n }\n>({\n id: 'aihubmix.file_search',\n inputSchema: z.object({}),\n outputSchema: fileSearchOutputSchema,\n});\n","import { createProviderToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\nexport const imageGenerationArgsSchema = z\n .object({\n background: z.enum(['auto', 'opaque', 'transparent']).optional(),\n inputFidelity: z.enum(['low', 'high']).optional(),\n inputImageMask: z\n .object({\n fileId: z.string().optional(),\n imageUrl: z.string().optional(),\n })\n .optional(),\n model: z.string().optional(),\n moderation: z.enum(['auto']).optional(),\n outputCompression: z.number().int().min(0).max(100).optional(),\n outputFormat: z.enum(['png', 'jpeg', 'webp']).optional(),\n quality: z.enum(['auto', 'low', 'medium', 'high']).optional(),\n size: z.enum(['1024x1024', '1024x1536', '1536x1024', 'auto']).optional(),\n })\n .strict();\n\nexport const imageGenerationOutputSchema = z.object({\n result: z.string(),\n});\n\ntype ImageGenerationArgs = {\n /**\n * Background type for the generated image. Default is 'auto'.\n */\n background?: 'auto' | 'opaque' | 'transparent';\n\n /**\n * Input fidelity for the generated image. Default is 'low'.\n */\n inputFidelity?: 'low' | 'high';\n\n /**\n * Optional mask for inpainting.\n * Contains image_url (string, optional) and file_id (string, optional).\n */\n inputImageMask?: {\n /**\n * File ID for the mask image.\n */\n fileId?: string;\n\n /**\n * Base64-encoded mask image.\n */\n imageUrl?: string;\n };\n\n /**\n * The image generation model to use. Default: gpt-image-1.\n */\n model?: string;\n\n /**\n * Moderation level for the generated image. Default: auto.\n */\n moderation?: 'auto';\n\n /**\n * Compression level for the output image. Default: 100.\n */\n outputCompression?: number;\n\n /**\n * The output format of the generated image. One of png, webp, or jpeg.\n * Default: png\n */\n outputFormat?: 'png' | 'jpeg' | 'webp';\n\n /**\n * The quality of the generated image.\n * One of low, medium, high, or auto. Default: auto.\n */\n quality?: 'auto' | 'low' | 'medium' | 'high';\n\n /**\n * The size of the generated image.\n * One of 1024x1024, 1024x1536, 1536x1024, or auto.\n * Default: auto.\n */\n size?: 'auto' | '1024x1024' | '1024x1536' | '1536x1024';\n};\n\nconst imageGenerationToolFactory =\n createProviderToolFactoryWithOutputSchema<\n {},\n {\n /**\n * The generated image encoded in base64.\n */\n result: string;\n },\n ImageGenerationArgs\n >({\n id: 'aihubmix.image_generation',\n inputSchema: z.object({}),\n outputSchema: imageGenerationOutputSchema,\n });\n\nexport const imageGeneration = (\n args: ImageGenerationArgs = {}, // default\n) => {\n return imageGenerationToolFactory(args);\n};\n","import { createProviderToolFactory } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\nexport const webSearchArgsSchema = z.object({\n filters: z\n .object({\n allowedDomains: z.array(z.string()).optional(),\n })\n .optional(),\n\n searchContextSize: z.enum(['low', 'medium', 'high']).optional(),\n\n userLocation: z\n .object({\n type: z.literal('approximate'),\n country: z.string().optional(),\n city: z.string().optional(),\n region: z.string().optional(),\n timezone: z.string().optional(),\n })\n .optional(),\n});\n\nexport const webSearchToolFactory = createProviderToolFactory<\n {\n // Web search doesn't take input parameters - it's controlled by the prompt\n },\n {\n /**\n * Filters for the search.\n */\n filters?: {\n /**\n * Allowed domains for the search.\n * If not provided, all domains are allowed.\n * Subdomains of the provided domains are allowed as well.\n */\n allowedDomains?: string[];\n };\n\n /**\n * Search context size to use for the web search.\n * - high: Most comprehensive context, highest cost, slower response\n * - medium: Balanced context, cost, and latency (default)\n * - low: Least context, lowest cost, fastest response\n */\n searchContextSize?: 'low' | 'medium' | 'high';\n\n /**\n * User location information to provide geographically relevant search results.\n */\n userLocation?: {\n /**\n * Type of location (always 'approximate')\n */\n type: 'approximate';\n /**\n * Two-letter ISO country code (e.g., 'US', 'GB')\n */\n country?: string;\n /**\n * City name (free text, e.g., 'Minneapolis')\n */\n city?: string;\n /**\n * Region name (free text, e.g., 'Minnesota')\n */\n region?: string;\n /**\n * IANA timezone (e.g., 'America/Chicago')\n */\n timezone?: string;\n };\n }\n>({\n id: 'aihubmix.web_search',\n inputSchema: z.object({\n action: z\n .discriminatedUnion('type', [\n z.object({\n type: z.literal('search'),\n query: z.string().nullish(),\n }),\n z.object({\n type: z.literal('open_page'),\n url: z.string(),\n }),\n z.object({\n type: z.literal('find'),\n url: z.string(),\n pattern: z.string(),\n }),\n ])\n .nullish(),\n }),\n});\n\nexport const webSearch = (\n args: Parameters<typeof webSearchToolFactory>[0] = {}, // default\n) => {\n return webSearchToolFactory(args);\n};\n","import { createProviderToolFactory } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\n// Args validation schema\nexport const webSearchPreviewArgsSchema = z.object({\n /**\n * Search context size to use for the web search.\n * - high: Most comprehensive context, highest cost, slower response\n * - medium: Balanced context, cost, and latency (default)\n * - low: Least context, lowest cost, fastest response\n */\n searchContextSize: z.enum(['low', 'medium', 'high']).optional(),\n\n /**\n * User location information to provide geographically relevant search results.\n */\n userLocation: z\n .object({\n /**\n * Type of location (always 'approximate')\n */\n type: z.literal('approximate'),\n /**\n * Two-letter ISO country code (e.g., 'US', 'GB')\n */\n country: z.string().optional(),\n /**\n * City name (free text, e.g., 'Minneapolis')\n */\n city: z.string().optional(),\n /**\n * Region name (free text, e.g., 'Minnesota')\n */\n region: z.string().optional(),\n /**\n * IANA timezone (e.g., 'America/Chicago')\n */\n timezone: z.string().optional(),\n })\n .optional(),\n});\n\nexport const webSearchPreview = createProviderToolFactory<\n {\n // Web search doesn't take input parameters - it's controlled by the prompt\n },\n {\n /**\n * Search context size to use for the web search.\n * - high: Most comprehensive context, highest cost, slower response\n * - medium: Balanced context, cost, and latency (default)\n * - low: Least context, lowest cost, fastest response\n */\n searchContextSize?: 'low' | 'medium' | 'high';\n\n /**\n * User location information to provide geographically relevant search results.\n */\n userLocation?: {\n /**\n * Type of location (always 'approximate')\n */\n type: 'approximate';\n /**\n * Two-letter ISO country code (e.g., 'US', 'GB')\n */\n country?: string;\n /**\n * City name (free text, e.g., 'Minneapolis')\n */\n city?: string;\n /**\n * Region name (free text, e.g., 'Minnesota')\n */\n region?: string;\n /**\n * IANA timezone (e.g., 'America/Chicago')\n */\n timezone?: string;\n };\n }\n>({\n id: 'aihubmix.web_search_preview',\n inputSchema: z.object({\n action: z\n .discriminatedUnion('type', [\n z.object({\n type: z.literal('search'),\n query: z.string().nullish(),\n }),\n z.object({\n type: z.literal('open_page'),\n url: z.string(),\n }),\n z.object({\n type: z.literal('find'),\n url: z.string(),\n pattern: z.string(),\n }),\n ])\n .nullish(),\n }),\n});\n","import { codeInterpreter } from './tool/code-interpreter';\nimport { fileSearch } from './tool/file-search';\nimport { imageGeneration } from './tool/image-generation';\nimport { webSearch } from './tool/web-search';\nimport { webSearchPreview } from './tool/web-search-preview';\n\nexport const aihubmixTools = {\n /**\n * The Code Interpreter tool allows models to write and run Python code in a\n * sandboxed environment to solve complex problems in domains like data analysis,\n * coding, and math.\n *\n * @param container - The container to use for the code interpreter.\n *\n * Must have name `code_interpreter`.\n */\n codeInterpreter,\n\n /**\n * File search is a tool available in the Responses API. It enables models to\n * retrieve information in a knowledge base of previously uploaded files through\n * semantic and keyword search.\n *\n * Must have name `file_search`.\n *\n * @param vectorStoreIds - The vector store IDs to use for the file search.\n * @param maxNumResults - The maximum number of results to return.\n * @param ranking - The ranking options to use for the file search.\n * @param filters - The filters to use for the file search.\n */\n fileSearch,\n\n /**\n * The image generation tool allows you to generate images using a text prompt,\n * and optionally image inputs. It leverages the GPT Image model,\n * and automatically optimizes text inputs for improved performance.\n *\n * Must have name `image_generation`.\n *\n * @param size - Image dimensions (e.g., 1024x1024, 1024x1536)\n * @param quality - Rendering quality (e.g. low, medium, high)\n * @param format - File output format\n * @param compression - Compression level (0-100%) for JPEG and WebP formats\n * @param background - Transparent or opaque\n */\n imageGeneration,\n\n /**\n * Web search allows models to access up-to-date information from the internet\n * and provide answers with sourced citations.\n *\n * Must have name `web_search_preview`.\n *\n * @param searchContextSize - The search context size to use for the web search.\n * @param userLocation - The user location to use for the web search.\n *\n * @deprecated Use `webSearch` instead.\n */\n webSearchPreview,\n\n /**\n * Web search allows models to access up-to-date information from the internet\n * and provide answers with sourced citations.\n *\n * Must have name `web_search`.\n *\n * @param filters - The filters to use for the web search.\n * @param searchContextSize - The search context size to use for the web search.\n * @param userLocation - The user location to use for the web search.\n */\n webSearch,\n};\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sCAAsC;AAC/C,SAAS,uCAAuC;AAUhD,SAAwB,kBAAkB;;;ACtB1C,SAAS,iDAAiD;AAC1D,SAAS,SAAS;AAEX,IAAM,6BAA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,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,kBAAkB,SAAS;AAAA,IAC7B,UAAU;AAAA,IACV;AAAA,IACA,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB,CAAC;AAEH,QAAM,aAAa,SACjB,cACA,UACA;AACA,QAAI,YAAY;AACd,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,gBAAgB,cAAc,QAAQ;AAAA,EAC/C;AAGA,QAAM,WAAW,OAAO,OAAO,YAAY;AAAA,IACzC,sBAAsB;AAAA,IACtB,eAAe;AAAA,IACf,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,oBAAoB;AAAA,IACpB,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,oBAAoB;AAAA,IACpB,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,OAAO;AAAA,EACT,CAAC;AAED,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":["createProviderToolFactoryWithOutputSchema","z","createProviderToolFactoryWithOutputSchema","z","z","createProviderToolFactory","z"]}
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@aihubmix/ai-sdk-provider",
3
- "version": "2.0.6",
3
+ "version": "2.2.0",
4
4
  "license": "Apache-2.0",
5
+ "packageManager": "pnpm@10.28.0",
5
6
  "sideEffects": false,
6
7
  "main": "./dist/index.js",
7
8
  "module": "./dist/index.mjs",
@@ -10,6 +11,18 @@
10
11
  "dist/**/*",
11
12
  "CHANGELOG.md"
12
13
  ],
14
+ "scripts": {
15
+ "build": "tsup",
16
+ "build:watch": "tsup --watch",
17
+ "clean": "rm -rf dist",
18
+ "lint": "eslint \"./**/*.ts*\"",
19
+ "type-check": "tsc --noEmit",
20
+ "prettier-check": "prettier --check \"./**/*.ts*\" --write",
21
+ "test": "pnpm test:node && pnpm test:edge",
22
+ "test:edge": "vitest --config vitest.edge.config.js --run",
23
+ "test:node": "vitest --config vitest.node.config.js --run",
24
+ "test:node:watch": "vitest --config vitest.node.config.js"
25
+ },
13
26
  "exports": {
14
27
  "./package.json": "./package.json",
15
28
  ".": {
@@ -60,17 +73,5 @@
60
73
  "aihubmix",
61
74
  "ai-sdk-provider",
62
75
  "ai-sdk"
63
- ],
64
- "scripts": {
65
- "build": "tsup",
66
- "build:watch": "tsup --watch",
67
- "clean": "rm -rf dist",
68
- "lint": "eslint \"./**/*.ts*\"",
69
- "type-check": "tsc --noEmit",
70
- "prettier-check": "prettier --check \"./**/*.ts*\" --write",
71
- "test": "pnpm test:node && pnpm test:edge",
72
- "test:edge": "vitest --config vitest.edge.config.js --run",
73
- "test:node": "vitest --config vitest.node.config.js --run",
74
- "test:node:watch": "vitest --config vitest.node.config.js"
75
- }
76
- }
76
+ ]
77
+ }