@ai-sdk/openai 0.0.0 → 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md CHANGED
@@ -19,7 +19,7 @@ You can import `OpenAI` from `ai/openai` and initialize a provider instance with
19
19
  import { OpenAI } from '@ai-sdk/openai'
20
20
 
21
21
  const openai = new OpenAI({
22
- baseUrl: '', // optional base URL for proxies etc.
22
+ baseURL: '', // optional base URL for proxies etc.
23
23
  apiKey: '' // optional API key, default to env property OPENAI_API_KEY
24
24
  organization: '' // optional organization
25
25
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/openai",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -9,17 +9,6 @@
9
9
  "files": [
10
10
  "dist/**/*"
11
11
  ],
12
- "scripts": {
13
- "build": "tsup",
14
- "clean": "rm -rf dist",
15
- "dev": "tsup --watch",
16
- "lint": "eslint \"./**/*.ts*\"",
17
- "type-check": "tsc --noEmit",
18
- "prettier-check": "prettier --check \"./**/*.ts*\"",
19
- "test": "pnpm test:node && pnpm test:edge",
20
- "test:edge": "vitest --config vitest.edge.config.js --run --threads=false",
21
- "test:node": "vitest --config vitest.node.config.js --run --threads=false"
22
- },
23
12
  "exports": {
24
13
  "./package.json": "./package.json",
25
14
  ".": {
@@ -30,14 +19,14 @@
30
19
  },
31
20
  "dependencies": {
32
21
  "@ai-sdk/provider": "0.0.0",
33
- "@ai-sdk/provider-utils": "0.0.0"
22
+ "@ai-sdk/provider-utils": "0.0.1"
34
23
  },
35
24
  "devDependencies": {
36
25
  "@types/node": "^18",
37
- "@vercel/ai-tsconfig": "workspace:*",
38
26
  "tsup": "^8",
39
27
  "typescript": "5.1.3",
40
- "zod": "3.22.4"
28
+ "zod": "3.22.4",
29
+ "@vercel/ai-tsconfig": "0.0.0"
41
30
  },
42
31
  "peerDependencies": {
43
32
  "zod": "^3.0.0"
@@ -63,5 +52,16 @@
63
52
  },
64
53
  "keywords": [
65
54
  "ai"
66
- ]
67
- }
55
+ ],
56
+ "scripts": {
57
+ "build": "tsup",
58
+ "clean": "rm -rf dist",
59
+ "dev": "tsup --watch",
60
+ "lint": "eslint \"./**/*.ts*\"",
61
+ "type-check": "tsc --noEmit",
62
+ "prettier-check": "prettier --check \"./**/*.ts*\"",
63
+ "test": "pnpm test:node && pnpm test:edge",
64
+ "test:edge": "vitest --config vitest.edge.config.js --run --threads=false",
65
+ "test:node": "vitest --config vitest.node.config.js --run --threads=false"
66
+ }
67
+ }
package/dist/index.d.mts DELETED
@@ -1,116 +0,0 @@
1
- import { LanguageModelV1 } from '@ai-sdk/provider';
2
-
3
- type OpenAIChatModelId = 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4-vision-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4-32k' | 'gpt-4-32k-0613' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | 'gpt-3.5-turbo-0613' | 'gpt-3.5-turbo-16k-0613' | (string & {});
4
- interface OpenAIChatSettings {
5
- /**
6
- * Modify the likelihood of specified tokens appearing in the completion.
7
- *
8
- * Accepts a JSON object that maps tokens (specified by their token ID in
9
- * the GPT tokenizer) to an associated bias value from -100 to 100. You
10
- * can use this tokenizer tool to convert text to token IDs. Mathematically,
11
- * the bias is added to the logits generated by the model prior to sampling.
12
- * The exact effect will vary per model, but values between -1 and 1 should
13
- * decrease or increase likelihood of selection; values like -100 or 100
14
- * should result in a ban or exclusive selection of the relevant token.
15
- *
16
- * As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
17
- * token from being generated.
18
- */
19
- logitBias?: Record<number, number>;
20
- /**
21
- * A unique identifier representing your end-user, which can help OpenAI to
22
- * monitor and detect abuse. Learn more.
23
- */
24
- user?: string;
25
- }
26
-
27
- type OpenAIChatConfig = {
28
- provider: string;
29
- baseUrl: string;
30
- headers: () => Record<string, string | undefined>;
31
- };
32
- declare class OpenAIChatLanguageModel implements LanguageModelV1 {
33
- readonly specificationVersion = "v1";
34
- readonly defaultObjectGenerationMode = "tool";
35
- readonly modelId: OpenAIChatModelId;
36
- readonly settings: OpenAIChatSettings;
37
- private readonly config;
38
- constructor(modelId: OpenAIChatModelId, settings: OpenAIChatSettings, config: OpenAIChatConfig);
39
- get provider(): string;
40
- private getArgs;
41
- doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>;
42
- doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
43
- }
44
-
45
- type OpenAICompletionModelId = 'gpt-3.5-turbo-instruct' | (string & {});
46
- interface OpenAICompletionSettings {
47
- /**
48
- * Echo back the prompt in addition to the completion
49
- */
50
- echo?: boolean;
51
- /**
52
- * Modify the likelihood of specified tokens appearing in the completion.
53
- *
54
- * Accepts a JSON object that maps tokens (specified by their token ID in
55
- * the GPT tokenizer) to an associated bias value from -100 to 100. You
56
- * can use this tokenizer tool to convert text to token IDs. Mathematically,
57
- * the bias is added to the logits generated by the model prior to sampling.
58
- * The exact effect will vary per model, but values between -1 and 1 should
59
- * decrease or increase likelihood of selection; values like -100 or 100
60
- * should result in a ban or exclusive selection of the relevant token.
61
- *
62
- * As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
63
- * token from being generated.
64
- */
65
- logitBias?: Record<number, number>;
66
- /**
67
- * The suffix that comes after a completion of inserted text.
68
- */
69
- suffix?: string;
70
- /**
71
- * A unique identifier representing your end-user, which can help OpenAI to
72
- * monitor and detect abuse. Learn more.
73
- */
74
- user?: string;
75
- }
76
-
77
- type OpenAICompletionConfig = {
78
- provider: string;
79
- baseUrl: string;
80
- headers: () => Record<string, string | undefined>;
81
- };
82
- declare class OpenAICompletionLanguageModel implements LanguageModelV1 {
83
- readonly specificationVersion = "v1";
84
- readonly defaultObjectGenerationMode: undefined;
85
- readonly modelId: OpenAICompletionModelId;
86
- readonly settings: OpenAICompletionSettings;
87
- private readonly config;
88
- constructor(modelId: OpenAICompletionModelId, settings: OpenAICompletionSettings, config: OpenAICompletionConfig);
89
- get provider(): string;
90
- private getArgs;
91
- doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>;
92
- doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
93
- }
94
-
95
- /**
96
- * OpenAI provider.
97
- */
98
- declare class OpenAI {
99
- readonly baseUrl?: string;
100
- readonly apiKey?: string;
101
- readonly organization?: string;
102
- constructor(options?: {
103
- baseUrl?: string;
104
- apiKey?: string;
105
- organization?: string;
106
- });
107
- private get baseConfig();
108
- chat(modelId: OpenAIChatModelId, settings?: OpenAIChatSettings): OpenAIChatLanguageModel;
109
- completion(modelId: OpenAICompletionModelId, settings?: OpenAICompletionSettings): OpenAICompletionLanguageModel;
110
- }
111
- /**
112
- * Default OpenAI provider instance.
113
- */
114
- declare const openai: OpenAI;
115
-
116
- export { OpenAI, openai };
package/dist/index.d.ts DELETED
@@ -1,116 +0,0 @@
1
- import { LanguageModelV1 } from '@ai-sdk/provider';
2
-
3
- type OpenAIChatModelId = 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4-vision-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4-32k' | 'gpt-4-32k-0613' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | 'gpt-3.5-turbo-0613' | 'gpt-3.5-turbo-16k-0613' | (string & {});
4
- interface OpenAIChatSettings {
5
- /**
6
- * Modify the likelihood of specified tokens appearing in the completion.
7
- *
8
- * Accepts a JSON object that maps tokens (specified by their token ID in
9
- * the GPT tokenizer) to an associated bias value from -100 to 100. You
10
- * can use this tokenizer tool to convert text to token IDs. Mathematically,
11
- * the bias is added to the logits generated by the model prior to sampling.
12
- * The exact effect will vary per model, but values between -1 and 1 should
13
- * decrease or increase likelihood of selection; values like -100 or 100
14
- * should result in a ban or exclusive selection of the relevant token.
15
- *
16
- * As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
17
- * token from being generated.
18
- */
19
- logitBias?: Record<number, number>;
20
- /**
21
- * A unique identifier representing your end-user, which can help OpenAI to
22
- * monitor and detect abuse. Learn more.
23
- */
24
- user?: string;
25
- }
26
-
27
- type OpenAIChatConfig = {
28
- provider: string;
29
- baseUrl: string;
30
- headers: () => Record<string, string | undefined>;
31
- };
32
- declare class OpenAIChatLanguageModel implements LanguageModelV1 {
33
- readonly specificationVersion = "v1";
34
- readonly defaultObjectGenerationMode = "tool";
35
- readonly modelId: OpenAIChatModelId;
36
- readonly settings: OpenAIChatSettings;
37
- private readonly config;
38
- constructor(modelId: OpenAIChatModelId, settings: OpenAIChatSettings, config: OpenAIChatConfig);
39
- get provider(): string;
40
- private getArgs;
41
- doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>;
42
- doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
43
- }
44
-
45
- type OpenAICompletionModelId = 'gpt-3.5-turbo-instruct' | (string & {});
46
- interface OpenAICompletionSettings {
47
- /**
48
- * Echo back the prompt in addition to the completion
49
- */
50
- echo?: boolean;
51
- /**
52
- * Modify the likelihood of specified tokens appearing in the completion.
53
- *
54
- * Accepts a JSON object that maps tokens (specified by their token ID in
55
- * the GPT tokenizer) to an associated bias value from -100 to 100. You
56
- * can use this tokenizer tool to convert text to token IDs. Mathematically,
57
- * the bias is added to the logits generated by the model prior to sampling.
58
- * The exact effect will vary per model, but values between -1 and 1 should
59
- * decrease or increase likelihood of selection; values like -100 or 100
60
- * should result in a ban or exclusive selection of the relevant token.
61
- *
62
- * As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
63
- * token from being generated.
64
- */
65
- logitBias?: Record<number, number>;
66
- /**
67
- * The suffix that comes after a completion of inserted text.
68
- */
69
- suffix?: string;
70
- /**
71
- * A unique identifier representing your end-user, which can help OpenAI to
72
- * monitor and detect abuse. Learn more.
73
- */
74
- user?: string;
75
- }
76
-
77
- type OpenAICompletionConfig = {
78
- provider: string;
79
- baseUrl: string;
80
- headers: () => Record<string, string | undefined>;
81
- };
82
- declare class OpenAICompletionLanguageModel implements LanguageModelV1 {
83
- readonly specificationVersion = "v1";
84
- readonly defaultObjectGenerationMode: undefined;
85
- readonly modelId: OpenAICompletionModelId;
86
- readonly settings: OpenAICompletionSettings;
87
- private readonly config;
88
- constructor(modelId: OpenAICompletionModelId, settings: OpenAICompletionSettings, config: OpenAICompletionConfig);
89
- get provider(): string;
90
- private getArgs;
91
- doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>;
92
- doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
93
- }
94
-
95
- /**
96
- * OpenAI provider.
97
- */
98
- declare class OpenAI {
99
- readonly baseUrl?: string;
100
- readonly apiKey?: string;
101
- readonly organization?: string;
102
- constructor(options?: {
103
- baseUrl?: string;
104
- apiKey?: string;
105
- organization?: string;
106
- });
107
- private get baseConfig();
108
- chat(modelId: OpenAIChatModelId, settings?: OpenAIChatSettings): OpenAIChatLanguageModel;
109
- completion(modelId: OpenAICompletionModelId, settings?: OpenAICompletionSettings): OpenAICompletionLanguageModel;
110
- }
111
- /**
112
- * Default OpenAI provider instance.
113
- */
114
- declare const openai: OpenAI;
115
-
116
- export { OpenAI, openai };