@hintergrund/ui 0.2.1 → 0.2.3
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/Builder-H8tY8V9I.js +14172 -0
- package/dist/admin.js +11160 -9739
- package/dist/{anthropic-UhrJpH25.js → anthropic-messages-C3hIUlsA.js} +1134 -1055
- package/dist/azure-openai-responses-t7u41KMr.js +222 -0
- package/dist/builder.js +2 -2
- package/dist/client-Cd7yMX39.js +7860 -0
- package/dist/deferred-tools-BZWMWBYN.js +28 -0
- package/dist/error-body-BUPcH4GF.js +71 -0
- package/dist/github-copilot-headers-B1RBGoZi.js +21 -0
- package/dist/{global-CFcrkAa3.js → global-Bk9T4Af5.js} +17896 -16508
- package/dist/google-generative-ai-6ZG79NDC.js +264 -0
- package/dist/{google-shared-BmdaIInh.js → google-shared-C6y4fA42.js} +1135 -1104
- package/dist/google-vertex-f2myaAmm.js +305 -0
- package/dist/headers-D4iLzGaS.js +21 -0
- package/dist/json-parse-LZdWp-Nd.js +232 -0
- package/dist/login.js +79 -75
- package/dist/mistral-conversations-D16H8Mgq.js +513 -0
- package/dist/openai-codex-responses-DIHPbnIS.js +947 -0
- package/dist/openai-completions-vDHGFsWV.js +741 -0
- package/dist/{headers-u7rXGJ9f.js → openai-prompt-cache-BJwqbEDx.js} +7 -6
- package/dist/openai-responses-B0rjAJxx.js +184 -0
- package/dist/openai-responses-shared-DqdzMfa_.js +477 -0
- package/dist/pi-messages-DB2BtH-g.js +251 -0
- package/dist/pi-user-agent-CUqx-qiX.js +13 -0
- package/dist/provider-env-D2VjEV3S.js +26 -0
- package/dist/provider-retry-BsigVlMg.js +67 -0
- package/dist/setup.js +275 -188
- package/dist/transform-messages-CsKsy6b4.js +398 -0
- package/package.json +4 -5
- package/dist/Builder-B0XYsyXe.js +0 -163449
- package/dist/azure-openai-responses-DAC03Qw1.js +0 -203
- package/dist/client-Sh7wNjbG.js +0 -5277
- package/dist/github-copilot-headers-DWh_6bE3.js +0 -35
- package/dist/google-CVz_TaG6.js +0 -248
- package/dist/google-vertex-C6GE41DE.js +0 -285
- package/dist/json-parse-DmJ6NiZE.js +0 -93
- package/dist/mistral-DqYbzWvv.js +0 -22932
- package/dist/openai-codex-responses-ZWuD9ryk.js +0 -700
- package/dist/openai-completions-B6B2OwYj.js +0 -535
- package/dist/openai-responses-D9Ip2Wgd.js +0 -142
- package/dist/openai-responses-shared-eUUJSL4D.js +0 -324
- package/dist/transform-messages-CkpQp6fJ.js +0 -132
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { O as y, a as p, r as f, i as R, b as g } from "./client-Cd7yMX39.js";
|
|
2
|
+
import { d as _, e as I } from "./Builder-H8tY8V9I.js";
|
|
3
|
+
import { f as O, n as v } from "./error-body-BUPcH4GF.js";
|
|
4
|
+
import { h as P } from "./headers-D4iLzGaS.js";
|
|
5
|
+
import { g as m } from "./provider-env-D2VjEV3S.js";
|
|
6
|
+
import { r as b } from "./provider-retry-BsigVlMg.js";
|
|
7
|
+
import { c as h, b as w } from "./transform-messages-CsKsy6b4.js";
|
|
8
|
+
import { c as N } from "./openai-prompt-cache-BJwqbEDx.js";
|
|
9
|
+
import { p as U, c as z, a as S } from "./openai-responses-shared-DqdzMfa_.js";
|
|
10
|
+
typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(r) {
|
|
11
|
+
return Promise.resolve().then(r);
|
|
12
|
+
} });
|
|
13
|
+
class M extends y {
|
|
14
|
+
/**
|
|
15
|
+
* API Client for interfacing with the Azure OpenAI API.
|
|
16
|
+
*
|
|
17
|
+
* @param {string | undefined} [opts.apiVersion=process.env['OPENAI_API_VERSION'] ?? undefined]
|
|
18
|
+
* @param {string | undefined} [opts.endpoint=process.env['AZURE_OPENAI_ENDPOINT'] ?? undefined] - Your Azure endpoint, including the resource, e.g. `https://example-resource.azure.openai.com/`
|
|
19
|
+
* @param {string | undefined} [opts.apiKey=process.env['AZURE_OPENAI_API_KEY'] ?? undefined]
|
|
20
|
+
* @param {string | undefined} opts.deployment - A model deployment, if given, sets the base client URL to include `/deployments/{deployment}`.
|
|
21
|
+
* @param {string | null | undefined} [opts.organization=process.env['OPENAI_ORG_ID'] ?? null]
|
|
22
|
+
* @param {string} [opts.baseURL=process.env['OPENAI_BASE_URL']] - Sets the base URL for the API, e.g. `https://example-resource.azure.openai.com/openai/`.
|
|
23
|
+
* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
24
|
+
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
25
|
+
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
26
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
27
|
+
* @param {Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
28
|
+
* @param {DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
29
|
+
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
|
|
30
|
+
*/
|
|
31
|
+
constructor({ baseURL: a = f("OPENAI_BASE_URL"), apiKey: e = f("AZURE_OPENAI_API_KEY"), apiVersion: t = f("OPENAI_API_VERSION"), endpoint: n, deployment: s, azureADTokenProvider: o, dangerouslyAllowBrowser: i, ...u } = {}) {
|
|
32
|
+
if (!t)
|
|
33
|
+
throw new p("The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).");
|
|
34
|
+
if (typeof o == "function" && (i = !0), !o && !e)
|
|
35
|
+
throw new p("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");
|
|
36
|
+
if (o && e)
|
|
37
|
+
throw new p("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");
|
|
38
|
+
if (u.defaultQuery = { ...u.defaultQuery, "api-version": t }, a) {
|
|
39
|
+
if (n)
|
|
40
|
+
throw new p("baseURL and endpoint are mutually exclusive");
|
|
41
|
+
} else {
|
|
42
|
+
if (n || (n = process.env.AZURE_OPENAI_ENDPOINT), !n)
|
|
43
|
+
throw new p("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");
|
|
44
|
+
a = `${n}/openai`;
|
|
45
|
+
}
|
|
46
|
+
super({
|
|
47
|
+
apiKey: o ?? e,
|
|
48
|
+
baseURL: a,
|
|
49
|
+
...u,
|
|
50
|
+
...i !== void 0 ? { dangerouslyAllowBrowser: i } : {}
|
|
51
|
+
}), this.apiVersion = "", this.apiVersion = t, this.deploymentName = s;
|
|
52
|
+
}
|
|
53
|
+
async buildRequest(a, e = {}) {
|
|
54
|
+
if (T.has(a.path) && a.method === "post" && a.body !== void 0) {
|
|
55
|
+
if (!R(a.body))
|
|
56
|
+
throw new Error("Expected request body to be an object");
|
|
57
|
+
const t = this.deploymentName || a.body.model || a.__metadata?.model;
|
|
58
|
+
t !== void 0 && !this.baseURL.includes("/deployments") && (a.path = `/deployments/${t}${a.path}`);
|
|
59
|
+
}
|
|
60
|
+
return super.buildRequest(a, e);
|
|
61
|
+
}
|
|
62
|
+
async authHeaders(a, e) {
|
|
63
|
+
const t = e ?? { bearerAuth: !0, adminAPIKeyAuth: !0 };
|
|
64
|
+
return t.bearerAuth && typeof this._options.apiKey == "string" ? g([{ "api-key": this.apiKey }]) : super.authHeaders(a, t);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const T = /* @__PURE__ */ new Set([
|
|
68
|
+
"/completions",
|
|
69
|
+
"/chat/completions",
|
|
70
|
+
"/embeddings",
|
|
71
|
+
"/audio/transcriptions",
|
|
72
|
+
"/audio/translations",
|
|
73
|
+
"/audio/speech",
|
|
74
|
+
"/images/generations",
|
|
75
|
+
"/batches",
|
|
76
|
+
"/images/edits"
|
|
77
|
+
]), L = "v1", k = /* @__PURE__ */ new Set(["openai", "openai-codex", "opencode", "azure-openai-responses"]), D = 16;
|
|
78
|
+
function x(r) {
|
|
79
|
+
const a = /* @__PURE__ */ new Map();
|
|
80
|
+
if (!r)
|
|
81
|
+
return a;
|
|
82
|
+
for (const e of r.split(",")) {
|
|
83
|
+
const t = e.trim();
|
|
84
|
+
if (!t)
|
|
85
|
+
continue;
|
|
86
|
+
const [n, s] = t.split("=", 2);
|
|
87
|
+
!n || !s || a.set(n.trim(), s.trim());
|
|
88
|
+
}
|
|
89
|
+
return a;
|
|
90
|
+
}
|
|
91
|
+
function K(r, a) {
|
|
92
|
+
return a?.azureDeploymentName ? a.azureDeploymentName : x(m("AZURE_OPENAI_DEPLOYMENT_NAME_MAP", a?.env)).get(r.id) || r.id;
|
|
93
|
+
}
|
|
94
|
+
function V(r) {
|
|
95
|
+
return O(v(r), "Azure OpenAI API error");
|
|
96
|
+
}
|
|
97
|
+
const Z = (r, a, e) => {
|
|
98
|
+
const t = new _();
|
|
99
|
+
return (async () => {
|
|
100
|
+
const n = K(r, e), s = {
|
|
101
|
+
role: "assistant",
|
|
102
|
+
content: [],
|
|
103
|
+
api: "azure-openai-responses",
|
|
104
|
+
provider: r.provider,
|
|
105
|
+
model: r.id,
|
|
106
|
+
usage: {
|
|
107
|
+
input: 0,
|
|
108
|
+
output: 0,
|
|
109
|
+
cacheRead: 0,
|
|
110
|
+
cacheWrite: 0,
|
|
111
|
+
totalTokens: 0,
|
|
112
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
|
|
113
|
+
},
|
|
114
|
+
stopReason: "pending",
|
|
115
|
+
timestamp: Date.now()
|
|
116
|
+
};
|
|
117
|
+
try {
|
|
118
|
+
const o = e?.apiKey;
|
|
119
|
+
if (!o)
|
|
120
|
+
throw new Error(`No API key for provider: ${r.provider}`);
|
|
121
|
+
const i = C(r, o, e), u = h(a.tools, r.compat?.supportsOpenAIGrammarTools ?? !1);
|
|
122
|
+
let c = G(r, a, e, n, u);
|
|
123
|
+
const d = await e?.onPayload?.(c, r);
|
|
124
|
+
d !== void 0 && (c = d);
|
|
125
|
+
const A = {
|
|
126
|
+
...e?.signal ? { signal: e.signal } : {},
|
|
127
|
+
...e?.timeoutMs !== void 0 ? { timeout: e.timeoutMs } : {},
|
|
128
|
+
maxRetries: 0
|
|
129
|
+
}, { data: E, response: l } = await b(() => i.responses.create(c, A).withResponse(), {
|
|
130
|
+
maxRetries: e?.maxRetries,
|
|
131
|
+
maxRetryDelayMs: e?.maxRetryDelayMs,
|
|
132
|
+
signal: e?.signal
|
|
133
|
+
});
|
|
134
|
+
if (await e?.onResponse?.({ status: l.status, headers: P(l.headers) }, r), t.push({ type: "start", partial: s }), await U(E, s, t, r, { grammarToolInputProperties: u }), e?.signal?.aborted)
|
|
135
|
+
throw new Error("Request was aborted");
|
|
136
|
+
if (s.stopReason === "pending")
|
|
137
|
+
throw new Error("Azure OpenAI Responses stream ended without a stop reason");
|
|
138
|
+
if (s.stopReason === "aborted" || s.stopReason === "error")
|
|
139
|
+
throw new Error(s.errorMessage || "An unknown error occurred");
|
|
140
|
+
t.push({ type: "done", reason: s.stopReason, message: s }), t.end();
|
|
141
|
+
} catch (o) {
|
|
142
|
+
for (const i of s.content)
|
|
143
|
+
delete i.index, delete i.partialJson, delete i.customInput;
|
|
144
|
+
s.stopReason = e?.signal?.aborted ? "aborted" : "error", s.errorMessage = V(o), t.push({ type: "error", reason: s.stopReason, error: s }), t.end();
|
|
145
|
+
}
|
|
146
|
+
})(), t;
|
|
147
|
+
}, re = (r, a, e) => {
|
|
148
|
+
const t = e?.apiKey;
|
|
149
|
+
if (!t)
|
|
150
|
+
throw new Error(`No API key for provider: ${r.provider}`);
|
|
151
|
+
const n = w(r, a, e, t), s = e?.reasoning ? I(r, e.reasoning) : void 0;
|
|
152
|
+
return Z(r, a, {
|
|
153
|
+
...n,
|
|
154
|
+
reasoningEffort: s === "off" ? void 0 : s
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
function $(r) {
|
|
158
|
+
const a = r.trim().replace(/\/+$/, "");
|
|
159
|
+
let e;
|
|
160
|
+
try {
|
|
161
|
+
e = new URL(a);
|
|
162
|
+
} catch {
|
|
163
|
+
throw new Error(`Invalid Azure OpenAI base URL: ${r}`);
|
|
164
|
+
}
|
|
165
|
+
const t = e.hostname.endsWith(".openai.azure.com") || e.hostname.endsWith(".cognitiveservices.azure.com") || e.hostname.endsWith(".ai.azure.com"), n = e.pathname.replace(/\/+$/, "");
|
|
166
|
+
return t && (n === "" || n === "/" || n === "/openai" || n === "/openai/v1/responses") && (e.pathname = "/openai/v1", e.search = ""), e.toString().replace(/\/+$/, "");
|
|
167
|
+
}
|
|
168
|
+
function B(r) {
|
|
169
|
+
return `https://${r}.openai.azure.com/openai/v1`;
|
|
170
|
+
}
|
|
171
|
+
function q(r, a) {
|
|
172
|
+
const e = a?.azureApiVersion || m("AZURE_OPENAI_API_VERSION", a?.env) || L, t = a?.azureBaseUrl?.trim() || m("AZURE_OPENAI_BASE_URL", a?.env)?.trim() || void 0, n = a?.azureResourceName || m("AZURE_OPENAI_RESOURCE_NAME", a?.env);
|
|
173
|
+
let s = t;
|
|
174
|
+
if (!s && n && (s = B(n)), !s && r.baseUrl && (s = r.baseUrl), !s)
|
|
175
|
+
throw new Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");
|
|
176
|
+
return {
|
|
177
|
+
baseUrl: $(s),
|
|
178
|
+
apiVersion: e
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function C(r, a, e) {
|
|
182
|
+
const t = { ...r.headers };
|
|
183
|
+
e?.headers && Object.assign(t, e.headers);
|
|
184
|
+
const { baseUrl: n, apiVersion: s } = q(r, e);
|
|
185
|
+
return new M({
|
|
186
|
+
apiKey: a,
|
|
187
|
+
apiVersion: s,
|
|
188
|
+
dangerouslyAllowBrowser: !0,
|
|
189
|
+
fetch: e?.fetch,
|
|
190
|
+
defaultHeaders: t,
|
|
191
|
+
baseURL: n
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
function G(r, a, e, t, n = h(a.tools, r.compat?.supportsOpenAIGrammarTools ?? !1)) {
|
|
195
|
+
const s = z(r, a, k, {
|
|
196
|
+
grammarToolInputProperties: n
|
|
197
|
+
}), o = {
|
|
198
|
+
model: t,
|
|
199
|
+
input: s,
|
|
200
|
+
stream: !0,
|
|
201
|
+
prompt_cache_key: N(e?.sessionId),
|
|
202
|
+
store: !1
|
|
203
|
+
};
|
|
204
|
+
if (e?.maxTokens && (o.max_output_tokens = Math.max(e.maxTokens, D)), e?.temperature !== void 0 && (o.temperature = e?.temperature), a.tools && a.tools.length > 0 && (o.tools = S(a.tools, {
|
|
205
|
+
supportsStrictMode: r.compat?.supportsStrictMode ?? !0,
|
|
206
|
+
supportsOpenAIGrammarTools: r.compat?.supportsOpenAIGrammarTools ?? !1
|
|
207
|
+
})), r.reasoning)
|
|
208
|
+
if (e?.reasoningEffort || e?.reasoningSummary) {
|
|
209
|
+
const i = e?.reasoningEffort ? r.thinkingLevelMap?.[e.reasoningEffort] ?? e.reasoningEffort : "medium";
|
|
210
|
+
o.reasoning = {
|
|
211
|
+
effort: i,
|
|
212
|
+
summary: e?.reasoningSummary || "auto"
|
|
213
|
+
}, o.include = ["reasoning.encrypted_content"];
|
|
214
|
+
} else r.thinkingLevelMap?.off !== null && (o.reasoning = {
|
|
215
|
+
effort: r.thinkingLevelMap?.off ?? "none"
|
|
216
|
+
});
|
|
217
|
+
return e?.samplingParams && Object.assign(o, e.samplingParams), o;
|
|
218
|
+
}
|
|
219
|
+
export {
|
|
220
|
+
Z as stream,
|
|
221
|
+
re as streamSimple
|
|
222
|
+
};
|
package/dist/builder.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./global-
|
|
2
|
-
import { B as i } from "./Builder-
|
|
1
|
+
import "./global-Bk9T4Af5.js";
|
|
2
|
+
import { B as i } from "./Builder-H8tY8V9I.js";
|
|
3
3
|
typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(e) {
|
|
4
4
|
return Promise.resolve().then(e);
|
|
5
5
|
} });
|