@ai-sdk/openai 0.0.25 → 0.0.27

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.
@@ -0,0 +1,163 @@
1
+ import { LanguageModelV1, EmbeddingModelV1 } from '@ai-sdk/provider';
2
+
3
+ type OpenAIChatModelId = 'gpt-4o' | 'gpt-4o-2024-05-13' | '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
+ Return the log probabilities of the tokens. Including logprobs will increase
22
+ the response size and can slow down response times. However, it can
23
+ be useful to better understand how the model is behaving.
24
+
25
+ Setting to true will return the log probabilities of the tokens that
26
+ were generated.
27
+
28
+ Setting to a number will return the log probabilities of the top n
29
+ tokens that were generated.
30
+ */
31
+ logprobs?: boolean | number;
32
+ /**
33
+ A unique identifier representing your end-user, which can help OpenAI to
34
+ monitor and detect abuse. Learn more.
35
+ */
36
+ user?: string;
37
+ }
38
+
39
+ type OpenAIChatConfig = {
40
+ provider: string;
41
+ compatibility: 'strict' | 'compatible';
42
+ headers: () => Record<string, string | undefined>;
43
+ url: (options: {
44
+ modelId: string;
45
+ path: string;
46
+ }) => string;
47
+ };
48
+ declare class OpenAIChatLanguageModel implements LanguageModelV1 {
49
+ readonly specificationVersion = "v1";
50
+ readonly defaultObjectGenerationMode = "tool";
51
+ readonly modelId: OpenAIChatModelId;
52
+ readonly settings: OpenAIChatSettings;
53
+ private readonly config;
54
+ constructor(modelId: OpenAIChatModelId, settings: OpenAIChatSettings, config: OpenAIChatConfig);
55
+ get provider(): string;
56
+ private getArgs;
57
+ doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>;
58
+ doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
59
+ }
60
+
61
+ type OpenAICompletionModelId = 'gpt-3.5-turbo-instruct' | (string & {});
62
+ interface OpenAICompletionSettings {
63
+ /**
64
+ Echo back the prompt in addition to the completion.
65
+ */
66
+ echo?: boolean;
67
+ /**
68
+ Modify the likelihood of specified tokens appearing in the completion.
69
+
70
+ Accepts a JSON object that maps tokens (specified by their token ID in
71
+ the GPT tokenizer) to an associated bias value from -100 to 100. You
72
+ can use this tokenizer tool to convert text to token IDs. Mathematically,
73
+ the bias is added to the logits generated by the model prior to sampling.
74
+ The exact effect will vary per model, but values between -1 and 1 should
75
+ decrease or increase likelihood of selection; values like -100 or 100
76
+ should result in a ban or exclusive selection of the relevant token.
77
+
78
+ As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
79
+ token from being generated.
80
+ */
81
+ logitBias?: Record<number, number>;
82
+ /**
83
+ Return the log probabilities of the tokens. Including logprobs will increase
84
+ the response size and can slow down response times. However, it can
85
+ be useful to better understand how the model is behaving.
86
+
87
+ Setting to true will return the log probabilities of the tokens that
88
+ were generated.
89
+
90
+ Setting to a number will return the log probabilities of the top n
91
+ tokens that were generated.
92
+ */
93
+ logprobs?: boolean | number;
94
+ /**
95
+ The suffix that comes after a completion of inserted text.
96
+ */
97
+ suffix?: string;
98
+ /**
99
+ A unique identifier representing your end-user, which can help OpenAI to
100
+ monitor and detect abuse. Learn more.
101
+ */
102
+ user?: string;
103
+ }
104
+
105
+ type OpenAICompletionConfig = {
106
+ provider: string;
107
+ baseURL: string;
108
+ compatibility: 'strict' | 'compatible';
109
+ headers: () => Record<string, string | undefined>;
110
+ };
111
+ declare class OpenAICompletionLanguageModel implements LanguageModelV1 {
112
+ readonly specificationVersion = "v1";
113
+ readonly defaultObjectGenerationMode: undefined;
114
+ readonly modelId: OpenAICompletionModelId;
115
+ readonly settings: OpenAICompletionSettings;
116
+ private readonly config;
117
+ constructor(modelId: OpenAICompletionModelId, settings: OpenAICompletionSettings, config: OpenAICompletionConfig);
118
+ get provider(): string;
119
+ private getArgs;
120
+ doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>;
121
+ doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
122
+ }
123
+
124
+ type OpenAIEmbeddingModelId = 'text-embedding-3-small' | 'text-embedding-3-large' | 'text-embedding-ada-002' | (string & {});
125
+ interface OpenAIEmbeddingSettings {
126
+ /**
127
+ Override the maximum number of embeddings per call.
128
+ */
129
+ maxEmbeddingsPerCall?: number;
130
+ /**
131
+ Override the parallelism of embedding calls.
132
+ */
133
+ supportsParallelCalls?: boolean;
134
+ /**
135
+ The number of dimensions the resulting output embeddings should have.
136
+ Only supported in text-embedding-3 and later models.
137
+ */
138
+ dimensions?: number;
139
+ /**
140
+ A unique identifier representing your end-user, which can help OpenAI to
141
+ monitor and detect abuse. Learn more.
142
+ */
143
+ user?: string;
144
+ }
145
+
146
+ type OpenAIEmbeddingConfig = {
147
+ provider: string;
148
+ baseURL: string;
149
+ headers: () => Record<string, string | undefined>;
150
+ };
151
+ declare class OpenAIEmbeddingModel implements EmbeddingModelV1<string> {
152
+ readonly specificationVersion = "v1";
153
+ readonly modelId: OpenAIEmbeddingModelId;
154
+ private readonly config;
155
+ private readonly settings;
156
+ get provider(): string;
157
+ get maxEmbeddingsPerCall(): number;
158
+ get supportsParallelCalls(): boolean;
159
+ constructor(modelId: OpenAIEmbeddingModelId, settings: OpenAIEmbeddingSettings, config: OpenAIEmbeddingConfig);
160
+ doEmbed({ values, abortSignal, }: Parameters<EmbeddingModelV1<string>['doEmbed']>[0]): Promise<Awaited<ReturnType<EmbeddingModelV1<string>['doEmbed']>>>;
161
+ }
162
+
163
+ export { OpenAIChatLanguageModel, type OpenAIChatModelId, type OpenAIChatSettings, OpenAICompletionLanguageModel, type OpenAICompletionModelId, type OpenAICompletionSettings, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingSettings };