@aihubmix/ai-sdk-provider 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -8,12 +8,8 @@ import {
8
8
  OpenAITranscriptionModel,
9
9
  OpenAISpeechModel
10
10
  } from "@ai-sdk/openai/internal";
11
- import {
12
- AnthropicMessagesLanguageModel
13
- } from "@ai-sdk/anthropic/internal";
14
- import {
15
- GoogleGenerativeAILanguageModel
16
- } from "@ai-sdk/google/internal";
11
+ import { AnthropicMessagesLanguageModel } from "@ai-sdk/anthropic/internal";
12
+ import { GoogleGenerativeAILanguageModel } from "@ai-sdk/google/internal";
17
13
  import { loadApiKey } from "@ai-sdk/provider-utils";
18
14
 
19
15
  // src/aihubmix-tools.ts
@@ -24,16 +20,15 @@ function webSearchPreviewTool({
24
20
  userLocation
25
21
  } = {}) {
26
22
  return {
27
- type: "provider-defined",
28
- id: "openai.web_search_preview",
29
- args: {
30
- searchContextSize,
31
- userLocation
32
- },
33
- parameters: WebSearchPreviewParameters
23
+ type: "function",
24
+ function: {
25
+ name: "aihubmix.web_search_preview",
26
+ description: "Search the web for current information and preview results",
27
+ parameters: WebSearchPreviewParameters
28
+ }
34
29
  };
35
30
  }
