@ai-sdk/openai 0.0.1 → 0.0.2
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.d.mts +135 -0
- package/dist/index.d.ts +135 -0
- package/dist/index.js +801 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +793 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +1 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
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
|
+
/**
|
|
100
|
+
* Base URL for the OpenAI API calls.
|
|
101
|
+
*/
|
|
102
|
+
readonly baseURL: string;
|
|
103
|
+
readonly apiKey?: string;
|
|
104
|
+
readonly organization?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Creates a new OpenAI provider instance.
|
|
107
|
+
*/
|
|
108
|
+
constructor(options?: {
|
|
109
|
+
/**
|
|
110
|
+
* Base URL for the OpenAI API calls.
|
|
111
|
+
*/
|
|
112
|
+
baseURL?: string;
|
|
113
|
+
/**
|
|
114
|
+
* @deprecated Use `baseURL` instead.
|
|
115
|
+
*/
|
|
116
|
+
baseUrl?: string;
|
|
117
|
+
/**
|
|
118
|
+
* API key for authenticating requests.
|
|
119
|
+
*/
|
|
120
|
+
apiKey?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Organization ID.
|
|
123
|
+
*/
|
|
124
|
+
organization?: string;
|
|
125
|
+
});
|
|
126
|
+
private get baseConfig();
|
|
127
|
+
chat(modelId: OpenAIChatModelId, settings?: OpenAIChatSettings): OpenAIChatLanguageModel;
|
|
128
|
+
completion(modelId: OpenAICompletionModelId, settings?: OpenAICompletionSettings): OpenAICompletionLanguageModel;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Default OpenAI provider instance.
|
|
132
|
+
*/
|
|
133
|
+
declare const openai: OpenAI;
|
|
134
|
+
|
|
135
|
+
export { OpenAI, openai };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
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
|
+
/**
|
|
100
|
+
* Base URL for the OpenAI API calls.
|
|
101
|
+
*/
|
|
102
|
+
readonly baseURL: string;
|
|
103
|
+
readonly apiKey?: string;
|
|
104
|
+
readonly organization?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Creates a new OpenAI provider instance.
|
|
107
|
+
*/
|
|
108
|
+
constructor(options?: {
|
|
109
|
+
/**
|
|
110
|
+
* Base URL for the OpenAI API calls.
|
|
111
|
+
*/
|
|
112
|
+
baseURL?: string;
|
|
113
|
+
/**
|
|
114
|
+
* @deprecated Use `baseURL` instead.
|
|
115
|
+
*/
|
|
116
|
+
baseUrl?: string;
|
|
117
|
+
/**
|
|
118
|
+
* API key for authenticating requests.
|
|
119
|
+
*/
|
|
120
|
+
apiKey?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Organization ID.
|
|
123
|
+
*/
|
|
124
|
+
organization?: string;
|
|
125
|
+
});
|
|
126
|
+
private get baseConfig();
|
|
127
|
+
chat(modelId: OpenAIChatModelId, settings?: OpenAIChatSettings): OpenAIChatLanguageModel;
|
|
128
|
+
completion(modelId: OpenAICompletionModelId, settings?: OpenAICompletionSettings): OpenAICompletionLanguageModel;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Default OpenAI provider instance.
|
|
132
|
+
*/
|
|
133
|
+
declare const openai: OpenAI;
|
|
134
|
+
|
|
135
|
+
export { OpenAI, openai };
|