@ai-sdk/openai-compatible 2.0.15 → 2.0.16
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 +6 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1540,6 +1540,19 @@ var OpenAICompatibleImageModel = class {
|
|
|
1540
1540
|
get provider() {
|
|
1541
1541
|
return this.config.provider;
|
|
1542
1542
|
}
|
|
1543
|
+
/**
|
|
1544
|
+
* The provider options key used to extract provider-specific options.
|
|
1545
|
+
*/
|
|
1546
|
+
get providerOptionsKey() {
|
|
1547
|
+
return this.config.provider.split(".")[0].trim();
|
|
1548
|
+
}
|
|
1549
|
+
// TODO: deprecate non-camelCase keys and remove in future major version
|
|
1550
|
+
getArgs(providerOptions) {
|
|
1551
|
+
return {
|
|
1552
|
+
...providerOptions[this.providerOptionsKey],
|
|
1553
|
+
...providerOptions[toCamelCase(this.providerOptionsKey)]
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1543
1556
|
async doGenerate({
|
|
1544
1557
|
prompt,
|
|
1545
1558
|
n,
|
|
@@ -1552,7 +1565,7 @@ var OpenAICompatibleImageModel = class {
|
|
|
1552
1565
|
files,
|
|
1553
1566
|
mask
|
|
1554
1567
|
}) {
|
|
1555
|
-
var _a, _b, _c, _d, _e
|
|
1568
|
+
var _a, _b, _c, _d, _e;
|
|
1556
1569
|
const warnings = [];
|
|
1557
1570
|
if (aspectRatio != null) {
|
|
1558
1571
|
warnings.push({
|
|
@@ -1565,6 +1578,7 @@ var OpenAICompatibleImageModel = class {
|
|
|
1565
1578
|
warnings.push({ type: "unsupported", feature: "seed" });
|
|
1566
1579
|
}
|
|
1567
1580
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1581
|
+
const args = this.getArgs(providerOptions);
|
|
1568
1582
|
if (files != null && files.length > 0) {
|
|
1569
1583
|
const { value: response2, responseHeaders: responseHeaders2 } = await postFormDataToApi({
|
|
1570
1584
|
url: this.config.url({
|
|
@@ -1579,10 +1593,10 @@ var OpenAICompatibleImageModel = class {
|
|
|
1579
1593
|
mask: mask != null ? await fileToBlob(mask) : void 0,
|
|
1580
1594
|
n,
|
|
1581
1595
|
size,
|
|
1582
|
-
...
|
|
1596
|
+
...args
|
|
1583
1597
|
}),
|
|
1584
1598
|
failedResponseHandler: createJsonErrorResponseHandler4(
|
|
1585
|
-
(
|
|
1599
|
+
(_d = this.config.errorStructure) != null ? _d : defaultOpenAICompatibleErrorStructure
|
|
1586
1600
|
),
|
|
1587
1601
|
successfulResponseHandler: createJsonResponseHandler4(
|
|
1588
1602
|
openaiCompatibleImageResponseSchema
|
|
@@ -1611,11 +1625,11 @@ var OpenAICompatibleImageModel = class {
|
|
|
1611
1625
|
prompt,
|
|
1612
1626
|
n,
|
|
1613
1627
|
size,
|
|
1614
|
-
...
|
|
1628
|
+
...args,
|
|
1615
1629
|
response_format: "b64_json"
|
|
1616
1630
|
},
|
|
1617
1631
|
failedResponseHandler: createJsonErrorResponseHandler4(
|
|
1618
|
-
(
|
|
1632
|
+
(_e = this.config.errorStructure) != null ? _e : defaultOpenAICompatibleErrorStructure
|
|
1619
1633
|
),
|
|
1620
1634
|
successfulResponseHandler: createJsonResponseHandler4(
|
|
1621
1635
|
openaiCompatibleImageResponseSchema
|
|
@@ -1644,6 +1658,9 @@ async function fileToBlob(file) {
|
|
|
1644
1658
|
const data = file.data instanceof Uint8Array ? file.data : convertBase64ToUint8Array(file.data);
|
|
1645
1659
|
return new Blob([data], { type: file.mediaType });
|
|
1646
1660
|
}
|
|
1661
|
+
function toCamelCase(str) {
|
|
1662
|
+
return str.replace(/[_-]([a-z])/g, (g) => g[1].toUpperCase());
|
|
1663
|
+
}
|
|
1647
1664
|
|
|
1648
1665
|
// src/openai-compatible-provider.ts
|
|
1649
1666
|
import {
|
|
@@ -1652,7 +1669,7 @@ import {
|
|
|
1652
1669
|
} from "@ai-sdk/provider-utils";
|
|
1653
1670
|
|
|
1654
1671
|
// src/version.ts
|
|
1655
|
-
var VERSION = true ? "2.0.
|
|
1672
|
+
var VERSION = true ? "2.0.16" : "0.0.0-test";
|
|
1656
1673
|
|
|
1657
1674
|
// src/openai-compatible-provider.ts
|
|
1658
1675
|
function createOpenAICompatible(options) {
|