@nordlys-labs/nordlys-ai-provider 0.1.0
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/README.md +156 -0
- package/dist/index.cjs +1055 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +298 -0
- package/dist/index.d.ts +298 -0
- package/dist/index.js +1038 -0
- package/dist/index.js.map +1 -0
- package/package.json +80 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { ProviderV3, LanguageModelV3, EmbeddingModelV3 } from '@ai-sdk/provider';
|
|
2
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
+
|
|
4
|
+
interface NordlysProvider extends ProviderV3 {
|
|
5
|
+
(modelId: string): LanguageModelV3;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a model for text generation with Nordlys models.
|
|
8
|
+
*/
|
|
9
|
+
languageModel: (modelId: string) => LanguageModelV3;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a chat model with Nordlys models.
|
|
12
|
+
*/
|
|
13
|
+
chat: (modelId: string) => LanguageModelV3;
|
|
14
|
+
/**
|
|
15
|
+
* Text embedding is not currently supported by the Nordlys provider.
|
|
16
|
+
*/
|
|
17
|
+
embeddingModel: (modelId: string) => EmbeddingModelV3;
|
|
18
|
+
}
|
|
19
|
+
interface NordlysProviderSettings {
|
|
20
|
+
/**
|
|
21
|
+
* Use a different URL prefix for API calls, e.g. to use proxy servers.
|
|
22
|
+
* The default prefix is your Nordlys API endpoint.
|
|
23
|
+
*/
|
|
24
|
+
baseURL?: string;
|
|
25
|
+
/**
|
|
26
|
+
* API key for the Nordlys service.
|
|
27
|
+
* It defaults to the `NORDLYS_API_KEY` environment variable.
|
|
28
|
+
*/
|
|
29
|
+
apiKey?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Custom headers to include in the requests.
|
|
32
|
+
*/
|
|
33
|
+
headers?: Record<string, string>;
|
|
34
|
+
/**
|
|
35
|
+
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
36
|
+
* or to provide a custom fetch implementation for e.g. testing.
|
|
37
|
+
*/
|
|
38
|
+
fetch?: FetchFunction;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a Nordlys AI provider instance.
|
|
42
|
+
*/
|
|
43
|
+
declare function createNordlys(options?: NordlysProviderSettings): NordlysProvider;
|
|
44
|
+
/**
|
|
45
|
+
* Default Nordlys provider instance.
|
|
46
|
+
*/
|
|
47
|
+
declare const nordlys: NordlysProvider;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Request payload for Nordlys chat completion API.
|
|
51
|
+
*/
|
|
52
|
+
interface NordlysChatCompletionRequest {
|
|
53
|
+
messages: NordlysChatCompletionMessage[];
|
|
54
|
+
model: string;
|
|
55
|
+
max_tokens?: number;
|
|
56
|
+
max_completion_tokens?: number;
|
|
57
|
+
temperature?: number;
|
|
58
|
+
top_p?: number;
|
|
59
|
+
n?: number;
|
|
60
|
+
stream?: boolean;
|
|
61
|
+
stop?: string | string[];
|
|
62
|
+
presence_penalty?: number;
|
|
63
|
+
frequency_penalty?: number;
|
|
64
|
+
logit_bias?: Record<string, number>;
|
|
65
|
+
user?: string;
|
|
66
|
+
audio?: V2ChatCompletionAudioParam;
|
|
67
|
+
logprobs?: boolean;
|
|
68
|
+
metadata?: SharedMetadata;
|
|
69
|
+
modalities?: string[];
|
|
70
|
+
parallel_tool_calls?: boolean;
|
|
71
|
+
prediction?: V2ChatCompletionPredictionContentParam;
|
|
72
|
+
reasoning_effort?: string;
|
|
73
|
+
response_format?: V2ChatCompletionNewParamsResponseFormatUnion;
|
|
74
|
+
seed?: number;
|
|
75
|
+
service_tier?: string;
|
|
76
|
+
store?: boolean;
|
|
77
|
+
top_logprobs?: number;
|
|
78
|
+
web_search_options?: V2ChatCompletionNewParamsWebSearchOptions;
|
|
79
|
+
stream_options?: V2ChatCompletionStreamOptionsParam;
|
|
80
|
+
tools?: Array<{
|
|
81
|
+
type: 'function';
|
|
82
|
+
function: {
|
|
83
|
+
name: string;
|
|
84
|
+
description?: string;
|
|
85
|
+
parameters: unknown;
|
|
86
|
+
};
|
|
87
|
+
}>;
|
|
88
|
+
tool_choice?: {
|
|
89
|
+
type: 'function';
|
|
90
|
+
function: {
|
|
91
|
+
name: string;
|
|
92
|
+
};
|
|
93
|
+
} | 'auto' | 'none' | 'required';
|
|
94
|
+
}
|
|
95
|
+
interface NordlysChatCompletionDeveloperMessage {
|
|
96
|
+
role: 'developer';
|
|
97
|
+
content: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* All possible message types for Nordlys chat completion.
|
|
101
|
+
*/
|
|
102
|
+
type NordlysChatCompletionMessage = NordlysChatCompletionSystemMessage | NordlysChatCompletionUserMessage | NordlysChatCompletionAssistantMessage | NordlysChatCompletionToolMessage | NordlysChatCompletionDeveloperMessage;
|
|
103
|
+
/**
|
|
104
|
+
* System message for Nordlys chat completion.
|
|
105
|
+
*/
|
|
106
|
+
interface NordlysChatCompletionSystemMessage {
|
|
107
|
+
role: 'system';
|
|
108
|
+
content: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* User message for Nordlys chat completion.
|
|
112
|
+
*/
|
|
113
|
+
interface NordlysChatCompletionUserMessage {
|
|
114
|
+
role: 'user';
|
|
115
|
+
content: string | Array<NordlysChatCompletionContentPart>;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Content part for user messages.
|
|
119
|
+
*/
|
|
120
|
+
type NordlysChatCompletionContentPart = {
|
|
121
|
+
type: 'text';
|
|
122
|
+
text: string;
|
|
123
|
+
} | {
|
|
124
|
+
type: 'image_url';
|
|
125
|
+
image_url: {
|
|
126
|
+
url: string;
|
|
127
|
+
};
|
|
128
|
+
} | {
|
|
129
|
+
type: 'input_audio';
|
|
130
|
+
input_audio: {
|
|
131
|
+
data: string;
|
|
132
|
+
format: 'wav' | 'mp3';
|
|
133
|
+
};
|
|
134
|
+
} | {
|
|
135
|
+
type: 'file';
|
|
136
|
+
file: {
|
|
137
|
+
filename: string;
|
|
138
|
+
file_data: string;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Assistant message for Nordlys chat completion.
|
|
143
|
+
*/
|
|
144
|
+
interface NordlysChatCompletionAssistantMessage {
|
|
145
|
+
role: 'assistant';
|
|
146
|
+
content?: string | null;
|
|
147
|
+
tool_calls?: Array<NordlysChatCompletionMessageToolCall>;
|
|
148
|
+
reasoning_content?: string;
|
|
149
|
+
generated_files?: Array<{
|
|
150
|
+
media_type: string;
|
|
151
|
+
data: string;
|
|
152
|
+
}>;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Tool call for assistant messages.
|
|
156
|
+
*/
|
|
157
|
+
interface NordlysChatCompletionMessageToolCall {
|
|
158
|
+
type: 'function';
|
|
159
|
+
id: string;
|
|
160
|
+
function: {
|
|
161
|
+
arguments: string;
|
|
162
|
+
name: string;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Tool message for Nordlys chat completion.
|
|
167
|
+
*/
|
|
168
|
+
interface NordlysChatCompletionToolMessage {
|
|
169
|
+
role: 'tool';
|
|
170
|
+
content: string;
|
|
171
|
+
tool_call_id: string;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Response from Nordlys chat completion API.
|
|
175
|
+
*/
|
|
176
|
+
interface NordlysChatCompletionResponse {
|
|
177
|
+
id: string;
|
|
178
|
+
object: string;
|
|
179
|
+
created: number;
|
|
180
|
+
model: string;
|
|
181
|
+
choices: Array<{
|
|
182
|
+
index: number;
|
|
183
|
+
message: NordlysChatCompletionAssistantMessage;
|
|
184
|
+
finish_reason: string | null;
|
|
185
|
+
}>;
|
|
186
|
+
usage?: NordlysChatCompletionUsage;
|
|
187
|
+
provider: string;
|
|
188
|
+
service_tier?: string;
|
|
189
|
+
system_fingerprint?: string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Usage statistics for Nordlys chat completion API.
|
|
193
|
+
*/
|
|
194
|
+
interface NordlysChatCompletionUsage {
|
|
195
|
+
prompt_tokens: number;
|
|
196
|
+
completion_tokens: number;
|
|
197
|
+
total_tokens: number;
|
|
198
|
+
reasoning_tokens?: number;
|
|
199
|
+
cached_input_tokens?: number;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Audio parameter for chat completion.
|
|
203
|
+
*/
|
|
204
|
+
interface V2ChatCompletionAudioParam {
|
|
205
|
+
format?: string;
|
|
206
|
+
voice?: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Shared metadata for requests.
|
|
210
|
+
*/
|
|
211
|
+
interface SharedMetadata {
|
|
212
|
+
[key: string]: string;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Prediction content parameter.
|
|
216
|
+
*/
|
|
217
|
+
interface V2ChatCompletionPredictionContentParam {
|
|
218
|
+
type?: string;
|
|
219
|
+
content?: V2ChatCompletionPredictionContentContentUnionParam;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Prediction content union parameter.
|
|
223
|
+
*/
|
|
224
|
+
interface V2ChatCompletionPredictionContentContentUnionParam {
|
|
225
|
+
OfString?: string;
|
|
226
|
+
OfArrayOfContentParts?: Array<{
|
|
227
|
+
type: 'text';
|
|
228
|
+
text: string;
|
|
229
|
+
}>;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Response format union parameter.
|
|
233
|
+
*/
|
|
234
|
+
interface V2ChatCompletionNewParamsResponseFormatUnion {
|
|
235
|
+
OfText?: SharedResponseFormatTextParam;
|
|
236
|
+
OfJSONObject?: SharedResponseFormatJSONObjectParam;
|
|
237
|
+
OfJSONSchema?: SharedResponseFormatJSONSchemaParam;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Text response format parameter.
|
|
241
|
+
*/
|
|
242
|
+
interface SharedResponseFormatTextParam {
|
|
243
|
+
type: string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* JSON object response format parameter.
|
|
247
|
+
*/
|
|
248
|
+
interface SharedResponseFormatJSONObjectParam {
|
|
249
|
+
type: string;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* JSON schema response format parameter.
|
|
253
|
+
*/
|
|
254
|
+
interface SharedResponseFormatJSONSchemaParam {
|
|
255
|
+
type: string;
|
|
256
|
+
json_schema?: SharedResponseFormatJSONSchemaJSONSchemaParam;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* JSON schema details parameter.
|
|
260
|
+
*/
|
|
261
|
+
interface SharedResponseFormatJSONSchemaJSONSchemaParam {
|
|
262
|
+
name: string;
|
|
263
|
+
schema: unknown;
|
|
264
|
+
description?: string;
|
|
265
|
+
strict?: boolean;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Web search options parameter.
|
|
269
|
+
*/
|
|
270
|
+
interface V2ChatCompletionNewParamsWebSearchOptions {
|
|
271
|
+
search_context_size?: string;
|
|
272
|
+
user_location?: V2ChatCompletionNewParamsWebSearchOptionsUserLocation;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* User location for web search options.
|
|
276
|
+
*/
|
|
277
|
+
interface V2ChatCompletionNewParamsWebSearchOptionsUserLocation {
|
|
278
|
+
type?: string;
|
|
279
|
+
approximate?: V2ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Approximate user location for web search options.
|
|
283
|
+
*/
|
|
284
|
+
interface V2ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate {
|
|
285
|
+
city?: string;
|
|
286
|
+
country?: string;
|
|
287
|
+
region?: string;
|
|
288
|
+
timezone?: string;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Stream options parameter.
|
|
292
|
+
*/
|
|
293
|
+
interface V2ChatCompletionStreamOptionsParam {
|
|
294
|
+
include_usage?: boolean;
|
|
295
|
+
include_obfuscation?: boolean;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export { type NordlysChatCompletionAssistantMessage, type NordlysChatCompletionContentPart, type NordlysChatCompletionDeveloperMessage, type NordlysChatCompletionMessage, type NordlysChatCompletionMessageToolCall, type NordlysChatCompletionRequest, type NordlysChatCompletionResponse, type NordlysChatCompletionSystemMessage, type NordlysChatCompletionToolMessage, type NordlysChatCompletionUsage, type NordlysChatCompletionUserMessage, type NordlysProvider, type NordlysProviderSettings, type SharedMetadata, type SharedResponseFormatJSONObjectParam, type SharedResponseFormatJSONSchemaJSONSchemaParam, type SharedResponseFormatJSONSchemaParam, type SharedResponseFormatTextParam, type V2ChatCompletionAudioParam, type V2ChatCompletionNewParamsResponseFormatUnion, type V2ChatCompletionNewParamsWebSearchOptions, type V2ChatCompletionNewParamsWebSearchOptionsUserLocation, type V2ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate, type V2ChatCompletionPredictionContentContentUnionParam, type V2ChatCompletionPredictionContentParam, type V2ChatCompletionStreamOptionsParam, createNordlys, nordlys };
|