@aihubmix/ai-sdk-provider 2.0.4 → 2.0.5

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.
@@ -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 OpenAIChatLanguageModel,\n OpenAICompletionLanguageModel,\n OpenAIEmbeddingModel,\n OpenAIImageModel,\n OpenAIResponsesLanguageModel,\n OpenAITranscriptionModel,\n OpenAISpeechModel,\n} from '@ai-sdk/openai/internal';\nimport { AnthropicMessagesLanguageModel } from '@ai-sdk/anthropic/internal';\nimport { GoogleGenerativeAILanguageModel } from '@ai-sdk/google/internal';\nimport {\n EmbeddingModelV3,\n LanguageModelV3,\n ProviderV3,\n ImageModelV3,\n TranscriptionModelV3,\n SpeechModelV3,\n TranscriptionModelV3CallOptions,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n zodSchema,\n lazySchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\nimport { aihubmixTools } from './aihubmix-tools';\n\n/**\n * OpenAI Chat 语言模型的 Provider Options Schema\n * 与 Vercel AI SDK 的 openaiChatLanguageModelOptions 保持一致\n */\nexport const aihubmixChatProviderOptionsSchema = lazySchema(() =>\n zodSchema(\n z.object({\n /**\n * 修改指定 token 出现在生成内容中的概率\n * 接受一个 JSON 对象,将 token ID(字符串形式)映射到 -100 到 100 之间的偏差值\n */\n logitBias: z.record(z.string(), z.number()).optional(),\n\n /**\n * 返回 token 的对数概率\n * 设置为 true 返回生成 token 的对数概率\n * 设置为数字返回前 n 个 token 的对数概率\n */\n logprobs: z.union([z.boolean(), z.number()]).optional(),\n\n /**\n * 是否启用并行工具调用,默认为 true\n */\n parallelToolCalls: z.boolean().optional(),\n\n /**\n * 代表终端用户的唯一标识符,帮助 OpenAI 监控和检测滥用行为\n */\n user: z.string().optional(),\n\n /**\n * 推理模型的推理强度,默认为 `medium`\n */\n reasoningEffort: z\n .enum(['none', 'minimal', 'low', 'medium', 'high', 'xhigh'])\n .optional(),\n\n /**\n * 生成的最大完成 token 数,适用于推理模型\n */\n maxCompletionTokens: z.number().optional(),\n\n /**\n * 是否在 Responses API 中启用持久化\n */\n store: z.boolean().optional(),\n\n /**\n * 与请求关联的元数据\n */\n metadata: z.record(z.string().max(64), z.string().max(512)).optional(),\n\n /**\n * 预测模式的参数\n */\n prediction: z.record(z.string(), z.any()).optional(),\n\n /**\n * 请求的服务层级\n * - 'auto': 默认服务层级\n * - 'flex': 50% 更便宜但延迟更高(仅限 o3, o4-mini, gpt-5)\n * - 'priority': 更快处理(需要企业版)\n * - 'default': 标准定价和性能\n */\n serviceTier: z.enum(['auto', 'flex', 'priority', 'default']).optional(),\n\n /**\n * 是否使用严格的 JSON schema 验证\n * @default true\n */\n strictJsonSchema: z.boolean().optional(),\n\n /**\n * 控制模型响应的详细程度\n * 较低的值会产生更简洁的响应,较高的值会产生更详细的响应\n */\n textVerbosity: z.enum(['low', 'medium', 'high']).optional(),\n\n /**\n * 提示缓存的缓存键\n */\n promptCacheKey: z.string().optional(),\n\n /**\n * 提示缓存的保留策略\n * - 'in_memory': 默认,标准提示缓存行为\n * - '24h': 扩展提示缓存,保持缓存前缀最多 24 小时\n */\n promptCacheRetention: z.enum(['in_memory', '24h']).optional(),\n\n /**\n * 用于帮助检测违反使用政策用户的稳定标识符\n */\n safetyIdentifier: z.string().optional(),\n\n /**\n * 覆盖此模型的系统消息模式\n * - 'system': 使用 'system' 角色(大多数模型的默认值)\n * - 'developer': 使用 'developer' 角色(推理模型使用)\n * - 'remove': 完全移除系统消息\n */\n systemMessageMode: z.enum(['system', 'developer', 'remove']).optional(),\n\n /**\n * 强制将此模型视为推理模型\n * 适用于自定义 baseURL 的\"隐形\"推理模型\n */\n forceReasoning: z.boolean().optional(),\n }),\n ),\n);\n\n/**\n * OpenAI Responses API 的 Provider Options Schema\n */\nexport const aihubmixResponsesProviderOptionsSchema = lazySchema(() =>\n zodSchema(\n z.object({\n /**\n * OpenAI 对话的 ID,用于继续对话\n */\n conversation: z.string().nullish(),\n\n /**\n * 响应中包含的额外字段\n */\n include: z\n .array(\n z.enum([\n 'reasoning.encrypted_content',\n 'file_search_call.results',\n 'message.output_text.logprobs',\n ]),\n )\n .nullish(),\n\n /**\n * 模型的指令\n */\n instructions: z.string().nullish(),\n\n /**\n * 返回 token 的对数概率\n */\n logprobs: z\n .union([z.boolean(), z.number().min(1).max(20)])\n .optional(),\n\n /**\n * 内置工具调用的最大总数\n */\n maxToolCalls: z.number().nullish(),\n\n /**\n * 与生成关联的额外元数据\n */\n metadata: z.any().nullish(),\n\n /**\n * 是否使用并行工具调用,默认为 true\n */\n parallelToolCalls: z.boolean().nullish(),\n\n /**\n * 上一个响应的 ID,用于继续对话\n */\n previousResponseId: z.string().nullish(),\n\n /**\n * 提示缓存键\n */\n promptCacheKey: z.string().nullish(),\n\n /**\n * 提示缓存保留策略\n */\n promptCacheRetention: z.enum(['in_memory', '24h']).nullish(),\n\n /**\n * 推理模型的推理强度\n */\n reasoningEffort: z.string().nullish(),\n\n /**\n * 控制推理摘要输出\n */\n reasoningSummary: z.string().nullish(),\n\n /**\n * 安全监控的标识符\n */\n safetyIdentifier: z.string().nullish(),\n\n /**\n * 请求的服务层级\n */\n serviceTier: z.enum(['auto', 'flex', 'priority', 'default']).nullish(),\n\n /**\n * 是否存储生成内容,默认为 true\n */\n store: z.boolean().nullish(),\n\n /**\n * 是否使用严格的 JSON schema 验证\n */\n strictJsonSchema: z.boolean().nullish(),\n\n /**\n * 控制模型响应的详细程度\n */\n textVerbosity: z.enum(['low', 'medium', 'high']).nullish(),\n\n /**\n * 输出截断控制\n */\n truncation: z.enum(['auto', 'disabled']).nullish(),\n\n /**\n * 代表终端用户的唯一标识符\n */\n user: z.string().nullish(),\n\n /**\n * 系统消息模式\n */\n systemMessageMode: z.enum(['system', 'developer', 'remove']).optional(),\n\n /**\n * 强制将模型视为推理模型\n */\n forceReasoning: z.boolean().optional(),\n }),\n ),\n);\n\n// Provider Options 类型推断\nexport type AihubmixChatProviderOptions = InferSchema<\n typeof aihubmixChatProviderOptionsSchema\n>;\n\nexport type AihubmixResponsesProviderOptions = InferSchema<\n typeof aihubmixResponsesProviderOptionsSchema\n>;\n\n// OpenAI Provider 设置类型(保持向后兼容)\ntype OpenAIProviderSettings = AihubmixChatProviderOptions;\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// 自定义 OpenAI 聊天模型类,修复空工具时的 tool_choice 问题\nclass AihubmixOpenAIChatLanguageModel extends OpenAIChatLanguageModel {\n constructor(modelId: string, settings: any) {\n super(modelId, {\n ...settings,\n fetch: AihubmixOpenAIChatLanguageModel.createCustomFetch(settings.fetch),\n });\n }\n\n private static createCustomFetch(originalFetch?: any) {\n return async (url: string, options: any) => {\n // 拦截请求并修复 tool_choice 问题\n if (options?.body) {\n try {\n const body = JSON.parse(options.body);\n if (body.tools && Array.isArray(body.tools) && body.tools.length === 0 && body.tool_choice) {\n delete body.tool_choice;\n options.body = JSON.stringify(body);\n }\n } catch (error) {\n // 如果解析失败,继续使用原始请求\n }\n }\n \n return originalFetch ? originalFetch(url, options) : fetch(url, options);\n };\n }\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 return new AnthropicMessagesLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n baseURL: url({ path: '', modelId: deploymentName }),\n headers: {\n ...headers,\n 'x-api-key': headers['Authorization'].split(' ')[1],\n },\n supportedUrls: () => ({\n 'image/*': [/^https?:\\/\\/.*$/],\n }),\n });\n }\n if (\n (deploymentName.startsWith('gemini') ||\n deploymentName.startsWith('imagen')) &&\n !deploymentName.endsWith('-nothink') &&\n !deploymentName.endsWith('-search')\n ) {\n return new GoogleGenerativeAILanguageModel(\n deploymentName,\n {\n provider: 'aihubmix.chat',\n baseURL: 'https://aihubmix.com/gemini/v1beta',\n headers: {\n ...headers,\n 'x-goog-api-key': headers['Authorization'].split(' ')[1],\n },\n generateId: () => `aihubmix-${Date.now()}`,\n supportedUrls: () => ({}),\n },\n );\n }\n\n if (deploymentName === \"gpt-5-pro\" || deploymentName === \"gpt-5-codex\") {\n\t\t\treturn new OpenAIResponsesLanguageModel(deploymentName, {\n\t\t\t\tprovider: 'aihubmix.chat',\n\t\t\t\turl,\n\t\t\t\theaders: getHeaders,\n\t\t\t\tfetch: options.fetch,\n\t\t\t\tfileIdPrefixes: ['file-'],\n\t\t\t});\n\t\t}\n\n return new AihubmixOpenAIChatLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n };\n\n const createCompletionModel = (\n modelId: string,\n settings: any = {},\n ) =>\n new OpenAICompletionLanguageModel(modelId, {\n provider: 'aihubmix.completion',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createEmbeddingModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAIEmbeddingModel(modelId, {\n provider: 'aihubmix.embeddings',\n headers: getHeaders,\n url,\n fetch: options.fetch,\n });\n };\n\n const createResponsesModel = (modelId: string) =>\n new OpenAIResponsesLanguageModel(modelId, {\n provider: 'aihubmix.responses',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n fileIdPrefixes: ['file-'],\n });\n\n const createImageModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAIImageModel(modelId, {\n provider: 'aihubmix.image',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n };\n\n const createTranscriptionModel = (modelId: string) =>\n new AihubmixTranscriptionModel(modelId, {\n provider: 'aihubmix.transcription',\n url,\n headers: getTranscriptionHeaders,\n fetch: options.fetch,\n });\n const createSpeechModel = (modelId: string) =>\n new OpenAISpeechModel(modelId, {\n provider: 'aihubmix.speech',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\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,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sCAAsC;AAC/C,SAAS,uCAAuC;AAUhD;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;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chema","z","createProviderToolFactoryWithOutputSchema","z","z","createProviderToolFactory","z","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\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 return new AnthropicMessagesLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n baseURL: url({ path: '', modelId: deploymentName }),\n headers: {\n ...headers,\n 'x-api-key': headers['Authorization'].split(' ')[1],\n },\n supportedUrls: () => ({\n 'image/*': [/^https?:\\/\\/.*$/],\n }),\n });\n }\n if (\n (deploymentName.startsWith('gemini') ||\n deploymentName.startsWith('imagen')) &&\n !deploymentName.endsWith('-nothink') &&\n !deploymentName.endsWith('-search')\n ) {\n return new GoogleGenerativeAILanguageModel(\n deploymentName,\n {\n provider: 'aihubmix.chat',\n baseURL: 'https://aihubmix.com/gemini/v1beta',\n headers: {\n ...headers,\n 'x-goog-api-key': headers['Authorization'].split(' ')[1],\n },\n generateId: () => `aihubmix-${Date.now()}`,\n supportedUrls: () => ({}),\n },\n );\n }\n\n return new 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,6BAA6B,EAAE,OAAO;AAAA,EACjD,MAAM,EAAE,OAAO,EAAE,QAAQ;A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AAA,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.4",
3
+ "version": "2.0.5",
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
  ".": {
@@ -22,17 +35,24 @@
22
35
  "@ai-sdk/anthropic": "^3.0.0",
23
36
  "@ai-sdk/google": "^3.0.0",
24
37
  "@ai-sdk/openai": "^3.0.0",
38
+ "@ai-sdk/openai-compatible": "^2.0.37",
25
39
  "@ai-sdk/provider": "^3.0.0",
26
- "@ai-sdk/provider-utils": "^4.0.0",
27
- "zod": "^3.25.76"
40
+ "@ai-sdk/provider-utils": "^4.0.0"
41
+ },
42
+ "peerDependencies": {
43
+ "zod": "^3.25.0 || ^4.0.0"
28
44
  },
29
45
  "devDependencies": {
46
+ "@changesets/cli": "^2.29.0",
30
47
  "@edge-runtime/vm": "^2.0.0",
31
48
  "@types/node": "20.17.24",
32
49
  "jsdom": "^24.0.0",
50
+ "msw": "^2.7.0",
33
51
  "tsup": "^8",
52
+ "turbo": "^2.5.0",
34
53
  "typescript": "5.6.3",
35
- "vitest": "^2.0.0"
54
+ "vitest": "^2.0.0",
55
+ "zod": "^3.25.0"
36
56
  },
37
57
  "engines": {
38
58
  "node": ">=18"
@@ -43,27 +63,15 @@
43
63
  "homepage": "https://aihubmix.com",
44
64
  "repository": {
45
65
  "type": "git",
46
- "url": "git+https://github.com/inferera/aihubmix.git"
66
+ "url": "git+https://github.com/AIhubmix/ai-sdk-provider.git"
47
67
  },
48
68
  "bugs": {
49
- "url": "https://github.com/inferera/aihubmix/issues"
69
+ "url": "https://github.com/AIhubmix/ai-sdk-provider/issues"
50
70
  },
51
71
  "keywords": [
52
72
  "ai",
53
73
  "aihubmix",
54
74
  "ai-sdk-provider",
55
75
  "ai-sdk"
56
- ],
57
- "scripts": {
58
- "build": "tsup",
59
- "build:watch": "tsup --watch",
60
- "clean": "rm -rf dist",
61
- "lint": "eslint \"./**/*.ts*\"",
62
- "type-check": "tsc --noEmit",
63
- "prettier-check": "prettier --check \"./**/*.ts*\" --write",
64
- "test": "pnpm test:node && pnpm test:edge",
65
- "test:edge": "vitest --config vitest.edge.config.js --run",
66
- "test:node": "vitest --config vitest.node.config.js --run",
67
- "test:node:watch": "vitest --config vitest.node.config.js"
68
- }
69
- }
76
+ ]
77
+ }
package/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.