@ai-sdk/openai 4.0.0-beta.22 → 4.0.0-beta.25
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 +25 -0
- package/dist/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +112 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +116 -16
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +20 -14
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +24 -15
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/openai-provider.ts +16 -1
- package/src/responses/openai-responses-prepare-tools.ts +13 -5
- package/src/skills/openai-skills-api.ts +31 -0
- package/src/skills/openai-skills.ts +87 -0
- package/src/tool/shell.ts +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.25
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 34bd95d: feat(ai): add support for uploading provider skills using the provider references abstraction
|
|
8
|
+
- Updated dependencies [34bd95d]
|
|
9
|
+
- Updated dependencies [008271d]
|
|
10
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
11
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
12
|
+
|
|
13
|
+
## 4.0.0-beta.24
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [b0c2869]
|
|
18
|
+
- Updated dependencies [7e26e81]
|
|
19
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
20
|
+
|
|
21
|
+
## 4.0.0-beta.23
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [46d1149]
|
|
26
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
27
|
+
|
|
3
28
|
## 4.0.0-beta.22
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
|
-
import { JSONValue, ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, TranscriptionModelV4, SpeechModelV4, FilesV4 } from '@ai-sdk/provider';
|
|
2
|
+
import { JSONValue, ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, TranscriptionModelV4, SpeechModelV4, FilesV4, SkillsV4 } from '@ai-sdk/provider';
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
4
|
import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
5
|
|
|
@@ -853,7 +853,7 @@ declare const openaiTools: {
|
|
|
853
853
|
};
|
|
854
854
|
skills?: Array<{
|
|
855
855
|
type: "skillReference";
|
|
856
|
-
|
|
856
|
+
providerReference: _ai_sdk_provider.SharedV4ProviderReference;
|
|
857
857
|
version?: string;
|
|
858
858
|
} | {
|
|
859
859
|
type: "inline";
|
|
@@ -1098,6 +1098,10 @@ interface OpenAIProvider extends ProviderV4 {
|
|
|
1098
1098
|
* Returns a FilesV4 interface for uploading files to OpenAI.
|
|
1099
1099
|
*/
|
|
1100
1100
|
files(): FilesV4;
|
|
1101
|
+
/**
|
|
1102
|
+
* Returns a SkillsV4 interface for uploading skills to OpenAI.
|
|
1103
|
+
*/
|
|
1104
|
+
skills(): SkillsV4;
|
|
1101
1105
|
/**
|
|
1102
1106
|
* OpenAI-specific tools.
|
|
1103
1107
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
|
-
import { JSONValue, ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, TranscriptionModelV4, SpeechModelV4, FilesV4 } from '@ai-sdk/provider';
|
|
2
|
+
import { JSONValue, ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, TranscriptionModelV4, SpeechModelV4, FilesV4, SkillsV4 } from '@ai-sdk/provider';
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
4
|
import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
5
|
|
|
@@ -853,7 +853,7 @@ declare const openaiTools: {
|
|
|
853
853
|
};
|
|
854
854
|
skills?: Array<{
|
|
855
855
|
type: "skillReference";
|
|
856
|
-
|
|
856
|
+
providerReference: _ai_sdk_provider.SharedV4ProviderReference;
|
|
857
857
|
version?: string;
|
|
858
858
|
} | {
|
|
859
859
|
type: "inline";
|
|
@@ -1098,6 +1098,10 @@ interface OpenAIProvider extends ProviderV4 {
|
|
|
1098
1098
|
* Returns a FilesV4 interface for uploading files to OpenAI.
|
|
1099
1099
|
*/
|
|
1100
1100
|
files(): FilesV4;
|
|
1101
|
+
/**
|
|
1102
|
+
* Returns a SkillsV4 interface for uploading skills to OpenAI.
|
|
1103
|
+
*/
|
|
1104
|
+
skills(): SkillsV4;
|
|
1101
1105
|
/**
|
|
1102
1106
|
* OpenAI-specific tools.
|
|
1103
1107
|
*/
|
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ __export(index_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
|
|
29
29
|
// src/openai-provider.ts
|
|
30
|
-
var
|
|
30
|
+
var import_provider_utils40 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/chat/openai-chat-language-model.ts
|
|
33
33
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -2328,7 +2328,7 @@ var shellSkillsSchema = import_v417.z.array(
|
|
|
2328
2328
|
import_v417.z.discriminatedUnion("type", [
|
|
2329
2329
|
import_v417.z.object({
|
|
2330
2330
|
type: import_v417.z.literal("skillReference"),
|
|
2331
|
-
|
|
2331
|
+
providerReference: import_v417.z.record(import_v417.z.string(), import_v417.z.string()),
|
|
2332
2332
|
version: import_v417.z.string().optional()
|
|
2333
2333
|
}),
|
|
2334
2334
|
import_v417.z.object({
|
|
@@ -4761,19 +4761,25 @@ function mapShellEnvironment(environment) {
|
|
|
4761
4761
|
}
|
|
4762
4762
|
function mapShellSkills(skills) {
|
|
4763
4763
|
return skills == null ? void 0 : skills.map(
|
|
4764
|
-
(skill) =>
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4764
|
+
(skill) => {
|
|
4765
|
+
var _a, _b;
|
|
4766
|
+
return skill.type === "skillReference" ? {
|
|
4767
|
+
type: "skill_reference",
|
|
4768
|
+
skill_id: (0, import_provider_utils31.resolveProviderReference)({
|
|
4769
|
+
reference: (_a = skill.providerReference) != null ? _a : {},
|
|
4770
|
+
provider: "openai"
|
|
4771
|
+
}),
|
|
4772
|
+
version: (_b = skill.version) != null ? _b : "latest"
|
|
4773
|
+
} : {
|
|
4774
|
+
type: "inline",
|
|
4775
|
+
name: skill.name,
|
|
4776
|
+
description: skill.description,
|
|
4777
|
+
source: {
|
|
4778
|
+
type: "base64",
|
|
4779
|
+
media_type: skill.source.mediaType,
|
|
4780
|
+
data: skill.source.data
|
|
4781
|
+
}
|
|
4782
|
+
};
|
|
4777
4783
|
}
|
|
4778
4784
|
);
|
|
4779
4785
|
}
|
|
@@ -6855,22 +6861,101 @@ var OpenAITranscriptionModel = class {
|
|
|
6855
6861
|
}
|
|
6856
6862
|
};
|
|
6857
6863
|
|
|
6864
|
+
// src/skills/openai-skills.ts
|
|
6865
|
+
var import_provider_utils39 = require("@ai-sdk/provider-utils");
|
|
6866
|
+
|
|
6867
|
+
// src/skills/openai-skills-api.ts
|
|
6868
|
+
var import_provider_utils38 = require("@ai-sdk/provider-utils");
|
|
6869
|
+
var import_v428 = require("zod/v4");
|
|
6870
|
+
var openaiSkillResponseSchema = (0, import_provider_utils38.lazySchema)(
|
|
6871
|
+
() => (0, import_provider_utils38.zodSchema)(
|
|
6872
|
+
import_v428.z.object({
|
|
6873
|
+
id: import_v428.z.string(),
|
|
6874
|
+
name: import_v428.z.string().nullish(),
|
|
6875
|
+
description: import_v428.z.string().nullish(),
|
|
6876
|
+
default_version: import_v428.z.string().nullish(),
|
|
6877
|
+
latest_version: import_v428.z.string().nullish(),
|
|
6878
|
+
created_at: import_v428.z.number(),
|
|
6879
|
+
updated_at: import_v428.z.number().nullish()
|
|
6880
|
+
})
|
|
6881
|
+
)
|
|
6882
|
+
);
|
|
6883
|
+
var openaiSkillVersionResponseSchema = (0, import_provider_utils38.lazySchema)(
|
|
6884
|
+
() => (0, import_provider_utils38.zodSchema)(
|
|
6885
|
+
import_v428.z.object({
|
|
6886
|
+
id: import_v428.z.string(),
|
|
6887
|
+
version: import_v428.z.string().nullish(),
|
|
6888
|
+
name: import_v428.z.string().nullish(),
|
|
6889
|
+
description: import_v428.z.string().nullish()
|
|
6890
|
+
})
|
|
6891
|
+
)
|
|
6892
|
+
);
|
|
6893
|
+
|
|
6894
|
+
// src/skills/openai-skills.ts
|
|
6895
|
+
var OpenAISkills = class {
|
|
6896
|
+
constructor(config) {
|
|
6897
|
+
this.config = config;
|
|
6898
|
+
this.specificationVersion = "v4";
|
|
6899
|
+
}
|
|
6900
|
+
get provider() {
|
|
6901
|
+
return this.config.provider;
|
|
6902
|
+
}
|
|
6903
|
+
async upload(params) {
|
|
6904
|
+
const warnings = [];
|
|
6905
|
+
if (params.displayTitle != null) {
|
|
6906
|
+
warnings.push({
|
|
6907
|
+
type: "unsupported",
|
|
6908
|
+
feature: "displayTitle"
|
|
6909
|
+
});
|
|
6910
|
+
}
|
|
6911
|
+
const formData = new FormData();
|
|
6912
|
+
for (const file of params.files) {
|
|
6913
|
+
const content = typeof file.content === "string" ? (0, import_provider_utils39.convertBase64ToUint8Array)(file.content) : file.content;
|
|
6914
|
+
formData.append("files[]", new Blob([content]), file.path);
|
|
6915
|
+
}
|
|
6916
|
+
const { value: response } = await (0, import_provider_utils39.postFormDataToApi)({
|
|
6917
|
+
url: this.config.url({ path: "/skills" }),
|
|
6918
|
+
headers: (0, import_provider_utils39.combineHeaders)(this.config.headers()),
|
|
6919
|
+
formData,
|
|
6920
|
+
failedResponseHandler: openaiFailedResponseHandler,
|
|
6921
|
+
successfulResponseHandler: (0, import_provider_utils39.createJsonResponseHandler)(
|
|
6922
|
+
openaiSkillResponseSchema
|
|
6923
|
+
),
|
|
6924
|
+
fetch: this.config.fetch
|
|
6925
|
+
});
|
|
6926
|
+
return {
|
|
6927
|
+
providerReference: { openai: response.id },
|
|
6928
|
+
...response.name != null ? { name: response.name } : {},
|
|
6929
|
+
...response.description != null ? { description: response.description } : {},
|
|
6930
|
+
...response.latest_version != null ? { latestVersion: response.latest_version } : {},
|
|
6931
|
+
providerMetadata: {
|
|
6932
|
+
openai: {
|
|
6933
|
+
...response.default_version != null ? { defaultVersion: response.default_version } : {},
|
|
6934
|
+
...response.created_at != null ? { createdAt: response.created_at } : {},
|
|
6935
|
+
...response.updated_at != null ? { updatedAt: response.updated_at } : {}
|
|
6936
|
+
}
|
|
6937
|
+
},
|
|
6938
|
+
warnings
|
|
6939
|
+
};
|
|
6940
|
+
}
|
|
6941
|
+
};
|
|
6942
|
+
|
|
6858
6943
|
// src/version.ts
|
|
6859
|
-
var VERSION = true ? "4.0.0-beta.
|
|
6944
|
+
var VERSION = true ? "4.0.0-beta.25" : "0.0.0-test";
|
|
6860
6945
|
|
|
6861
6946
|
// src/openai-provider.ts
|
|
6862
6947
|
function createOpenAI(options = {}) {
|
|
6863
6948
|
var _a, _b;
|
|
6864
|
-
const baseURL = (_a = (0,
|
|
6865
|
-
(0,
|
|
6949
|
+
const baseURL = (_a = (0, import_provider_utils40.withoutTrailingSlash)(
|
|
6950
|
+
(0, import_provider_utils40.loadOptionalSetting)({
|
|
6866
6951
|
settingValue: options.baseURL,
|
|
6867
6952
|
environmentVariableName: "OPENAI_BASE_URL"
|
|
6868
6953
|
})
|
|
6869
6954
|
)) != null ? _a : "https://api.openai.com/v1";
|
|
6870
6955
|
const providerName = (_b = options.name) != null ? _b : "openai";
|
|
6871
|
-
const getHeaders = () => (0,
|
|
6956
|
+
const getHeaders = () => (0, import_provider_utils40.withUserAgentSuffix)(
|
|
6872
6957
|
{
|
|
6873
|
-
Authorization: `Bearer ${(0,
|
|
6958
|
+
Authorization: `Bearer ${(0, import_provider_utils40.loadApiKey)({
|
|
6874
6959
|
apiKey: options.apiKey,
|
|
6875
6960
|
environmentVariableName: "OPENAI_API_KEY",
|
|
6876
6961
|
description: "OpenAI"
|
|
@@ -6923,6 +7008,12 @@ function createOpenAI(options = {}) {
|
|
|
6923
7008
|
headers: getHeaders,
|
|
6924
7009
|
fetch: options.fetch
|
|
6925
7010
|
});
|
|
7011
|
+
const createSkills = () => new OpenAISkills({
|
|
7012
|
+
provider: `${providerName}.skills`,
|
|
7013
|
+
url: ({ path }) => `${baseURL}${path}`,
|
|
7014
|
+
headers: getHeaders,
|
|
7015
|
+
fetch: options.fetch
|
|
7016
|
+
});
|
|
6926
7017
|
const createLanguageModel = (modelId) => {
|
|
6927
7018
|
if (new.target) {
|
|
6928
7019
|
throw new Error(
|
|
@@ -6960,6 +7051,7 @@ function createOpenAI(options = {}) {
|
|
|
6960
7051
|
provider.speech = createSpeechModel;
|
|
6961
7052
|
provider.speechModel = createSpeechModel;
|
|
6962
7053
|
provider.files = createFiles;
|
|
7054
|
+
provider.skills = createSkills;
|
|
6963
7055
|
provider.tools = openaiTools;
|
|
6964
7056
|
return provider;
|
|
6965
7057
|
}
|