@umituz/web-ai 1.0.6 → 1.0.8
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/dist/{AIErrors-CLjXRty-.d.ts → AIErrors-CSk4nvN1.d.ts} +1 -1
- package/dist/{AIErrors-DjZXUiLT.d.cts → AIErrors-Dq9o95R_.d.cts} +1 -1
- package/dist/{cancellation-error-CkMn5Kft.d.ts → cancellation-error-Ci8fQhNF.d.ts} +3 -3
- package/dist/{cancellation-error-Cj7fJyCg.d.cts → cancellation-error-CpkPd67D.d.cts} +3 -3
- package/dist/chat/index.d.cts +4 -4
- package/dist/chat/index.d.ts +4 -4
- package/dist/{chat.service-9M-KpLo-.d.cts → chat.service-BRtiA7H9.d.cts} +2 -2
- package/dist/{chat.service-B4FLFxR1.d.ts → chat.service-Cqga2h1e.d.ts} +2 -2
- package/dist/content/index.d.cts +7 -7
- package/dist/content/index.d.ts +7 -7
- package/dist/core/index.cjs +815 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +418 -4
- package/dist/core/index.d.ts +418 -4
- package/dist/core/index.js +747 -1
- package/dist/core/index.js.map +1 -1
- package/dist/{create-ai-0eZFFqTw.d.ts → create-ai-DW7eHMBF.d.ts} +3 -3
- package/dist/{create-ai-BrKR_5fQ.d.cts → create-ai-DeOpUgZ-.d.cts} +3 -3
- package/dist/hooks/index.d.cts +9 -9
- package/dist/hooks/index.d.ts +9 -9
- package/dist/{index-DIHz8_OJ.d.ts → index-Ca5o4gBK.d.ts} +1 -1
- package/dist/{index-fXjxTR5W.d.cts → index-DDzvTDg0.d.cts} +1 -1
- package/dist/{index-fXjxTR5W.d.ts → index-DDzvTDg0.d.ts} +1 -1
- package/dist/{index-DKHNcMbl.d.cts → index-itgxPeLz.d.cts} +1 -1
- package/dist/index.cjs +1011 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +934 -15
- package/dist/index.js.map +1 -1
- package/dist/{provider.factory-BwPnqSEU.d.ts → provider.factory-CJuI08Xr.d.ts} +1 -1
- package/dist/{provider.factory-DyfJtR8M.d.cts → provider.factory-DG2CYFgh.d.cts} +1 -1
- package/dist/providers/index.cjs +196 -0
- package/dist/providers/index.cjs.map +1 -1
- package/dist/providers/index.d.cts +79 -10
- package/dist/providers/index.d.ts +79 -10
- package/dist/providers/index.js +188 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/{requestQueue-CvxWxC-z.d.ts → requestQueue-D-RCbxuR.d.ts} +4 -4
- package/dist/{requestQueue-CkJ6Xc9K.d.cts → requestQueue-O6f8VBl5.d.cts} +4 -4
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as ProviderHealth, T as TextRequest, G as GenerationResult,
|
|
1
|
+
import { P as ProviderHealth, T as TextRequest, G as GenerationResult, a as StructuredTextRequest, S as StructuredGeneration, d as StreamCallbacks, b as TextTier } from './index-DDzvTDg0.js';
|
|
2
2
|
import { T as TextGenerationRequest, I as ImageGenerationRequest, V as VideoGenerationRequest, G as GeneratedContent, a as ImageToVideoRequest, b as VideoToVideoRequest } from './ProviderConfig-DIFa9nmG.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as ProviderHealth, T as TextRequest, G as GenerationResult,
|
|
1
|
+
import { P as ProviderHealth, T as TextRequest, G as GenerationResult, a as StructuredTextRequest, S as StructuredGeneration, d as StreamCallbacks, b as TextTier } from './index-DDzvTDg0.cjs';
|
|
2
2
|
import { T as TextGenerationRequest, I as ImageGenerationRequest, V as VideoGenerationRequest, G as GeneratedContent, a as ImageToVideoRequest, b as VideoToVideoRequest } from './ProviderConfig-DIFa9nmG.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/providers/index.cjs
CHANGED
|
@@ -3976,6 +3976,193 @@ function resetProvider() {
|
|
|
3976
3976
|
container = null;
|
|
3977
3977
|
}
|
|
3978
3978
|
|
|
3979
|
+
// src/providers/embeddings/openai-embeddings.ts
|
|
3980
|
+
var DEFAULT_EMBED_TIMEOUT_MS = 6e4;
|
|
3981
|
+
function createOpenAiEmbeddingsAdapter(config) {
|
|
3982
|
+
return {
|
|
3983
|
+
async embed(req) {
|
|
3984
|
+
const response = await fetch(`${config.baseUrl}/embeddings`, {
|
|
3985
|
+
method: "POST",
|
|
3986
|
+
headers: {
|
|
3987
|
+
Authorization: `Bearer ${config.apiKey}`,
|
|
3988
|
+
"Content-Type": "application/json"
|
|
3989
|
+
},
|
|
3990
|
+
body: JSON.stringify({ model: req.externalModelId, input: req.input }),
|
|
3991
|
+
signal: AbortSignal.timeout(config.timeoutMs ?? DEFAULT_EMBED_TIMEOUT_MS)
|
|
3992
|
+
});
|
|
3993
|
+
if (!response.ok) {
|
|
3994
|
+
let detail;
|
|
3995
|
+
try {
|
|
3996
|
+
const parsed2 = await response.json();
|
|
3997
|
+
detail = typeof parsed2.error?.message === "string" ? parsed2.error.message : void 0;
|
|
3998
|
+
} catch {
|
|
3999
|
+
detail = void 0;
|
|
4000
|
+
}
|
|
4001
|
+
throw new Error(detail ?? `Embeddings upstream failed with HTTP ${response.status}`);
|
|
4002
|
+
}
|
|
4003
|
+
const parsed = await response.json();
|
|
4004
|
+
const items = Array.isArray(parsed.data) ? parsed.data : [];
|
|
4005
|
+
const byIndex = /* @__PURE__ */ new Map();
|
|
4006
|
+
for (const item of items) {
|
|
4007
|
+
if (typeof item.index !== "number" || !Array.isArray(item.embedding)) continue;
|
|
4008
|
+
byIndex.set(item.index, item.embedding);
|
|
4009
|
+
}
|
|
4010
|
+
const vectors = [];
|
|
4011
|
+
for (let i = 0; i < req.input.length; i += 1) {
|
|
4012
|
+
const vector = byIndex.get(i);
|
|
4013
|
+
if (!vector) throw new Error("Provider returned an incomplete embeddings batch");
|
|
4014
|
+
vectors.push(vector);
|
|
4015
|
+
}
|
|
4016
|
+
const inputTokens = typeof parsed.usage?.prompt_tokens === "number" ? parsed.usage.prompt_tokens : null;
|
|
4017
|
+
return { vectors, inputTokens };
|
|
4018
|
+
}
|
|
4019
|
+
};
|
|
4020
|
+
}
|
|
4021
|
+
|
|
4022
|
+
// src/providers/audio/audio-transcription.ts
|
|
4023
|
+
function createOpenAiAudioTranscriptionAdapter(config) {
|
|
4024
|
+
return {
|
|
4025
|
+
async transcribe(req) {
|
|
4026
|
+
const form = new FormData();
|
|
4027
|
+
form.append("file", new Blob([req.audio], { type: req.mimeType }), req.name);
|
|
4028
|
+
form.append("model", req.externalModelId);
|
|
4029
|
+
form.append("response_format", "json");
|
|
4030
|
+
const response = await fetch(`${config.baseUrl}/audio/transcriptions`, {
|
|
4031
|
+
method: "POST",
|
|
4032
|
+
headers: { Authorization: `Bearer ${config.apiKey}` },
|
|
4033
|
+
body: form,
|
|
4034
|
+
signal: AbortSignal.timeout(config.timeoutMs ?? 6e4)
|
|
4035
|
+
});
|
|
4036
|
+
if (!response.ok) {
|
|
4037
|
+
let detail;
|
|
4038
|
+
try {
|
|
4039
|
+
const body2 = await response.json();
|
|
4040
|
+
detail = body2.error?.message;
|
|
4041
|
+
} catch {
|
|
4042
|
+
detail = void 0;
|
|
4043
|
+
}
|
|
4044
|
+
throw new Error(detail ?? `Audio transcription failed with HTTP ${response.status}`);
|
|
4045
|
+
}
|
|
4046
|
+
let body;
|
|
4047
|
+
try {
|
|
4048
|
+
body = await response.json();
|
|
4049
|
+
} catch {
|
|
4050
|
+
throw new Error("Transcription response was not valid JSON");
|
|
4051
|
+
}
|
|
4052
|
+
const text = (body.text ?? "").trim();
|
|
4053
|
+
if (text.length === 0) throw new Error("Transcription returned no text");
|
|
4054
|
+
return { text };
|
|
4055
|
+
}
|
|
4056
|
+
};
|
|
4057
|
+
}
|
|
4058
|
+
|
|
4059
|
+
// src/providers/audio/speech-synthesis.ts
|
|
4060
|
+
var SPEECH_VOICES = [
|
|
4061
|
+
"tara",
|
|
4062
|
+
"leah",
|
|
4063
|
+
"jess",
|
|
4064
|
+
"julian",
|
|
4065
|
+
"annie",
|
|
4066
|
+
"steve",
|
|
4067
|
+
"zac",
|
|
4068
|
+
"bella"
|
|
4069
|
+
];
|
|
4070
|
+
var SPEECH_INPUT_MAX = 4e3;
|
|
4071
|
+
function createOpenAiSpeechAdapter(config) {
|
|
4072
|
+
return {
|
|
4073
|
+
async speak(req) {
|
|
4074
|
+
const response = await fetch(`${config.baseUrl}/audio/speech`, {
|
|
4075
|
+
method: "POST",
|
|
4076
|
+
headers: {
|
|
4077
|
+
Authorization: `Bearer ${config.apiKey}`,
|
|
4078
|
+
"Content-Type": "application/json"
|
|
4079
|
+
},
|
|
4080
|
+
body: JSON.stringify({
|
|
4081
|
+
model: req.externalModelId,
|
|
4082
|
+
input: req.input,
|
|
4083
|
+
voice: req.voice,
|
|
4084
|
+
response_format: "wav"
|
|
4085
|
+
}),
|
|
4086
|
+
signal: AbortSignal.timeout(config.timeoutMs ?? 6e4)
|
|
4087
|
+
});
|
|
4088
|
+
if (!response.ok) {
|
|
4089
|
+
let detail;
|
|
4090
|
+
try {
|
|
4091
|
+
const body = await response.json();
|
|
4092
|
+
detail = body.error?.message;
|
|
4093
|
+
} catch {
|
|
4094
|
+
detail = void 0;
|
|
4095
|
+
}
|
|
4096
|
+
throw new Error(detail ?? `Speech synthesis failed with HTTP ${response.status}`);
|
|
4097
|
+
}
|
|
4098
|
+
const audio = new Uint8Array(await response.arrayBuffer());
|
|
4099
|
+
if (audio.length === 0) throw new Error("Speech synthesis returned no audio");
|
|
4100
|
+
return {
|
|
4101
|
+
audio,
|
|
4102
|
+
mimeType: response.headers.get("content-type")?.split(";")[0] ?? "audio/wav"
|
|
4103
|
+
};
|
|
4104
|
+
}
|
|
4105
|
+
};
|
|
4106
|
+
}
|
|
4107
|
+
|
|
4108
|
+
// src/providers/images/openai-images.ts
|
|
4109
|
+
var IMAGE_SIZES = ["1024x1024", "1536x1024", "1024x1536"];
|
|
4110
|
+
var IMAGE_QUALITIES = ["auto", "low", "medium", "high", "xhigh", "max"];
|
|
4111
|
+
var IMAGE_B64_LIMIT = 12e6;
|
|
4112
|
+
function createOpenAiImageAdapter(config) {
|
|
4113
|
+
return {
|
|
4114
|
+
async generate(req) {
|
|
4115
|
+
const response = await fetch(`${config.baseUrl}/images/generations`, {
|
|
4116
|
+
method: "POST",
|
|
4117
|
+
headers: {
|
|
4118
|
+
Authorization: `Bearer ${config.apiKey}`,
|
|
4119
|
+
"Content-Type": "application/json"
|
|
4120
|
+
},
|
|
4121
|
+
body: JSON.stringify({
|
|
4122
|
+
model: req.externalModelId,
|
|
4123
|
+
prompt: req.prompt,
|
|
4124
|
+
n: 1,
|
|
4125
|
+
size: req.size,
|
|
4126
|
+
quality: req.quality
|
|
4127
|
+
}),
|
|
4128
|
+
signal: AbortSignal.timeout(config.timeoutMs ?? 6e4)
|
|
4129
|
+
});
|
|
4130
|
+
if (!response.ok) {
|
|
4131
|
+
let detail;
|
|
4132
|
+
try {
|
|
4133
|
+
const body = await response.json();
|
|
4134
|
+
detail = body.error?.message;
|
|
4135
|
+
} catch {
|
|
4136
|
+
detail = void 0;
|
|
4137
|
+
}
|
|
4138
|
+
throw new Error(detail ?? `Image provider failed with HTTP ${response.status}`);
|
|
4139
|
+
}
|
|
4140
|
+
let payload;
|
|
4141
|
+
try {
|
|
4142
|
+
payload = await response.json();
|
|
4143
|
+
} catch {
|
|
4144
|
+
throw new Error("The image provider returned an unreadable response.");
|
|
4145
|
+
}
|
|
4146
|
+
const images = (payload.data ?? []).map((item) => item.b64_json).filter((value) => typeof value === "string" && value.length > 0);
|
|
4147
|
+
if (images.length === 0) {
|
|
4148
|
+
throw new Error("The image provider returned no image data.");
|
|
4149
|
+
}
|
|
4150
|
+
if (images.some((value) => value.length > IMAGE_B64_LIMIT)) {
|
|
4151
|
+
throw new Error("The generated image exceeds the storage limit.");
|
|
4152
|
+
}
|
|
4153
|
+
const usage = payload.usage;
|
|
4154
|
+
return {
|
|
4155
|
+
images,
|
|
4156
|
+
usage: usage ? {
|
|
4157
|
+
inputTokens: usage.input_tokens ?? 0,
|
|
4158
|
+
outputTokens: usage.output_tokens ?? 0,
|
|
4159
|
+
totalTokens: (usage.input_tokens ?? 0) + (usage.output_tokens ?? 0)
|
|
4160
|
+
} : null
|
|
4161
|
+
};
|
|
4162
|
+
}
|
|
4163
|
+
};
|
|
4164
|
+
}
|
|
4165
|
+
|
|
3979
4166
|
exports.ANTHROPIC_API_VERSION = ANTHROPIC_API_VERSION;
|
|
3980
4167
|
exports.ANTHROPIC_DEFAULT_MAX_TOKENS = ANTHROPIC_DEFAULT_MAX_TOKENS;
|
|
3981
4168
|
exports.ANTHROPIC_MODELS = ANTHROPIC_MODELS;
|
|
@@ -4002,9 +4189,14 @@ exports.GroqConfigStore = GroqConfigStore;
|
|
|
4002
4189
|
exports.GroqHttpClient = GroqHttpClient;
|
|
4003
4190
|
exports.GroqHttpTransport = GroqHttpTransport;
|
|
4004
4191
|
exports.GroqProvider = GroqProvider;
|
|
4192
|
+
exports.IMAGE_B64_LIMIT = IMAGE_B64_LIMIT;
|
|
4193
|
+
exports.IMAGE_QUALITIES = IMAGE_QUALITIES;
|
|
4194
|
+
exports.IMAGE_SIZES = IMAGE_SIZES;
|
|
4005
4195
|
exports.ProviderError = ProviderError;
|
|
4006
4196
|
exports.ProviderFactory = ProviderFactory;
|
|
4007
4197
|
exports.PrunaProvider = PrunaProvider;
|
|
4198
|
+
exports.SPEECH_INPUT_MAX = SPEECH_INPUT_MAX;
|
|
4199
|
+
exports.SPEECH_VOICES = SPEECH_VOICES;
|
|
4008
4200
|
exports.TIMEOUTS = TIMEOUTS;
|
|
4009
4201
|
exports.TextGenerationService = TextGenerationService;
|
|
4010
4202
|
exports.TimeoutError = TimeoutError;
|
|
@@ -4018,6 +4210,10 @@ exports.createFalProvider = createFalProvider;
|
|
|
4018
4210
|
exports.createGeminiProvider = createGeminiProvider;
|
|
4019
4211
|
exports.createGroqProvider = createGroqProvider;
|
|
4020
4212
|
exports.createMessage = createMessage;
|
|
4213
|
+
exports.createOpenAiAudioTranscriptionAdapter = createOpenAiAudioTranscriptionAdapter;
|
|
4214
|
+
exports.createOpenAiEmbeddingsAdapter = createOpenAiEmbeddingsAdapter;
|
|
4215
|
+
exports.createOpenAiImageAdapter = createOpenAiImageAdapter;
|
|
4216
|
+
exports.createOpenAiSpeechAdapter = createOpenAiSpeechAdapter;
|
|
4021
4217
|
exports.createProviderFactory = createProviderFactory;
|
|
4022
4218
|
exports.createPrunaProvider = createPrunaProvider;
|
|
4023
4219
|
exports.createSystemMessage = createSystemMessage;
|