@warlock.js/ai-openai 4.13.0 → 4.14.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/CHANGELOG.md +11 -0
- package/cjs/index.cjs +29 -75
- package/cjs/index.cjs.map +1 -1
- package/esm/config.type.d.mts +15 -9
- package/esm/config.type.d.mts.map +1 -1
- package/esm/image.d.mts +8 -6
- package/esm/image.d.mts.map +1 -1
- package/esm/image.mjs +9 -9
- package/esm/image.mjs.map +1 -1
- package/esm/index.d.mts +3 -4
- package/esm/index.mjs +3 -4
- package/esm/sdk.d.mts +11 -8
- package/esm/sdk.d.mts.map +1 -1
- package/esm/sdk.mjs +11 -8
- package/esm/sdk.mjs.map +1 -1
- package/esm/speech.d.mts +6 -6
- package/esm/speech.d.mts.map +1 -1
- package/esm/speech.mjs +6 -16
- package/esm/speech.mjs.map +1 -1
- package/esm/transcription.d.mts +6 -3
- package/esm/transcription.d.mts.map +1 -1
- package/esm/transcription.mjs +6 -13
- package/esm/transcription.mjs.map +1 -1
- package/llms-full.txt +1 -1
- package/package.json +3 -3
- package/skills/setup-openai/SKILL.md +1 -1
- package/esm/known-image-models.d.mts +0 -30
- package/esm/known-image-models.d.mts.map +0 -1
- package/esm/known-image-models.mjs +0 -33
- package/esm/known-image-models.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,17 @@ All notable changes to `@warlock.js/ai-openai` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
|
|
6
6
|
|
|
7
|
+
## 4.13.0
|
|
8
|
+
|
|
9
|
+
### Removed
|
|
10
|
+
|
|
11
|
+
- **BREAKING** — `isOpenAIImageModel()` and `OPENAI_IMAGE_MODEL_PREFIXES` are no longer exported; the `known-image-models` module is deleted. Nothing in the adapter read them once the construction-time gate went away, so they were a public list of model ids that enforced nothing and went stale on OpenAI's release schedule, not this package's. Import them from nowhere — branch on your own id list if you need one.
|
|
12
|
+
- **BREAKING** — `isOpenAISpeechModel()` and `isOpenAITranscriptionModel()` are no longer exported either, for the same reason. Once their construction-time gates went away nothing in the adapter read them, leaving two more public model-id lists that enforced nothing. No `@warlock.js/ai-*` adapter validates a model id locally, so the package no longer ships a helper that implies otherwise — branch on your own id list if you need one.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- `openai.image({ name })`, `openai.speech({ name })` and `openai.transcribe({ name })` no longer reject an unknown model id at construction — the id is forwarded to OpenAI as given, so an id OpenAI does not serve now fails as a typed provider error instead of a local `InvalidRequestError`.
|
|
17
|
+
|
|
7
18
|
## 4.12.0
|
|
8
19
|
|
|
9
20
|
### Changed
|
package/cjs/index.cjs
CHANGED
|
@@ -451,37 +451,6 @@ var OpenAIEmbedder = class {
|
|
|
451
451
|
}
|
|
452
452
|
};
|
|
453
453
|
|
|
454
|
-
//#endregion
|
|
455
|
-
//#region ../ai-openai/src/known-image-models.ts
|
|
456
|
-
/**
|
|
457
|
-
* Model-id prefixes OpenAI exposes through the **Images** API
|
|
458
|
-
* (`client.images.generate`). The two live families:
|
|
459
|
-
*
|
|
460
|
-
* - `gpt-image-*` — token-metered, always returns base64 bytes (no
|
|
461
|
-
* `response_format` knob), supports `output_format` + `background`.
|
|
462
|
-
* - `dall-e-*` — per-image-metered, returns a URL or base64 via
|
|
463
|
-
* `response_format`.
|
|
464
|
-
*
|
|
465
|
-
* Used by {@link isOpenAIImageModel} for the construction-time guard so
|
|
466
|
-
* `openai.image({ name: "gpt-4o" })` fails fast with a curated error
|
|
467
|
-
* instead of a downstream 400 — mirroring the embedder/vision guards.
|
|
468
|
-
*/
|
|
469
|
-
const OPENAI_IMAGE_MODEL_PREFIXES = ["gpt-image", "dall-e"];
|
|
470
|
-
/**
|
|
471
|
-
* True when `name` is a recognized OpenAI image-generation model. A
|
|
472
|
-
* prefix match (not an exact list) so dated snapshots
|
|
473
|
-
* (`gpt-image-1-mini`, `dall-e-3`) are covered without a maintenance
|
|
474
|
-
* burden every time OpenAI ships a point release.
|
|
475
|
-
*
|
|
476
|
-
* @example
|
|
477
|
-
* isOpenAIImageModel("gpt-image-1"); // true
|
|
478
|
-
* isOpenAIImageModel("dall-e-3"); // true
|
|
479
|
-
* isOpenAIImageModel("gpt-4o"); // false
|
|
480
|
-
*/
|
|
481
|
-
function isOpenAIImageModel(name) {
|
|
482
|
-
return OPENAI_IMAGE_MODEL_PREFIXES.some((prefix) => name.startsWith(prefix));
|
|
483
|
-
}
|
|
484
|
-
|
|
485
454
|
//#endregion
|
|
486
455
|
//#region ../ai-openai/src/image.ts
|
|
487
456
|
const LOG_MODULE$3 = "ai.openai";
|
|
@@ -498,17 +467,19 @@ function mediaTypeFor(format) {
|
|
|
498
467
|
* OpenAI-backed implementation of `ImageModelContract`.
|
|
499
468
|
*
|
|
500
469
|
* **Role.** Bridges the vendor-neutral `ai.image()` verb to OpenAI's
|
|
501
|
-
* **Images** API
|
|
470
|
+
* **Images** API. Metering follows the family the id belongs to: the
|
|
502
471
|
* token-metered `gpt-image-*` models (always return base64 bytes) and
|
|
503
472
|
* the per-image-metered `dall-e-*` models (URL or base64). Like
|
|
504
473
|
* `OpenAIEmbedder`, it's a standalone primitive — no relationship to
|
|
505
474
|
* chat completions, tools, or the agent loop.
|
|
506
475
|
*
|
|
507
|
-
* **
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
*
|
|
511
|
-
*
|
|
476
|
+
* **No model-id validation.** `config.name` is forwarded to
|
|
477
|
+
* `client.images.generate` exactly as given — the constructor never
|
|
478
|
+
* inspects it. OpenAI adds and retires image model ids on its own
|
|
479
|
+
* schedule, so an id this adapter does not recognize is not the
|
|
480
|
+
* adapter's call to refuse; an unsupported id surfaces as a provider
|
|
481
|
+
* error from OpenAI (wrapped into the typed `AIError` hierarchy by
|
|
482
|
+
* `generate()`), not as a local one.
|
|
512
483
|
*
|
|
513
484
|
* **Error handling.** Raw OpenAI SDK errors are wrapped into the typed
|
|
514
485
|
* `@warlock.js/ai` `AIError` hierarchy via `wrapOpenAIError`, so a
|
|
@@ -523,7 +494,6 @@ function mediaTypeFor(format) {
|
|
|
523
494
|
var OpenAIImageModel = class {
|
|
524
495
|
constructor(client, config, provider = "openai") {
|
|
525
496
|
this.logger = _warlock_js_logger.log;
|
|
526
|
-
if (!isOpenAIImageModel(config.name)) throw new _warlock_js_ai.InvalidRequestError(`"${config.name}" is not a known OpenAI image-generation model. Use a \`gpt-image-*\` or \`dall-e-*\` model with openai.image({ name }).`);
|
|
527
497
|
this.client = client;
|
|
528
498
|
this.name = config.name;
|
|
529
499
|
this.provider = provider;
|
|
@@ -1070,16 +1040,6 @@ var OpenAIModel = class {
|
|
|
1070
1040
|
//#endregion
|
|
1071
1041
|
//#region ../ai-openai/src/speech.ts
|
|
1072
1042
|
const LOG_MODULE$1 = "ai.openai";
|
|
1073
|
-
/** Model-id prefixes OpenAI exposes through the **Speech** (TTS) API. */
|
|
1074
|
-
const SPEECH_MODEL_PREFIXES = [
|
|
1075
|
-
"tts-1",
|
|
1076
|
-
"gpt-4o-mini-tts",
|
|
1077
|
-
"gpt-audio"
|
|
1078
|
-
];
|
|
1079
|
-
/** True when `name` is a recognized OpenAI text-to-speech model. */
|
|
1080
|
-
function isOpenAISpeechModel(name) {
|
|
1081
|
-
return SPEECH_MODEL_PREFIXES.some((prefix) => name.startsWith(prefix));
|
|
1082
|
-
}
|
|
1083
1043
|
/** Map a neutral output container hint to its IANA audio media type. */
|
|
1084
1044
|
function audioMediaType(format) {
|
|
1085
1045
|
switch (format) {
|
|
@@ -1096,9 +1056,11 @@ function audioMediaType(format) {
|
|
|
1096
1056
|
* via `audio.speech.create`. Standalone primitive — no relation to chat
|
|
1097
1057
|
* completions or the agent loop. Consumed by the `ai.speech()` verb.
|
|
1098
1058
|
*
|
|
1099
|
-
* **
|
|
1100
|
-
*
|
|
1101
|
-
*
|
|
1059
|
+
* **No model-id validation.** `config.name` is forwarded to
|
|
1060
|
+
* `audio.speech.create` exactly as given — the constructor never
|
|
1061
|
+
* inspects it. OpenAI ships and retires TTS model ids on its own
|
|
1062
|
+
* schedule, so an unrecognized id fails at OpenAI (wrapped into the
|
|
1063
|
+
* typed `AIError` hierarchy by `generate()`), not here.
|
|
1102
1064
|
*
|
|
1103
1065
|
* @example
|
|
1104
1066
|
* const tts = new OpenAISpeechModel(client, { name: "tts-1", voice: "alloy" }, "openai");
|
|
@@ -1107,7 +1069,6 @@ function audioMediaType(format) {
|
|
|
1107
1069
|
var OpenAISpeechModel = class {
|
|
1108
1070
|
constructor(client, config, provider = "openai") {
|
|
1109
1071
|
this.logger = _warlock_js_logger.log;
|
|
1110
|
-
if (!isOpenAISpeechModel(config.name)) throw new _warlock_js_ai.InvalidRequestError(`"${config.name}" is not a known OpenAI text-to-speech model. Use a \`tts-1\` / \`tts-1-hd\` / \`gpt-4o-mini-tts\` model with openai.speech({ name }).`);
|
|
1111
1072
|
this.client = client;
|
|
1112
1073
|
this.name = config.name;
|
|
1113
1074
|
this.provider = provider;
|
|
@@ -1157,21 +1118,16 @@ var OpenAISpeechModel = class {
|
|
|
1157
1118
|
//#endregion
|
|
1158
1119
|
//#region ../ai-openai/src/transcription.ts
|
|
1159
1120
|
const LOG_MODULE = "ai.openai";
|
|
1160
|
-
/** Model-id prefixes OpenAI exposes through the **Transcription** (STT) API. */
|
|
1161
|
-
const TRANSCRIPTION_MODEL_PREFIXES = [
|
|
1162
|
-
"whisper",
|
|
1163
|
-
"gpt-4o-transcribe",
|
|
1164
|
-
"gpt-4o-mini-transcribe"
|
|
1165
|
-
];
|
|
1166
|
-
/** True when `name` is a recognized OpenAI speech-to-text model. */
|
|
1167
|
-
function isOpenAITranscriptionModel(name) {
|
|
1168
|
-
return TRANSCRIPTION_MODEL_PREFIXES.some((prefix) => name.startsWith(prefix));
|
|
1169
|
-
}
|
|
1170
1121
|
/**
|
|
1171
1122
|
* OpenAI-backed implementation of `TranscriptionModelContract`
|
|
1172
1123
|
* (speech-to-text) via `audio.transcriptions.create`. Consumed by the
|
|
1173
1124
|
* `ai.transcribe()` verb.
|
|
1174
1125
|
*
|
|
1126
|
+
* **No model-id validation.** `config.name` is forwarded to
|
|
1127
|
+
* `audio.transcriptions.create` exactly as given — the constructor
|
|
1128
|
+
* never inspects it. An unrecognized id fails at OpenAI (wrapped into
|
|
1129
|
+
* the typed `AIError` hierarchy by `transcribe()`), not here.
|
|
1130
|
+
*
|
|
1175
1131
|
* **Response format.** Defaults to `verbose_json` for `whisper-1` (so
|
|
1176
1132
|
* the run gets a `duration` + timestamped `segments`) and `json` for
|
|
1177
1133
|
* the token-metered `gpt-4o-transcribe` family. Base64 audio is wrapped
|
|
@@ -1184,7 +1140,6 @@ function isOpenAITranscriptionModel(name) {
|
|
|
1184
1140
|
var OpenAITranscriptionModel = class {
|
|
1185
1141
|
constructor(client, config, provider = "openai") {
|
|
1186
1142
|
this.logger = _warlock_js_logger.log;
|
|
1187
|
-
if (!isOpenAITranscriptionModel(config.name)) throw new _warlock_js_ai.InvalidRequestError(`"${config.name}" is not a known OpenAI transcription model. Use a \`whisper-1\` / \`gpt-4o-transcribe\` / \`gpt-4o-mini-transcribe\` model with openai.transcribe({ name }).`);
|
|
1188
1143
|
this.client = client;
|
|
1189
1144
|
this.name = config.name;
|
|
1190
1145
|
this.provider = provider;
|
|
@@ -1328,9 +1283,10 @@ var OpenAISDK = class {
|
|
|
1328
1283
|
}
|
|
1329
1284
|
/**
|
|
1330
1285
|
* Build an `OpenAIImageModel` bound to this SDK's client for use with
|
|
1331
|
-
* `ai.image({ model, prompt })`.
|
|
1332
|
-
*
|
|
1333
|
-
*
|
|
1286
|
+
* `ai.image({ model, prompt })`. `config.name` is passed through to
|
|
1287
|
+
* `client.images.generate` as given — no id is rejected locally, so
|
|
1288
|
+
* an unsupported model fails at OpenAI, not here. Metering follows
|
|
1289
|
+
* the family: `gpt-image-*` is token-metered, `dall-e-*` per-image.
|
|
1334
1290
|
*
|
|
1335
1291
|
* Pricing resolution mirrors `model()`: per-model `config.pricing`
|
|
1336
1292
|
* wins, otherwise the SDK-level registry entry keyed by `config.name`,
|
|
@@ -1352,9 +1308,10 @@ var OpenAISDK = class {
|
|
|
1352
1308
|
}
|
|
1353
1309
|
/**
|
|
1354
1310
|
* Build an `OpenAISpeechModel` (text-to-speech) bound to this SDK's
|
|
1355
|
-
* client, for use with `ai.speech({ model, text })`.
|
|
1356
|
-
*
|
|
1357
|
-
* at
|
|
1311
|
+
* client, for use with `ai.speech({ model, text })`. `config.name` is
|
|
1312
|
+
* passed through to `audio.speech.create` as given — no id is
|
|
1313
|
+
* rejected locally, so an unsupported model fails at OpenAI, not
|
|
1314
|
+
* here.
|
|
1358
1315
|
*
|
|
1359
1316
|
* @example
|
|
1360
1317
|
* const tts = openai.speech({ name: "tts-1", voice: "alloy" });
|
|
@@ -1366,8 +1323,9 @@ var OpenAISDK = class {
|
|
|
1366
1323
|
/**
|
|
1367
1324
|
* Build an `OpenAITranscriptionModel` (speech-to-text) bound to this
|
|
1368
1325
|
* SDK's client, for use with `ai.transcribe({ model, audio })`.
|
|
1369
|
-
*
|
|
1370
|
-
*
|
|
1326
|
+
* `config.name` is passed through to `audio.transcriptions.create`
|
|
1327
|
+
* as given — no id is rejected locally, so an unsupported model
|
|
1328
|
+
* fails at OpenAI, not here.
|
|
1371
1329
|
*
|
|
1372
1330
|
* @example
|
|
1373
1331
|
* const stt = openai.transcribe({ name: "whisper-1" });
|
|
@@ -1379,13 +1337,9 @@ var OpenAISDK = class {
|
|
|
1379
1337
|
};
|
|
1380
1338
|
|
|
1381
1339
|
//#endregion
|
|
1382
|
-
exports.OPENAI_IMAGE_MODEL_PREFIXES = OPENAI_IMAGE_MODEL_PREFIXES;
|
|
1383
1340
|
exports.OpenAIEmbedder = OpenAIEmbedder;
|
|
1384
1341
|
exports.OpenAIImageModel = OpenAIImageModel;
|
|
1385
1342
|
exports.OpenAISDK = OpenAISDK;
|
|
1386
1343
|
exports.OpenAISpeechModel = OpenAISpeechModel;
|
|
1387
1344
|
exports.OpenAITranscriptionModel = OpenAITranscriptionModel;
|
|
1388
|
-
exports.isOpenAIImageModel = isOpenAIImageModel;
|
|
1389
|
-
exports.isOpenAISpeechModel = isOpenAISpeechModel;
|
|
1390
|
-
exports.isOpenAITranscriptionModel = isOpenAITranscriptionModel;
|
|
1391
1345
|
//# sourceMappingURL=index.cjs.map
|