@ai-sdk/vercel 1.0.18 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +18 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -36,4 +36,6 @@ interface VercelProvider extends ProviderV2 {
|
|
|
36
36
|
declare function createVercel(options?: VercelProviderSettings): VercelProvider;
|
|
37
37
|
declare const vercel: VercelProvider;
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
declare const VERSION: string;
|
|
40
|
+
|
|
41
|
+
export { VERSION, type VercelProvider, type VercelProviderSettings, createVercel, vercel };
|
package/dist/index.d.ts
CHANGED
|
@@ -36,4 +36,6 @@ interface VercelProvider extends ProviderV2 {
|
|
|
36
36
|
declare function createVercel(options?: VercelProviderSettings): VercelProvider;
|
|
37
37
|
declare const vercel: VercelProvider;
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
declare const VERSION: string;
|
|
40
|
+
|
|
41
|
+
export { VERSION, type VercelProvider, type VercelProviderSettings, createVercel, vercel };
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
+
VERSION: () => VERSION,
|
|
23
24
|
createVercel: () => createVercel,
|
|
24
25
|
vercel: () => vercel
|
|
25
26
|
});
|
|
@@ -29,19 +30,27 @@ module.exports = __toCommonJS(src_exports);
|
|
|
29
30
|
var import_provider = require("@ai-sdk/provider");
|
|
30
31
|
var import_openai_compatible = require("@ai-sdk/openai-compatible");
|
|
31
32
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
33
|
+
|
|
34
|
+
// src/version.ts
|
|
35
|
+
var VERSION = true ? "1.0.19" : "0.0.0-test";
|
|
36
|
+
|
|
37
|
+
// src/vercel-provider.ts
|
|
32
38
|
function createVercel(options = {}) {
|
|
33
39
|
var _a;
|
|
34
40
|
const baseURL = (0, import_provider_utils.withoutTrailingSlash)(
|
|
35
41
|
(_a = options.baseURL) != null ? _a : "https://api.v0.dev/v1"
|
|
36
42
|
);
|
|
37
|
-
const getHeaders = () => (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const getHeaders = () => (0, import_provider_utils.withUserAgentSuffix)(
|
|
44
|
+
{
|
|
45
|
+
Authorization: `Bearer ${(0, import_provider_utils.loadApiKey)({
|
|
46
|
+
apiKey: options.apiKey,
|
|
47
|
+
environmentVariableName: "VERCEL_API_KEY",
|
|
48
|
+
description: "Vercel"
|
|
49
|
+
})}`,
|
|
50
|
+
...options.headers
|
|
51
|
+
},
|
|
52
|
+
`ai-sdk/vercel/${VERSION}`
|
|
53
|
+
);
|
|
45
54
|
const getCommonModelConfig = (modelType) => ({
|
|
46
55
|
provider: `vercel.${modelType}`,
|
|
47
56
|
url: ({ path }) => `${baseURL}${path}`,
|
|
@@ -66,6 +75,7 @@ function createVercel(options = {}) {
|
|
|
66
75
|
var vercel = createVercel();
|
|
67
76
|
// Annotate the CommonJS export names for ESM import in node:
|
|
68
77
|
0 && (module.exports = {
|
|
78
|
+
VERSION,
|
|
69
79
|
createVercel,
|
|
70
80
|
vercel
|
|
71
81
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/vercel-provider.ts"],"sourcesContent":["export { createVercel, vercel } from './vercel-provider';\nexport type { VercelProvider, VercelProviderSettings } from './vercel-provider';\nexport type { OpenAICompatibleErrorData as VercelErrorData } from '@ai-sdk/openai-compatible';\n","import {\n LanguageModelV2,\n NoSuchModelError,\n ProviderV2,\n} from '@ai-sdk/provider';\nimport { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n} from '@ai-sdk/provider-utils';\nimport { VercelChatModelId } from './vercel-chat-options';\n\nexport interface VercelProviderSettings {\n /**\nVercel API key.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface VercelProvider extends ProviderV2 {\n /**\nCreates a model for text generation.\n*/\n (modelId: VercelChatModelId): LanguageModelV2;\n\n /**\nCreates a language model for text generation.\n*/\n languageModel(modelId: VercelChatModelId): LanguageModelV2;\n}\n\nexport function createVercel(\n options: VercelProviderSettings = {},\n): VercelProvider {\n const baseURL = withoutTrailingSlash(\n options.baseURL ?? 'https://api.v0.dev/v1',\n );\n const getHeaders = ()
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/vercel-provider.ts","../src/version.ts"],"sourcesContent":["export { createVercel, vercel } from './vercel-provider';\nexport type { VercelProvider, VercelProviderSettings } from './vercel-provider';\nexport type { OpenAICompatibleErrorData as VercelErrorData } from '@ai-sdk/openai-compatible';\nexport { VERSION } from './version';\n","import {\n LanguageModelV2,\n NoSuchModelError,\n ProviderV2,\n} from '@ai-sdk/provider';\nimport { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport { VercelChatModelId } from './vercel-chat-options';\nimport { VERSION } from './version';\n\nexport interface VercelProviderSettings {\n /**\nVercel API key.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface VercelProvider extends ProviderV2 {\n /**\nCreates a model for text generation.\n*/\n (modelId: VercelChatModelId): LanguageModelV2;\n\n /**\nCreates a language model for text generation.\n*/\n languageModel(modelId: VercelChatModelId): LanguageModelV2;\n}\n\nexport function createVercel(\n options: VercelProviderSettings = {},\n): VercelProvider {\n const baseURL = withoutTrailingSlash(\n options.baseURL ?? 'https://api.v0.dev/v1',\n );\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'VERCEL_API_KEY',\n description: 'Vercel',\n })}`,\n ...options.headers,\n },\n `ai-sdk/vercel/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (modelType: string): CommonModelConfig => ({\n provider: `vercel.${modelType}`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId: VercelChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(modelId, {\n ...getCommonModelConfig('chat'),\n });\n };\n\n const provider = (modelId: VercelChatModelId) => createChatModel(modelId);\n\n provider.languageModel = createChatModel;\n provider.textEmbeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'textEmbeddingModel' });\n };\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\nexport const vercel = createVercel();\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAIO;AACP,+BAAkD;AAClD,4BAKO;;;ACTA,IAAM,UACX,OACI,WACA;;;AD0CC,SAAS,aACd,UAAkC,CAAC,GACnB;AAjDlB;AAkDE,QAAM,cAAU;AAAA,KACd,aAAQ,YAAR,YAAmB;AAAA,EACrB;AACA,QAAM,aAAa,UACjB;AAAA,IACE;AAAA,MACE,eAAe,cAAU,kCAAW;AAAA,QAClC,QAAQ,QAAQ;AAAA,QAChB,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC,CAAC;AAAA,MACF,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,iBAAiB,OAAO;AAAA,EAC1B;AASF,QAAM,uBAAuB,CAAC,eAA0C;AAAA,IACtE,UAAU,UAAU,SAAS;AAAA,IAC7B,KAAK,CAAC,EAAE,KAAK,MAAM,GAAG,OAAO,GAAG,IAAI;AAAA,IACpC,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB;AAEA,QAAM,kBAAkB,CAAC,YAA+B;AACtD,WAAO,IAAI,2DAAkC,SAAS;AAAA,MACpD,GAAG,qBAAqB,MAAM;AAAA,IAChC,CAAC;AAAA,EACH;AAEA,QAAM,WAAW,CAAC,YAA+B,gBAAgB,OAAO;AAExE,WAAS,gBAAgB;AACzB,WAAS,qBAAqB,CAAC,YAAoB;AACjD,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,qBAAqB,CAAC;AAAA,EACzE;AACA,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;AAEO,IAAM,SAAS,aAAa;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -5,21 +5,30 @@ import {
|
|
|
5
5
|
import { OpenAICompatibleChatLanguageModel } from "@ai-sdk/openai-compatible";
|
|
6
6
|
import {
|
|
7
7
|
loadApiKey,
|
|
8
|
-
withoutTrailingSlash
|
|
8
|
+
withoutTrailingSlash,
|
|
9
|
+
withUserAgentSuffix
|
|
9
10
|
} from "@ai-sdk/provider-utils";
|
|
11
|
+
|
|
12
|
+
// src/version.ts
|
|
13
|
+
var VERSION = true ? "1.0.19" : "0.0.0-test";
|
|
14
|
+
|
|
15
|
+
// src/vercel-provider.ts
|
|
10
16
|
function createVercel(options = {}) {
|
|
11
17
|
var _a;
|
|
12
18
|
const baseURL = withoutTrailingSlash(
|
|
13
19
|
(_a = options.baseURL) != null ? _a : "https://api.v0.dev/v1"
|
|
14
20
|
);
|
|
15
|
-
const getHeaders = () => (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
22
|
+
{
|
|
23
|
+
Authorization: `Bearer ${loadApiKey({
|
|
24
|
+
apiKey: options.apiKey,
|
|
25
|
+
environmentVariableName: "VERCEL_API_KEY",
|
|
26
|
+
description: "Vercel"
|
|
27
|
+
})}`,
|
|
28
|
+
...options.headers
|
|
29
|
+
},
|
|
30
|
+
`ai-sdk/vercel/${VERSION}`
|
|
31
|
+
);
|
|
23
32
|
const getCommonModelConfig = (modelType) => ({
|
|
24
33
|
provider: `vercel.${modelType}`,
|
|
25
34
|
url: ({ path }) => `${baseURL}${path}`,
|
|
@@ -43,6 +52,7 @@ function createVercel(options = {}) {
|
|
|
43
52
|
}
|
|
44
53
|
var vercel = createVercel();
|
|
45
54
|
export {
|
|
55
|
+
VERSION,
|
|
46
56
|
createVercel,
|
|
47
57
|
vercel
|
|
48
58
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vercel-provider.ts"],"sourcesContent":["import {\n LanguageModelV2,\n NoSuchModelError,\n ProviderV2,\n} from '@ai-sdk/provider';\nimport { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n} from '@ai-sdk/provider-utils';\nimport { VercelChatModelId } from './vercel-chat-options';\n\nexport interface VercelProviderSettings {\n /**\nVercel API key.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface VercelProvider extends ProviderV2 {\n /**\nCreates a model for text generation.\n*/\n (modelId: VercelChatModelId): LanguageModelV2;\n\n /**\nCreates a language model for text generation.\n*/\n languageModel(modelId: VercelChatModelId): LanguageModelV2;\n}\n\nexport function createVercel(\n options: VercelProviderSettings = {},\n): VercelProvider {\n const baseURL = withoutTrailingSlash(\n options.baseURL ?? 'https://api.v0.dev/v1',\n );\n const getHeaders = ()
|
|
1
|
+
{"version":3,"sources":["../src/vercel-provider.ts","../src/version.ts"],"sourcesContent":["import {\n LanguageModelV2,\n NoSuchModelError,\n ProviderV2,\n} from '@ai-sdk/provider';\nimport { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport { VercelChatModelId } from './vercel-chat-options';\nimport { VERSION } from './version';\n\nexport interface VercelProviderSettings {\n /**\nVercel API key.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface VercelProvider extends ProviderV2 {\n /**\nCreates a model for text generation.\n*/\n (modelId: VercelChatModelId): LanguageModelV2;\n\n /**\nCreates a language model for text generation.\n*/\n languageModel(modelId: VercelChatModelId): LanguageModelV2;\n}\n\nexport function createVercel(\n options: VercelProviderSettings = {},\n): VercelProvider {\n const baseURL = withoutTrailingSlash(\n options.baseURL ?? 'https://api.v0.dev/v1',\n );\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'VERCEL_API_KEY',\n description: 'Vercel',\n })}`,\n ...options.headers,\n },\n `ai-sdk/vercel/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (modelType: string): CommonModelConfig => ({\n provider: `vercel.${modelType}`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId: VercelChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(modelId, {\n ...getCommonModelConfig('chat'),\n });\n };\n\n const provider = (modelId: VercelChatModelId) => createChatModel(modelId);\n\n provider.languageModel = createChatModel;\n provider.textEmbeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'textEmbeddingModel' });\n };\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\nexport const vercel = createVercel();\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";AAAA;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,yCAAyC;AAClD;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACTA,IAAM,UACX,OACI,WACA;;;AD0CC,SAAS,aACd,UAAkC,CAAC,GACnB;AAjDlB;AAkDE,QAAM,UAAU;AAAA,KACd,aAAQ,YAAR,YAAmB;AAAA,EACrB;AACA,QAAM,aAAa,MACjB;AAAA,IACE;AAAA,MACE,eAAe,UAAU,WAAW;AAAA,QAClC,QAAQ,QAAQ;AAAA,QAChB,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC,CAAC;AAAA,MACF,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,iBAAiB,OAAO;AAAA,EAC1B;AASF,QAAM,uBAAuB,CAAC,eAA0C;AAAA,IACtE,UAAU,UAAU,SAAS;AAAA,IAC7B,KAAK,CAAC,EAAE,KAAK,MAAM,GAAG,OAAO,GAAG,IAAI;AAAA,IACpC,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB;AAEA,QAAM,kBAAkB,CAAC,YAA+B;AACtD,WAAO,IAAI,kCAAkC,SAAS;AAAA,MACpD,GAAG,qBAAqB,MAAM;AAAA,IAChC,CAAC;AAAA,EACH;AAEA,QAAM,WAAW,CAAC,YAA+B,gBAAgB,OAAO;AAExE,WAAS,gBAAgB;AACzB,WAAS,qBAAqB,CAAC,YAAoB;AACjD,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,qBAAqB,CAAC;AAAA,EACzE;AACA,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;AAEO,IAAM,SAAS,aAAa;","names":[]}
|