36
- var openaiTools = {
31
+ var aihubmixTools = {
37
32
  webSearchPreview: webSearchPreviewTool
38
33
  };
39
34
 
@@ -55,38 +50,42 @@ var AihubmixTranscriptionModel = class extends OpenAITranscriptionModel {
55
50
  };
56
51
  const extension = mimeTypeMap[options.mediaType];
57
52
  if (extension) {
58
- const modifiedOptions = {
59
- ...options,
60
- mediaType: options.mediaType
61
- };
62
53
  const originalGetArgs = this.getArgs;
63
- this.getArgs = function(args) {
64
- const result = originalGetArgs.call(this, args);
54
+ this.getArgs = async function(args) {
55
+ const result = await originalGetArgs.call(this, args);
65
56
  if (result.formData) {
66
57
  const fileEntry = result.formData.get("file");
67
58
  if (fileEntry && typeof fileEntry === "object" && "name" in fileEntry) {
68
59
  try {
69
- const newFile = new globalThis.File([fileEntry], `audio.${extension}`, {
60
+ const newFile = new File([fileEntry], `audio.${extension}`, {
70
61
  type: options.mediaType
71
62
  });
72
63
  result.formData.set("file", newFile);
73
64
  } catch (error) {
74
- if (fileEntry && typeof fileEntry === "object") {
75
- fileEntry.name = `audio.${extension}`;
65
+ console.log("Failed to create new File object:", error);
66
+ if (fileEntry && typeof fileEntry === "object" && "arrayBuffer" in fileEntry) {
67
+ try {
68
+ const arrayBuffer = await fileEntry.arrayBuffer();
69
+ const newFile = new File([arrayBuffer], `audio.${extension}`, {
70
+ type: options.mediaType
71
+ });
72
+ result.formData.set("file", newFile);
73
+ console.log("Created new file from arrayBuffer with name:", `audio.${extension}`);
74
+ } catch (bufferError) {
75
+ console.log("Failed to create file from arrayBuffer:", bufferError);
76
+ }
76
77
  }
77
78
  }
78
79
  }
79
80
  }
80
81
  return result;
81
82
  };
82
- return super.doGenerate(modifiedOptions);
83
83
  }
84
84
  }
85
85
  return super.doGenerate(options);
86
86
  }
87
87
  };
88
88
  function createAihubmix(options = {}) {
89
- const compatibility = options.compatibility ?? "compatible";
90
89
  const getHeaders = () => ({
91
90
  Authorization: `Bearer ${loadApiKey({
92
91
  apiKey: options.apiKey,
@@ -111,24 +110,21 @@ function createAihubmix(options = {}) {
111
110
  const createChatModel = (deploymentName, settings = {}) => {
112
111
  const headers = getHeaders();
113
112
  if (deploymentName.startsWith("claude-")) {
114
- return new AnthropicMessagesLanguageModel(
115
- deploymentName,
116
- settings,
117
- {
118
- provider: "aihubmix.chat",
119
- baseURL: url({ path: "", modelId: deploymentName }),
120
- headers: {
121
- ...headers,
122
- "x-api-key": headers["Authorization"].split(" ")[1]
123
- },
124
- supportsImageUrls: true
125
- }
126
- );
113
+ return new AnthropicMessagesLanguageModel(deploymentName, {
114
+ provider: "aihubmix.chat",
115
+ baseURL: url({ path: "", modelId: deploymentName }),
116
+ headers: {
117
+ ...headers,
118
+ "x-api-key": headers["Authorization"].split(" ")[1]
119
+ },
120
+ supportedUrls: () => ({
121
+ "image/*": [/^https?:\/\/.*$/]
122
+ })
123
+ });
127
124
  }
128
125
  if ((deploymentName.startsWith("gemini") || deploymentName.startsWith("imagen")) && !deploymentName.endsWith("-nothink") && !deploymentName.endsWith("-search")) {
129
126
  return new GoogleGenerativeAILanguageModel(
130
127
  deploymentName,
131
- settings,
132
128
  {
133
129
  provider: "aihubmix.chat",
134
130
  baseURL: "https://aihubmix.com/gemini/v1beta",
@@ -137,27 +133,25 @@ function createAihubmix(options = {}) {
137
133
  "x-goog-api-key": headers["Authorization"].split(" ")[1]
138
134
  },
139
135
  generateId: () => `aihubmix-${Date.now()}`,
140
- isSupportedUrl: () => true
136
+ supportedUrls: () => ({})
141
137
  }
142
138
  );
143
139
  }
144
- return new OpenAIChatLanguageModel(deploymentName, settings, {
140
+ return new OpenAIChatLanguageModel(deploymentName, {
145
141
  provider: "aihubmix.chat",
146
142
  url,
147
143
  headers: getHeaders,
148
- compatibility,
149
144
  fetch: options.fetch
150
145
  });
151
146
  };
152
- const createCompletionModel = (modelId, settings = {}) => new OpenAICompletionLanguageModel(modelId, settings, {
147
+ const createCompletionModel = (modelId, settings = {}) => new OpenAICompletionLanguageModel(modelId, {
153
148
  provider: "aihubmix.completion",
154
149
  url,
155
- compatibility,
156
150
  headers: getHeaders,
157
151
  fetch: options.fetch
158
152
  });
159
153
  const createEmbeddingModel = (modelId, settings = {}) => {
160
- return new OpenAIEmbeddingModel(modelId, settings, {
154
+ return new OpenAIEmbeddingModel(modelId, {
161
155
  provider: "aihubmix.embeddings",
162
156
  headers: getHeaders,
163
157
  url,
@@ -170,7 +164,7 @@ function createAihubmix(options = {}) {
170
164
  headers: getHeaders
171
165
  });
172
166
  const createImageModel = (modelId, settings = {}) => {
173
- return new OpenAIImageModel(modelId, settings, {
167
+ return new OpenAIImageModel(modelId, {
174
168
  provider: "aihubmix.image",
175
169
  url,
176
170
  headers: getHeaders,
@@ -210,7 +204,7 @@ function createAihubmix(options = {}) {
210
204
  provider.transcriptionModel = createTranscriptionModel;
211
205
  provider.speech = createSpeechModel;
212
206
  provider.speechModel = createSpeechModel;
213
- provider.tools = openaiTools;
207
+ provider.tools = aihubmixTools;
214
208
  return provider;
215
209
  }
216
210
  var aihubmix = createAihubmix();
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/aihubmix-provider.ts","../src/aihubmix-tools.ts"],"sourcesContent":["import {\n OpenAIChatLanguageModel,\n OpenAIChatSettings,\n OpenAICompletionLanguageModel,\n OpenAICompletionSettings,\n OpenAIEmbeddingModel,\n OpenAIEmbeddingSettings,\n OpenAIImageModel,\n OpenAIImageSettings,\n OpenAIResponsesLanguageModel,\n OpenAITranscriptionModel,\n OpenAISpeechModel,\n} from '@ai-sdk/openai/internal';\nimport {\n AnthropicMessagesLanguageModel,\n AnthropicMessagesSettings,\n} from '@ai-sdk/anthropic/internal';\nimport {\n InternalGoogleGenerativeAISettings,\n GoogleGenerativeAILanguageModel,\n} from '@ai-sdk/google/internal';\nimport {\n EmbeddingModelV1,\n LanguageModelV1,\n ProviderV1,\n ImageModelV1,\n TranscriptionModelV1,\n SpeechModelV1,\n TranscriptionModelV1CallOptions,\n} from '@ai-sdk/provider';\nimport { FetchFunction, loadApiKey } from '@ai-sdk/provider-utils';\nimport { openaiTools } from './aihubmix-tools';\n\nexport interface AihubmixProvider extends ProviderV1 {\n (deploymentId: string, settings?: OpenAIChatSettings): LanguageModelV1;\n\n languageModel(\n deploymentId: string,\n settings?: OpenAIChatSettings,\n ): LanguageModelV1;\n\n chat(deploymentId: string, settings?: OpenAIChatSettings): LanguageModelV1;\n\n responses(deploymentId: string): LanguageModelV1;\n\n completion(\n deploymentId: string,\n settings?: OpenAICompletionSettings,\n ): LanguageModelV1;\n\n embedding(\n deploymentId: string,\n settings?: OpenAIEmbeddingSettings,\n ): EmbeddingModelV1<string>;\n\n image(deploymentId: string, settings?: OpenAIImageSettings): ImageModelV1;\n\n imageModel(\n deploymentId: string,\n settings?: OpenAIImageSettings,\n ): ImageModelV1;\n\n textEmbedding(\n deploymentId: string,\n settings?: OpenAIEmbeddingSettings,\n ): EmbeddingModelV1<string>;\n\n textEmbeddingModel(\n deploymentId: string,\n settings?: OpenAIEmbeddingSettings,\n ): EmbeddingModelV1<string>;\n\n transcription(deploymentId: string): TranscriptionModelV1;\n\n speech(deploymentId: string): SpeechModelV1;\n\n speechModel(deploymentId: string): SpeechModelV1;\n\n tools: typeof openaiTools;\n}\n\nclass AihubmixTranscriptionModel extends OpenAITranscriptionModel {\n async doGenerate(options: TranscriptionModelV1CallOptions) {\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 // 修改options,确保文件名有正确的扩展名\n const modifiedOptions = {\n ...options,\n mediaType: options.mediaType,\n };\n \n // 重写getArgs方法来设置正确的文件名\n const originalGetArgs = (this as any).getArgs;\n (this as any).getArgs = function(args: any) {\n const result = 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 // 在 Node.js 环境中,我们可能需要创建一个新的文件对象\n // 或者直接修改现有的对象\n try {\n const newFile = new (globalThis as any).File([fileEntry], `audio.${extension}`, { \n type: options.mediaType \n });\n result.formData.set('file', newFile);\n } catch (error) {\n // 如果 File 构造函数不可用,尝试修改现有对象的名称\n if (fileEntry && typeof fileEntry === 'object') {\n (fileEntry as any).name = `audio.${extension}`;\n }\n }\n }\n }\n return result;\n };\n \n return super.doGenerate(modifiedOptions);\n }\n }\n \n return super.doGenerate(options);\n }\n}\n\nexport interface AihubmixProviderSettings {\n apiKey?: string;\n fetch?: FetchFunction;\n compatibility?: 'strict' | 'compatible';\n}\n\nexport function createAihubmix(\n options: AihubmixProviderSettings = {},\n): AihubmixProvider {\n const compatibility = options.compatibility ?? 'compatible';\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: OpenAIChatSettings = {},\n ) => {\n const headers = getHeaders();\n if (deploymentName.startsWith('claude-')) {\n return new AnthropicMessagesLanguageModel(\n deploymentName,\n settings as AnthropicMessagesSettings,\n {\n provider: 'aihubmix.chat',\n baseURL: url({ path: '', modelId: deploymentName }),\n headers: {\n ...headers,\n 'x-api-key': headers['Authorization'].split(' ')[1],\n },\n supportsImageUrls: true,\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 settings as InternalGoogleGenerativeAISettings,\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 isSupportedUrl: () => true,\n },\n );\n }\n\n return new OpenAIChatLanguageModel(deploymentName, settings, {\n provider: 'aihubmix.chat',\n url,\n headers: getHeaders,\n compatibility,\n fetch: options.fetch,\n });\n };\n\n const createCompletionModel = (\n modelId: string,\n settings: OpenAICompletionSettings = {},\n ) =>\n new OpenAICompletionLanguageModel(modelId, settings, {\n provider: 'aihubmix.completion',\n url,\n compatibility,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createEmbeddingModel = (\n modelId: string,\n settings: OpenAIEmbeddingSettings = {},\n ) => {\n return new OpenAIEmbeddingModel(modelId, settings, {\n provider: 'aihubmix.embeddings',\n headers: getHeaders,\n url,\n fetch: options.fetch,\n });\n };\n\n const createResponsesModel = (modelId: string) =>\n new OpenAIResponsesLanguageModel(modelId, {\n provider: 'aihubmix.responses',\n url,\n headers: getHeaders,\n });\n\n const createImageModel = (\n modelId: string,\n settings: OpenAIImageSettings = {},\n ) => {\n return new OpenAIImageModel(modelId, settings, {\n provider: 'aihubmix.image',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n };\n\n const createTranscriptionModel = (modelId: string) =>\n new AihubmixTranscriptionModel(modelId, {\n provider: 'aihubmix.transcription',\n url,\n headers: getTranscriptionHeaders,\n fetch: options.fetch,\n });\n const createSpeechModel = (modelId: string) =>\n new OpenAISpeechModel(modelId, {\n provider: 'aihubmix.speech',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n const provider = function (\n deploymentId: string,\n settings?: OpenAIChatSettings | OpenAICompletionSettings,\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 as OpenAIChatSettings);\n };\n\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.completion = createCompletionModel;\n provider.responses = createResponsesModel;\n provider.embedding = createEmbeddingModel;\n provider.textEmbedding = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n\n provider.tools = openaiTools;\n\n return provider as AihubmixProvider;\n}\n\nexport const aihubmix = createAihubmix();\n","import { z } from 'zod';\n\nconst WebSearchPreviewParameters = z.object({});\n\nfunction webSearchPreviewTool({\n searchContextSize,\n userLocation,\n}: {\n searchContextSize?: 'low' | 'medium' | 'high';\n userLocation?: {\n type?: 'approximate';\n city?: string;\n region?: string;\n country?: string;\n timezone?: string;\n };\n} = {}): {\n type: 'provider-defined';\n id: 'openai.web_search_preview';\n args: {};\n parameters: typeof WebSearchPreviewParameters;\n} {\n return {\n type: 'provider-defined',\n id: 'openai.web_search_preview',\n args: {\n searchContextSize,\n userLocation,\n },\n parameters: WebSearchPreviewParameters,\n };\n}\n\nexport const openaiTools = {\n webSearchPreview: webSearchPreviewTool,\n};\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EAEE;AAAA,OACK;AAUP,SAAwB,kBAAkB;;;AC9B1C,SAAS,SAAS;AAElB,IAAM,6BAA6B,EAAE,OAAO,CAAC,CAAC;AAE9C,SAAS,qBAAqB;AAAA,EAC5B;AAAA,EACA;AACF,IASI,CAAC,GAKH;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,IAAI;AAAA,IACJ,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AACF;AAEO,IAAM,cAAc;AAAA,EACzB,kBAAkB;AACpB;;;AD8CA,IAAM,6BAAN,cAAyC,yBAAyB;AAAA,EAChE,MAAM,WAAW,SAA0C;AAEzD,QAAI,QAAQ,WAAW;AACrB,YAAM,cAAsC;AAAA,QAC1C,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QACb,cAAc;AAAA,QACd,aAAa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EtB,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAE9B,WAAS,SAAS;AAClB,WAAS,cAAc;AAEvB,WAAS,QAAQ;AAEjB,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":[]}
1
+ {"version":3,"sources":["../src/aihubmix-provider.ts","../src/aihubmix-tools.ts"],"sourcesContent":["import {\n OpenAIChatLanguageModel,\n OpenAICompletionLanguageModel,\n OpenAIEmbeddingModel,\n OpenAIImageModel,\n OpenAIResponsesLanguageModel,\n OpenAITranscriptionModel,\n OpenAISpeechModel,\n} from '@ai-sdk/openai/internal';\nimport { AnthropicMessagesLanguageModel } from '@ai-sdk/anthropic/internal';\nimport { GoogleGenerativeAILanguageModel } from '@ai-sdk/google/internal';\nimport {\n EmbeddingModelV2,\n LanguageModelV2,\n ProviderV2,\n ImageModelV2,\n TranscriptionModelV2,\n SpeechModelV2,\n TranscriptionModelV2CallOptions,\n} from '@ai-sdk/provider';\nimport { FetchFunction, loadApiKey } from '@ai-sdk/provider-utils';\nimport { aihubmixTools } from './aihubmix-tools';\n\n// 导入设置类型\nimport type { OpenAIProviderSettings } from '@ai-sdk/openai';\n\n\nexport interface AihubmixProvider extends ProviderV2 {\n (deploymentId: string, settings?: OpenAIProviderSettings): LanguageModelV2;\n\n languageModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV2;\n\n chat(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV2;\n\n responses(deploymentId: string): LanguageModelV2;\n\n completion(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): LanguageModelV2;\n\n embedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV2<string>;\n\n image(deploymentId: string, settings?: OpenAIProviderSettings): ImageModelV2;\n\n imageModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): ImageModelV2;\n\n textEmbedding(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV2<string>;\n\n textEmbeddingModel(\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ): EmbeddingModelV2<string>;\n\n transcription(deploymentId: string): TranscriptionModelV2;\n\n speech(deploymentId: string): SpeechModelV2;\n\n speechModel(deploymentId: string): SpeechModelV2;\n\n tools: typeof aihubmixTools;\n}\n\nexport interface AihubmixProviderSettings {\n apiKey?: string;\n fetch?: FetchFunction;\n compatibility?: 'strict' | 'compatible';\n}\n\nclass AihubmixTranscriptionModel extends OpenAITranscriptionModel {\n async doGenerate(options: TranscriptionModelV2CallOptions) {\n // 根据MIME类型设置正确的文件扩展名\n if (options.mediaType) {\n const mimeTypeMap: Record<string, string> = {\n 'audio/mpeg': 'mp3',\n 'audio/mp3': 'mp3',\n 'audio/wav': 'wav',\n 'audio/flac': 'flac',\n 'audio/m4a': 'm4a',\n 'audio/mp4': 'mp4',\n 'audio/ogg': 'ogg',\n 'audio/webm': 'webm',\n 'audio/oga': 'oga',\n 'audio/mpga': 'mpga',\n };\n \n const extension = mimeTypeMap[options.mediaType];\n if (extension) {\n // 重写getArgs方法来设置正确的文件名\n const originalGetArgs = (this as any).getArgs;\n (this as any).getArgs = async function(args: any) {\n const result = await originalGetArgs.call(this, args);\n if (result.formData) {\n // 找到file字段并修改文件名\n const fileEntry = result.formData.get('file');\n if (fileEntry && typeof fileEntry === 'object' && 'name' in fileEntry) {\n // 创建新的 File 对象,设置正确的文件名\n try {\n const newFile = new File([fileEntry], `audio.${extension}`, { \n type: options.mediaType \n });\n result.formData.set('file', newFile);\n } catch (error) {\n console.log('Failed to create new File object:', error);\n // 如果创建新 File 对象失败,尝试其他方法\n // 在 Node.js 环境中,可能需要使用 Buffer 或其他方式\n if (fileEntry && typeof fileEntry === 'object' && 'arrayBuffer' in fileEntry) {\n try {\n const arrayBuffer = await (fileEntry as any).arrayBuffer();\n const newFile = new File([arrayBuffer], `audio.${extension}`, { \n type: options.mediaType \n });\n result.formData.set('file', newFile);\n console.log('Created new file from arrayBuffer with name:', `audio.${extension}`);\n } catch (bufferError) {\n console.log('Failed to create file from arrayBuffer:', bufferError);\n }\n }\n }\n }\n }\n return result;\n };\n }\n }\n \n return super.doGenerate(options);\n }\n}\n\nexport function createAihubmix(\n options: AihubmixProviderSettings = {},\n): AihubmixProvider {\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': 'WHVL9885',\n 'Content-Type': 'application/json',\n });\n\n const getTranscriptionHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': 'WHVL9885',\n });\n\n const url = ({ path, modelId }: { path: string; modelId: string }) => {\n const baseURL = 'https://aihubmix.com/v1';\n return `${baseURL}${path}`;\n };\n\n const createChatModel = (\n deploymentName: string,\n settings: OpenAIProviderSettings = {},\n ) => {\n const headers = getHeaders();\n if (deploymentName.startsWith('claude-')) {\n return new AnthropicMessagesLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n baseURL: url({ path: '', modelId: deploymentName }),\n headers: {\n ...headers,\n 'x-api-key': headers['Authorization'].split(' ')[1],\n },\n supportedUrls: () => ({\n 'image/*': [/^https?:\\/\\/.*$/],\n }),\n });\n }\n if (\n (deploymentName.startsWith('gemini') ||\n deploymentName.startsWith('imagen')) &&\n !deploymentName.endsWith('-nothink') &&\n !deploymentName.endsWith('-search')\n ) {\n return new GoogleGenerativeAILanguageModel(\n deploymentName,\n {\n provider: 'aihubmix.chat',\n baseURL: 'https://aihubmix.com/gemini/v1beta',\n headers: {\n ...headers,\n 'x-goog-api-key': headers['Authorization'].split(' ')[1],\n },\n generateId: () => `aihubmix-${Date.now()}`,\n supportedUrls: () => ({}),\n },\n );\n }\n\n return new OpenAIChatLanguageModel(deploymentName, {\n provider: 'aihubmix.chat',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n };\n\n const createCompletionModel = (\n modelId: string,\n settings: any = {},\n ) =>\n new OpenAICompletionLanguageModel(modelId, {\n provider: 'aihubmix.completion',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createEmbeddingModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAIEmbeddingModel(modelId, {\n provider: 'aihubmix.embeddings',\n headers: getHeaders,\n url,\n fetch: options.fetch,\n });\n };\n\n const createResponsesModel = (modelId: string) =>\n new OpenAIResponsesLanguageModel(modelId, {\n provider: 'aihubmix.responses',\n url,\n headers: getHeaders,\n });\n\n const createImageModel = (\n modelId: string,\n settings: any = {},\n ) => {\n return new OpenAIImageModel(modelId, {\n provider: 'aihubmix.image',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n };\n\n const createTranscriptionModel = (modelId: string) =>\n new AihubmixTranscriptionModel(modelId, {\n provider: 'aihubmix.transcription',\n url,\n headers: getTranscriptionHeaders,\n fetch: options.fetch,\n });\n const createSpeechModel = (modelId: string) =>\n new OpenAISpeechModel(modelId, {\n provider: 'aihubmix.speech',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n const provider = function (\n deploymentId: string,\n settings?: OpenAIProviderSettings,\n ) {\n if (new.target) {\n throw new Error(\n 'The Aihubmix model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(deploymentId, settings);\n };\n\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.completion = createCompletionModel;\n provider.responses = createResponsesModel;\n provider.embedding = createEmbeddingModel;\n provider.textEmbedding = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n\n provider.tools = aihubmixTools;\n\n return provider as AihubmixProvider;\n}\n\nexport const aihubmix = createAihubmix();\n","import { z } from 'zod';\n\nconst WebSearchPreviewParameters = z.object({});\n\nfunction webSearchPreviewTool({\n searchContextSize,\n userLocation,\n}: {\n searchContextSize?: 'low' | 'medium' | 'high';\n userLocation?: {\n type?: 'approximate';\n city?: string;\n region?: string;\n country?: string;\n timezone?: string;\n };\n} = {}): {\n type: 'function';\n function: {\n name: string;\n description: string;\n parameters: typeof WebSearchPreviewParameters;\n };\n} {\n return {\n type: 'function',\n function: {\n name: 'aihubmix.web_search_preview',\n description: 'Search the web for current information and preview results',\n parameters: WebSearchPreviewParameters,\n },\n };\n}\n\nexport const aihubmixTools = {\n webSearchPreview: webSearchPreviewTool,\n};\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sCAAsC;AAC/C,SAAS,uCAAuC;AAUhD,SAAwB,kBAAkB;;;ACpB1C,SAAS,SAAS;AAElB,IAAM,6BAA6B,EAAE,OAAO,CAAC,CAAC;AAE9C,SAAS,qBAAqB;AAAA,EAC5B;AAAA,EACA;AACF,IASI,CAAC,GAOH;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,IACd;AAAA,EACF;AACF;AAEO,IAAM,gBAAgB;AAAA,EAC3B,kBAAkB;AACpB;;;ADgDA,IAAM,6BAAN,cAAyC,yBAAyB;AAAA,EAChE,MAAM,WAAW,SAA0C;AAEzD,QAAI,QAAQ,WAAW;AACrB,YAAM,cAAsC;AAAA,QAC1C,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QACb,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QACb,aAAa;AAAA,QACb,cAAc;AAAA,QACd,aAAa;AAAA,QACb,cAAc;AAAA,MAChB;AAEA,YAAM,YAAY,YAAY,QAAQ,SAAS;AAC/C,UAAI,WAAW;AAEb,cAAM,kBA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B;AACzB,WAAS,qBAAqB;AAE9B,WAAS,SAAS;AAClB,WAAS,cAAc;AAEvB,WAAS,QAAQ;AAEjB,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aihubmix/ai-sdk-provider",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -10,6 +10,18 @@
10
10
  "dist/**/*",
11
11
  "CHANGELOG.md"
12
12
  ],
13
+ "scripts": {
14
+ "build": "tsup",
15
+ "build:watch": "tsup --watch",
16
+ "clean": "rm -rf dist",
17
+ "lint": "eslint \"./**/*.ts*\"",
18
+ "type-check": "tsc --noEmit",
19
+ "prettier-check": "prettier --check \"./**/*.ts*\" --write",
20
+ "test": "pnpm test:node && pnpm test:edge",
21
+ "test:edge": "vitest --config vitest.edge.config.js --run",
22
+ "test:node": "vitest --config vitest.node.config.js --run",
23
+ "test:node:watch": "vitest --config vitest.node.config.js"
24
+ },
13
25
  "exports": {
14
26
  "./package.json": "./package.json",
15
27
  ".": {
@@ -19,11 +31,11 @@
19
31
  }
20
32
  },
21
33
  "dependencies": {
22
- "@ai-sdk/anthropic": "1.2.12",
23
- "@ai-sdk/google": "1.2.19",
24
- "@ai-sdk/openai": "1.3.22",
25
- "@ai-sdk/provider": "1.1.3",
26
- "@ai-sdk/provider-utils": "2.2.8"
34
+ "@ai-sdk/anthropic": "2.0.17",
35
+ "@ai-sdk/google": "2.0.15",
36
+ "@ai-sdk/openai": "2.0.32",
37
+ "@ai-sdk/provider": "2.0.0",
38
+ "@ai-sdk/provider-utils": "3.0.9"
27
39
  },
28
40
  "devDependencies": {
29
41
  "@types/node": "20.17.24",
@@ -56,17 +68,5 @@
56
68
  "aihubmix",
57
69
  "ai-sdk-provider",
58
70
  "ai-sdk"
59
- ],
60
- "scripts": {
61
- "build": "tsup",
62
- "build:watch": "tsup --watch",
63
- "clean": "rm -rf dist",
64
- "lint": "eslint \"./**/*.ts*\"",
65
- "type-check": "tsc --noEmit",
66
- "prettier-check": "prettier --check \"./**/*.ts*\" --write",
67
- "test": "pnpm test:node && pnpm test:edge",
68
- "test:edge": "vitest --config vitest.edge.config.js --run",
69
- "test:node": "vitest --config vitest.node.config.js --run",
70
- "test:node:watch": "vitest --config vitest.node.config.js"
71
- }
72
- }
71
+ ]
72
+ }
package/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.