@ai-sdk/openai-compatible 0.2.13 → 1.0.0-alpha.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/CHANGELOG.md +217 -23
- package/README.md +1 -1
- package/dist/index.d.mts +98 -97
- package/dist/index.d.ts +98 -97
- package/dist/index.js +453 -488
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +423 -457
- package/dist/index.mjs.map +1 -1
- package/{internal/dist → dist/internal}/index.d.mts +9 -11
- package/{internal/dist → dist/internal}/index.d.ts +9 -11
- package/{internal/dist → dist/internal}/index.js +15 -15
- package/dist/internal/index.js.map +1 -0
- package/{internal/dist → dist/internal}/index.mjs +15 -15
- package/dist/internal/index.mjs.map +1 -0
- package/internal.d.ts +1 -0
- package/package.json +20 -19
- package/internal/dist/index.js.map +0 -1
- package/internal/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
@@ -1,59 +1,253 @@
|
|
1
1
|
# @ai-sdk/openai-compatible
|
2
2
|
|
3
|
-
## 0.
|
3
|
+
## 1.0.0-alpha.1
|
4
4
|
|
5
5
|
### Patch Changes
|
6
6
|
|
7
|
-
-
|
7
|
+
- Updated dependencies [3f2f00c]
|
8
|
+
- @ai-sdk/provider@2.0.0-alpha.1
|
9
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.1
|
8
10
|
|
9
|
-
## 0.
|
11
|
+
## 1.0.0-canary.19
|
10
12
|
|
11
13
|
### Patch Changes
|
12
14
|
|
13
|
-
-
|
15
|
+
- Updated dependencies [faf8446]
|
16
|
+
- @ai-sdk/provider-utils@3.0.0-canary.19
|
14
17
|
|
15
|
-
## 0.
|
18
|
+
## 1.0.0-canary.18
|
16
19
|
|
17
20
|
### Patch Changes
|
18
21
|
|
19
|
-
-
|
22
|
+
- Updated dependencies [40acf9b]
|
23
|
+
- @ai-sdk/provider-utils@3.0.0-canary.18
|
20
24
|
|
21
|
-
## 0.
|
25
|
+
## 1.0.0-canary.17
|
26
|
+
|
27
|
+
### Major Changes
|
28
|
+
|
29
|
+
- 516be5b: ### Move Image Model Settings into generate options
|
30
|
+
|
31
|
+
Image Models no longer have settings. Instead, `maxImagesPerCall` can be passed directly to `generateImage()`. All other image settings can be passed to `providerOptions[provider]`.
|
32
|
+
|
33
|
+
Before
|
34
|
+
|
35
|
+
```js
|
36
|
+
await generateImage({
|
37
|
+
model: luma.image('photon-flash-1', {
|
38
|
+
maxImagesPerCall: 5,
|
39
|
+
pollIntervalMillis: 500,
|
40
|
+
}),
|
41
|
+
prompt,
|
42
|
+
n: 10,
|
43
|
+
});
|
44
|
+
```
|
45
|
+
|
46
|
+
After
|
47
|
+
|
48
|
+
```js
|
49
|
+
await generateImage({
|
50
|
+
model: luma.image('photon-flash-1'),
|
51
|
+
prompt,
|
52
|
+
n: 10,
|
53
|
+
maxImagesPerCall: 5,
|
54
|
+
providerOptions: {
|
55
|
+
luma: { pollIntervalMillis: 5 },
|
56
|
+
},
|
57
|
+
});
|
58
|
+
```
|
59
|
+
|
60
|
+
Pull Request: https://github.com/vercel/ai/pull/6180
|
61
|
+
|
62
|
+
### Patch Changes
|
63
|
+
|
64
|
+
- Updated dependencies [ea7a7c9]
|
65
|
+
- @ai-sdk/provider-utils@3.0.0-canary.17
|
66
|
+
|
67
|
+
## 1.0.0-canary.16
|
68
|
+
|
69
|
+
### Patch Changes
|
70
|
+
|
71
|
+
- Updated dependencies [87b828f]
|
72
|
+
- @ai-sdk/provider-utils@3.0.0-canary.16
|
73
|
+
|
74
|
+
## 1.0.0-canary.15
|
75
|
+
|
76
|
+
### Patch Changes
|
77
|
+
|
78
|
+
- Updated dependencies [a571d6e]
|
79
|
+
- Updated dependencies [a8c8bd5]
|
80
|
+
- Updated dependencies [7979f7f]
|
81
|
+
- Updated dependencies [41fa418]
|
82
|
+
- @ai-sdk/provider-utils@3.0.0-canary.15
|
83
|
+
- @ai-sdk/provider@2.0.0-canary.14
|
84
|
+
|
85
|
+
## 1.0.0-canary.14
|
86
|
+
|
87
|
+
### Patch Changes
|
88
|
+
|
89
|
+
- Updated dependencies [957b739]
|
90
|
+
- Updated dependencies [9bd5ab5]
|
91
|
+
- @ai-sdk/provider-utils@3.0.0-canary.14
|
92
|
+
- @ai-sdk/provider@2.0.0-canary.13
|
93
|
+
|
94
|
+
## 1.0.0-canary.13
|
95
|
+
|
96
|
+
### Patch Changes
|
97
|
+
|
98
|
+
- d9209ca: fix (image-model): `specificationVersion: v1` -> `v2`
|
99
|
+
- Updated dependencies [7b3ae3f]
|
100
|
+
- Updated dependencies [0ff02bb]
|
101
|
+
- @ai-sdk/provider@2.0.0-canary.12
|
102
|
+
- @ai-sdk/provider-utils@3.0.0-canary.13
|
103
|
+
|
104
|
+
## 1.0.0-canary.12
|
105
|
+
|
106
|
+
### Patch Changes
|
107
|
+
|
108
|
+
- Updated dependencies [9bf7291]
|
109
|
+
- Updated dependencies [4617fab]
|
110
|
+
- Updated dependencies [e030615]
|
111
|
+
- @ai-sdk/provider@2.0.0-canary.11
|
112
|
+
- @ai-sdk/provider-utils@3.0.0-canary.12
|
113
|
+
|
114
|
+
## 1.0.0-canary.11
|
115
|
+
|
116
|
+
### Patch Changes
|
117
|
+
|
118
|
+
- db72adc: chore(providers/openai): update completion model to use providerOptions
|
119
|
+
- 42e32b0: feat(providers/xai): add reasoningEffort provider option
|
120
|
+
- 66962ed: fix(packages): export node10 compatible types
|
121
|
+
- 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2`
|
122
|
+
- Updated dependencies [66962ed]
|
123
|
+
- Updated dependencies [9301f86]
|
124
|
+
- Updated dependencies [a3f768e]
|
125
|
+
- @ai-sdk/provider-utils@3.0.0-canary.11
|
126
|
+
- @ai-sdk/provider@2.0.0-canary.10
|
127
|
+
|
128
|
+
## 1.0.0-canary.10
|
129
|
+
|
130
|
+
### Patch Changes
|
131
|
+
|
132
|
+
- cf8280e: fix(providers/xai): return actual usage when streaming instead of NaN
|
133
|
+
- Updated dependencies [e86be6f]
|
134
|
+
- @ai-sdk/provider@2.0.0-canary.9
|
135
|
+
- @ai-sdk/provider-utils@3.0.0-canary.10
|
136
|
+
|
137
|
+
## 1.0.0-canary.9
|
138
|
+
|
139
|
+
### Patch Changes
|
140
|
+
|
141
|
+
- Updated dependencies [95857aa]
|
142
|
+
- Updated dependencies [7ea4132]
|
143
|
+
- @ai-sdk/provider@2.0.0-canary.8
|
144
|
+
- @ai-sdk/provider-utils@3.0.0-canary.9
|
145
|
+
|
146
|
+
## 1.0.0-canary.8
|
22
147
|
|
23
148
|
### Patch Changes
|
24
149
|
|
25
|
-
-
|
26
|
-
|
27
|
-
|
150
|
+
- b9a6121: fix (provider/openai-compatible): change tool_call type schema to nullish
|
151
|
+
- Updated dependencies [5d142ab]
|
152
|
+
- Updated dependencies [b6b43c7]
|
153
|
+
- Updated dependencies [8aa9e20]
|
154
|
+
- Updated dependencies [3795467]
|
155
|
+
- @ai-sdk/provider-utils@3.0.0-canary.8
|
156
|
+
- @ai-sdk/provider@2.0.0-canary.7
|
28
157
|
|
29
|
-
## 0.
|
158
|
+
## 1.0.0-canary.7
|
30
159
|
|
31
160
|
### Patch Changes
|
32
161
|
|
33
|
-
-
|
162
|
+
- fa49207: feat(providers/openai-compatible): convert to providerOptions
|
163
|
+
- 26735b5: chore(embedding-model): add v2 interface
|
164
|
+
- 443d8ec: feat(embedding-model-v2): add response body field
|
165
|
+
- fd65bc6: chore(embedding-model-v2): rename rawResponse to response
|
166
|
+
- Updated dependencies [26735b5]
|
167
|
+
- Updated dependencies [443d8ec]
|
168
|
+
- Updated dependencies [14c9410]
|
169
|
+
- Updated dependencies [d9c98f4]
|
170
|
+
- Updated dependencies [c4a2fec]
|
171
|
+
- Updated dependencies [0054544]
|
172
|
+
- Updated dependencies [9e9c809]
|
173
|
+
- Updated dependencies [32831c6]
|
174
|
+
- Updated dependencies [d0f9495]
|
175
|
+
- Updated dependencies [fd65bc6]
|
176
|
+
- Updated dependencies [393138b]
|
177
|
+
- Updated dependencies [7182d14]
|
178
|
+
- @ai-sdk/provider@2.0.0-canary.6
|
179
|
+
- @ai-sdk/provider-utils@3.0.0-canary.7
|
34
180
|
|
35
|
-
## 0.
|
181
|
+
## 1.0.0-canary.6
|
36
182
|
|
37
183
|
### Patch Changes
|
38
184
|
|
39
|
-
-
|
40
|
-
|
41
|
-
|
185
|
+
- 6db02c9: chore(openai-compatible): remove simulateStreaming
|
186
|
+
- Updated dependencies [411e483]
|
187
|
+
- Updated dependencies [79457bd]
|
188
|
+
- Updated dependencies [ad80501]
|
189
|
+
- Updated dependencies [1766ede]
|
190
|
+
- Updated dependencies [f10304b]
|
191
|
+
- @ai-sdk/provider@2.0.0-canary.5
|
192
|
+
- @ai-sdk/provider-utils@3.0.0-canary.6
|
42
193
|
|
43
|
-
## 0.
|
194
|
+
## 1.0.0-canary.5
|
44
195
|
|
45
196
|
### Patch Changes
|
46
197
|
|
47
|
-
- Updated dependencies [
|
48
|
-
- @ai-sdk/provider
|
49
|
-
- @ai-sdk/provider@
|
198
|
+
- Updated dependencies [6f6bb89]
|
199
|
+
- @ai-sdk/provider@2.0.0-canary.4
|
200
|
+
- @ai-sdk/provider-utils@3.0.0-canary.5
|
201
|
+
|
202
|
+
## 1.0.0-canary.4
|
203
|
+
|
204
|
+
### Patch Changes
|
205
|
+
|
206
|
+
- Updated dependencies [d1a1aa1]
|
207
|
+
- @ai-sdk/provider@2.0.0-canary.3
|
208
|
+
- @ai-sdk/provider-utils@3.0.0-canary.4
|
209
|
+
|
210
|
+
## 1.0.0-canary.3
|
211
|
+
|
212
|
+
### Patch Changes
|
213
|
+
|
214
|
+
- Updated dependencies [a166433]
|
215
|
+
- Updated dependencies [abf9a79]
|
216
|
+
- Updated dependencies [9f95b35]
|
217
|
+
- Updated dependencies [0a87932]
|
218
|
+
- Updated dependencies [6dc848c]
|
219
|
+
- @ai-sdk/provider-utils@3.0.0-canary.3
|
220
|
+
- @ai-sdk/provider@2.0.0-canary.2
|
221
|
+
|
222
|
+
## 1.0.0-canary.2
|
223
|
+
|
224
|
+
### Patch Changes
|
225
|
+
|
226
|
+
- Updated dependencies [c57e248]
|
227
|
+
- Updated dependencies [33f4a6a]
|
228
|
+
- @ai-sdk/provider@2.0.0-canary.1
|
229
|
+
- @ai-sdk/provider-utils@3.0.0-canary.2
|
230
|
+
|
231
|
+
## 1.0.0-canary.1
|
232
|
+
|
233
|
+
### Patch Changes
|
234
|
+
|
235
|
+
- Updated dependencies [060370c]
|
236
|
+
- Updated dependencies [0c0c0b3]
|
237
|
+
- Updated dependencies [63d791d]
|
238
|
+
- @ai-sdk/provider-utils@3.0.0-canary.1
|
239
|
+
|
240
|
+
## 1.0.0-canary.0
|
241
|
+
|
242
|
+
### Major Changes
|
50
243
|
|
51
|
-
|
244
|
+
- d5f588f: AI SDK 5
|
52
245
|
|
53
246
|
### Patch Changes
|
54
247
|
|
55
|
-
- Updated dependencies [
|
56
|
-
- @ai-sdk/provider-utils@
|
248
|
+
- Updated dependencies [d5f588f]
|
249
|
+
- @ai-sdk/provider-utils@3.0.0-canary.0
|
250
|
+
- @ai-sdk/provider@2.0.0-canary.0
|
57
251
|
|
58
252
|
## 0.2.5
|
59
253
|
|
package/README.md
CHANGED
@@ -97,4 +97,4 @@ const { text } = await generateText({
|
|
97
97
|
});
|
98
98
|
```
|
99
99
|
|
100
|
-
For more examples, see the [OpenAI Compatible Providers](https://sdk.
|
100
|
+
For more examples, see the [OpenAI Compatible Providers](https://ai-sdk.dev/providers/openai-compatible-providers) documentation.
|
package/dist/index.d.mts
CHANGED
@@ -1,23 +1,26 @@
|
|
1
|
-
import {
|
1
|
+
import { SharedV2ProviderMetadata, LanguageModelV2, EmbeddingModelV2, ImageModelV2, ProviderV2 } from '@ai-sdk/provider';
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
3
|
-
import {
|
3
|
+
import { z, ZodSchema } from 'zod';
|
4
4
|
|
5
5
|
type OpenAICompatibleChatModelId = string;
|
6
|
-
|
6
|
+
declare const openaiCompatibleProviderOptions: z.ZodObject<{
|
7
7
|
/**
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
user
|
8
|
+
* A unique identifier representing your end-user, which can help the provider to
|
9
|
+
* monitor and detect abuse.
|
10
|
+
*/
|
11
|
+
user: z.ZodOptional<z.ZodString>;
|
12
12
|
/**
|
13
|
-
|
14
|
-
Enable this if the model that you are using does not support streaming.
|
15
|
-
|
16
|
-
Defaults to `false`.
|
17
|
-
@deprecated Use `simulateStreamingMiddleware` instead.
|
13
|
+
* Reasoning effort for reasoning models. Defaults to `medium`.
|
18
14
|
*/
|
19
|
-
|
20
|
-
}
|
15
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
17
|
+
user?: string | undefined;
|
18
|
+
reasoningEffort?: "low" | "medium" | "high" | undefined;
|
19
|
+
}, {
|
20
|
+
user?: string | undefined;
|
21
|
+
reasoningEffort?: "low" | "medium" | "high" | undefined;
|
22
|
+
}>;
|
23
|
+
type OpenAICompatibleProviderOptions = z.infer<typeof openaiCompatibleProviderOptions>;
|
21
24
|
|
22
25
|
declare const openaiCompatibleErrorDataSchema: z.ZodObject<{
|
23
26
|
error: z.ZodObject<{
|
@@ -74,7 +77,7 @@ type MetadataExtractor = {
|
|
74
77
|
*/
|
75
78
|
extractMetadata: ({ parsedBody, }: {
|
76
79
|
parsedBody: unknown;
|
77
|
-
}) =>
|
80
|
+
}) => Promise<SharedV2ProviderMetadata | undefined>;
|
78
81
|
/**
|
79
82
|
* Creates an extractor for handling streaming responses. The returned object provides
|
80
83
|
* methods to process individual chunks and build the final metadata from the accumulated
|
@@ -97,7 +100,7 @@ type MetadataExtractor = {
|
|
97
100
|
* @returns Provider-specific metadata or undefined if no metadata is available.
|
98
101
|
* The metadata should be under a key indicating the provider id.
|
99
102
|
*/
|
100
|
-
buildMetadata():
|
103
|
+
buildMetadata(): SharedV2ProviderMetadata | undefined;
|
101
104
|
};
|
102
105
|
};
|
103
106
|
|
@@ -113,64 +116,64 @@ type OpenAICompatibleChatConfig = {
|
|
113
116
|
errorStructure?: ProviderErrorStructure<any>;
|
114
117
|
metadataExtractor?: MetadataExtractor;
|
115
118
|
/**
|
116
|
-
Default object generation mode that should be used with this model when
|
117
|
-
no mode is specified. Should be the mode with the best results for this
|
118
|
-
model. `undefined` can be specified if object generation is not supported.
|
119
|
-
*/
|
120
|
-
defaultObjectGenerationMode?: LanguageModelV1ObjectGenerationMode;
|
121
|
-
/**
|
122
119
|
* Whether the model supports structured outputs.
|
123
120
|
*/
|
124
121
|
supportsStructuredOutputs?: boolean;
|
122
|
+
/**
|
123
|
+
* The supported URLs for the model.
|
124
|
+
*/
|
125
|
+
supportedUrls?: () => LanguageModelV2['supportedUrls'];
|
125
126
|
};
|
126
|
-
declare class OpenAICompatibleChatLanguageModel implements
|
127
|
-
readonly specificationVersion = "
|
127
|
+
declare class OpenAICompatibleChatLanguageModel implements LanguageModelV2 {
|
128
|
+
readonly specificationVersion = "v2";
|
128
129
|
readonly supportsStructuredOutputs: boolean;
|
129
130
|
readonly modelId: OpenAICompatibleChatModelId;
|
130
|
-
readonly settings: OpenAICompatibleChatSettings;
|
131
131
|
private readonly config;
|
132
132
|
private readonly failedResponseHandler;
|
133
133
|
private readonly chunkSchema;
|
134
|
-
constructor(modelId: OpenAICompatibleChatModelId,
|
135
|
-
get defaultObjectGenerationMode(): 'json' | 'tool' | undefined;
|
134
|
+
constructor(modelId: OpenAICompatibleChatModelId, config: OpenAICompatibleChatConfig);
|
136
135
|
get provider(): string;
|
137
136
|
private get providerOptionsName();
|
137
|
+
get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
|
138
138
|
private getArgs;
|
139
|
-
doGenerate(options: Parameters<
|
140
|
-
doStream(options: Parameters<
|
139
|
+
doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
|
140
|
+
doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
141
141
|
}
|
142
142
|
|
143
143
|
type OpenAICompatibleCompletionModelId = string;
|
144
|
-
|
144
|
+
declare const openaiCompatibleCompletionProviderOptions: z.ZodObject<{
|
145
145
|
/**
|
146
|
-
|
146
|
+
* Echo back the prompt in addition to the completion.
|
147
147
|
*/
|
148
|
-
echo
|
148
|
+
echo: z.ZodOptional<z.ZodBoolean>;
|
149
149
|
/**
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
can use this tokenizer tool to convert text to token IDs. Mathematically,
|
155
|
-
the bias is added to the logits generated by the model prior to sampling.
|
156
|
-
The exact effect will vary per model, but values between -1 and 1 should
|
157
|
-
decrease or increase likelihood of selection; values like -100 or 100
|
158
|
-
should result in a ban or exclusive selection of the relevant token.
|
159
|
-
|
160
|
-
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
161
|
-
token from being generated.
|
150
|
+
* Modify the likelihood of specified tokens appearing in the completion.
|
151
|
+
*
|
152
|
+
* Accepts a JSON object that maps tokens (specified by their token ID in
|
153
|
+
* the GPT tokenizer) to an associated bias value from -100 to 100.
|
162
154
|
*/
|
163
|
-
logitBias
|
155
|
+
logitBias: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
164
156
|
/**
|
165
|
-
|
157
|
+
* The suffix that comes after a completion of inserted text.
|
166
158
|
*/
|
167
|
-
suffix
|
159
|
+
suffix: z.ZodOptional<z.ZodString>;
|
168
160
|
/**
|
169
|
-
|
170
|
-
|
161
|
+
* A unique identifier representing your end-user, which can help providers to
|
162
|
+
* monitor and detect abuse.
|
171
163
|
*/
|
172
|
-
user
|
173
|
-
}
|
164
|
+
user: z.ZodOptional<z.ZodString>;
|
165
|
+
}, "strip", z.ZodTypeAny, {
|
166
|
+
user?: string | undefined;
|
167
|
+
echo?: boolean | undefined;
|
168
|
+
logitBias?: Record<string, number> | undefined;
|
169
|
+
suffix?: string | undefined;
|
170
|
+
}, {
|
171
|
+
user?: string | undefined;
|
172
|
+
echo?: boolean | undefined;
|
173
|
+
logitBias?: Record<string, number> | undefined;
|
174
|
+
suffix?: string | undefined;
|
175
|
+
}>;
|
176
|
+
type OpenAICompatibleCompletionProviderOptions = z.infer<typeof openaiCompatibleCompletionProviderOptions>;
|
174
177
|
|
175
178
|
type OpenAICompatibleCompletionConfig = {
|
176
179
|
provider: string;
|
@@ -182,36 +185,46 @@ type OpenAICompatibleCompletionConfig = {
|
|
182
185
|
}) => string;
|
183
186
|
fetch?: FetchFunction;
|
184
187
|
errorStructure?: ProviderErrorStructure<any>;
|
188
|
+
/**
|
189
|
+
* The supported URLs for the model.
|
190
|
+
*/
|
191
|
+
supportedUrls?: () => LanguageModelV2['supportedUrls'];
|
185
192
|
};
|
186
|
-
declare class OpenAICompatibleCompletionLanguageModel implements
|
187
|
-
readonly specificationVersion = "
|
188
|
-
readonly defaultObjectGenerationMode: undefined;
|
193
|
+
declare class OpenAICompatibleCompletionLanguageModel implements LanguageModelV2 {
|
194
|
+
readonly specificationVersion = "v2";
|
189
195
|
readonly modelId: OpenAICompatibleCompletionModelId;
|
190
|
-
readonly settings: OpenAICompatibleCompletionSettings;
|
191
196
|
private readonly config;
|
192
197
|
private readonly failedResponseHandler;
|
193
198
|
private readonly chunkSchema;
|
194
|
-
constructor(modelId: OpenAICompatibleCompletionModelId,
|
199
|
+
constructor(modelId: OpenAICompatibleCompletionModelId, config: OpenAICompatibleCompletionConfig);
|
195
200
|
get provider(): string;
|
196
201
|
private get providerOptionsName();
|
202
|
+
get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
|
197
203
|
private getArgs;
|
198
|
-
doGenerate(options: Parameters<
|
199
|
-
doStream(options: Parameters<
|
204
|
+
doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
|
205
|
+
doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
200
206
|
}
|
201
207
|
|
202
208
|
type OpenAICompatibleEmbeddingModelId = string;
|
203
|
-
|
209
|
+
declare const openaiCompatibleEmbeddingProviderOptions: z.ZodObject<{
|
204
210
|
/**
|
205
|
-
|
206
|
-
|
211
|
+
* The number of dimensions the resulting output embeddings should have.
|
212
|
+
* Only supported in text-embedding-3 and later models.
|
207
213
|
*/
|
208
|
-
dimensions
|
214
|
+
dimensions: z.ZodOptional<z.ZodNumber>;
|
209
215
|
/**
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
user
|
214
|
-
}
|
216
|
+
* A unique identifier representing your end-user, which can help providers to
|
217
|
+
* monitor and detect abuse.
|
218
|
+
*/
|
219
|
+
user: z.ZodOptional<z.ZodString>;
|
220
|
+
}, "strip", z.ZodTypeAny, {
|
221
|
+
user?: string | undefined;
|
222
|
+
dimensions?: number | undefined;
|
223
|
+
}, {
|
224
|
+
user?: string | undefined;
|
225
|
+
dimensions?: number | undefined;
|
226
|
+
}>;
|
227
|
+
type OpenAICompatibleEmbeddingProviderOptions = z.infer<typeof openaiCompatibleEmbeddingProviderOptions>;
|
215
228
|
|
216
229
|
type OpenAICompatibleEmbeddingConfig = {
|
217
230
|
/**
|
@@ -231,30 +244,19 @@ type OpenAICompatibleEmbeddingConfig = {
|
|
231
244
|
fetch?: FetchFunction;
|
232
245
|
errorStructure?: ProviderErrorStructure<any>;
|
233
246
|
};
|
234
|
-
declare class OpenAICompatibleEmbeddingModel implements
|
235
|
-
readonly specificationVersion = "
|
247
|
+
declare class OpenAICompatibleEmbeddingModel implements EmbeddingModelV2<string> {
|
248
|
+
readonly specificationVersion = "v2";
|
236
249
|
readonly modelId: OpenAICompatibleEmbeddingModelId;
|
237
250
|
private readonly config;
|
238
|
-
private readonly settings;
|
239
251
|
get provider(): string;
|
240
252
|
get maxEmbeddingsPerCall(): number;
|
241
253
|
get supportsParallelCalls(): boolean;
|
242
|
-
constructor(modelId: OpenAICompatibleEmbeddingModelId,
|
243
|
-
|
254
|
+
constructor(modelId: OpenAICompatibleEmbeddingModelId, config: OpenAICompatibleEmbeddingConfig);
|
255
|
+
private get providerOptionsName();
|
256
|
+
doEmbed({ values, headers, abortSignal, providerOptions, }: Parameters<EmbeddingModelV2<string>['doEmbed']>[0]): Promise<Awaited<ReturnType<EmbeddingModelV2<string>['doEmbed']>>>;
|
244
257
|
}
|
245
258
|
|
246
259
|
type OpenAICompatibleImageModelId = string;
|
247
|
-
interface OpenAICompatibleImageSettings {
|
248
|
-
/**
|
249
|
-
A unique identifier representing your end-user, which can help the provider to
|
250
|
-
monitor and detect abuse.
|
251
|
-
*/
|
252
|
-
user?: string;
|
253
|
-
/**
|
254
|
-
* The maximum number of images to generate.
|
255
|
-
*/
|
256
|
-
maxImagesPerCall?: number;
|
257
|
-
}
|
258
260
|
|
259
261
|
type OpenAICompatibleImageModelConfig = {
|
260
262
|
provider: string;
|
@@ -269,24 +271,23 @@ type OpenAICompatibleImageModelConfig = {
|
|
269
271
|
currentDate?: () => Date;
|
270
272
|
};
|
271
273
|
};
|
272
|
-
declare class OpenAICompatibleImageModel implements
|
274
|
+
declare class OpenAICompatibleImageModel implements ImageModelV2 {
|
273
275
|
readonly modelId: OpenAICompatibleImageModelId;
|
274
|
-
private readonly settings;
|
275
276
|
private readonly config;
|
276
|
-
readonly specificationVersion = "
|
277
|
-
|
277
|
+
readonly specificationVersion = "v2";
|
278
|
+
readonly maxImagesPerCall = 10;
|
278
279
|
get provider(): string;
|
279
|
-
constructor(modelId: OpenAICompatibleImageModelId,
|
280
|
-
doGenerate({ prompt, n, size, aspectRatio, seed, providerOptions, headers, abortSignal, }: Parameters<
|
280
|
+
constructor(modelId: OpenAICompatibleImageModelId, config: OpenAICompatibleImageModelConfig);
|
281
|
+
doGenerate({ prompt, n, size, aspectRatio, seed, providerOptions, headers, abortSignal, }: Parameters<ImageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<ImageModelV2['doGenerate']>>>;
|
281
282
|
}
|
282
283
|
|
283
|
-
interface OpenAICompatibleProvider<CHAT_MODEL_IDS extends string = string, COMPLETION_MODEL_IDS extends string = string, EMBEDDING_MODEL_IDS extends string = string, IMAGE_MODEL_IDS extends string = string> extends Omit<
|
284
|
-
(modelId: CHAT_MODEL_IDS
|
285
|
-
languageModel(modelId: CHAT_MODEL_IDS
|
286
|
-
chatModel(modelId: CHAT_MODEL_IDS
|
287
|
-
completionModel(modelId: COMPLETION_MODEL_IDS
|
288
|
-
textEmbeddingModel(modelId: EMBEDDING_MODEL_IDS
|
289
|
-
imageModel(modelId: IMAGE_MODEL_IDS
|
284
|
+
interface OpenAICompatibleProvider<CHAT_MODEL_IDS extends string = string, COMPLETION_MODEL_IDS extends string = string, EMBEDDING_MODEL_IDS extends string = string, IMAGE_MODEL_IDS extends string = string> extends Omit<ProviderV2, 'imageModel'> {
|
285
|
+
(modelId: CHAT_MODEL_IDS): LanguageModelV2;
|
286
|
+
languageModel(modelId: CHAT_MODEL_IDS): LanguageModelV2;
|
287
|
+
chatModel(modelId: CHAT_MODEL_IDS): LanguageModelV2;
|
288
|
+
completionModel(modelId: COMPLETION_MODEL_IDS): LanguageModelV2;
|
289
|
+
textEmbeddingModel(modelId: EMBEDDING_MODEL_IDS): EmbeddingModelV2<string>;
|
290
|
+
imageModel(modelId: IMAGE_MODEL_IDS): ImageModelV2;
|
290
291
|
}
|
291
292
|
interface OpenAICompatibleProviderSettings {
|
292
293
|
/**
|
@@ -323,4 +324,4 @@ Create an OpenAICompatible provider instance.
|
|
323
324
|
*/
|
324
325
|
declare function createOpenAICompatible<CHAT_MODEL_IDS extends string, COMPLETION_MODEL_IDS extends string, EMBEDDING_MODEL_IDS extends string, IMAGE_MODEL_IDS extends string>(options: OpenAICompatibleProviderSettings): OpenAICompatibleProvider<CHAT_MODEL_IDS, COMPLETION_MODEL_IDS, EMBEDDING_MODEL_IDS, IMAGE_MODEL_IDS>;
|
325
326
|
|
326
|
-
export { type MetadataExtractor, OpenAICompatibleChatLanguageModel, type
|
327
|
+
export { type MetadataExtractor, OpenAICompatibleChatLanguageModel, type OpenAICompatibleChatModelId, OpenAICompatibleCompletionLanguageModel, type OpenAICompatibleCompletionModelId, type OpenAICompatibleCompletionProviderOptions, OpenAICompatibleEmbeddingModel, type OpenAICompatibleEmbeddingModelId, type OpenAICompatibleEmbeddingProviderOptions, type OpenAICompatibleErrorData, OpenAICompatibleImageModel, type OpenAICompatibleProvider, type OpenAICompatibleProviderOptions, type OpenAICompatibleProviderSettings, type ProviderErrorStructure, createOpenAICompatible };
|