@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,264 @@
|
|
|
1
|
+
import { r as v, i as M, a as I, m as T, G as R, c as S, s as G, b as L, d as _ } from "./google-shared-C6y4fA42.js";
|
|
2
|
+
import { d as P, f as E, e as A } from "./Builder-H8tY8V9I.js";
|
|
3
|
+
import { f as O, n as N } from "./error-body-BUPcH4GF.js";
|
|
4
|
+
import { p as H } from "./headers-D4iLzGaS.js";
|
|
5
|
+
import { b as W, s as $ } from "./transform-messages-CsKsy6b4.js";
|
|
6
|
+
typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(t) {
|
|
7
|
+
return Promise.resolve().then(t);
|
|
8
|
+
} });
|
|
9
|
+
let B = 0;
|
|
10
|
+
const k = (t, a, n) => {
|
|
11
|
+
const i = new P();
|
|
12
|
+
return (async () => {
|
|
13
|
+
const e = {
|
|
14
|
+
role: "assistant",
|
|
15
|
+
content: [],
|
|
16
|
+
api: "google-generative-ai",
|
|
17
|
+
provider: t.provider,
|
|
18
|
+
model: t.id,
|
|
19
|
+
usage: {
|
|
20
|
+
input: 0,
|
|
21
|
+
output: 0,
|
|
22
|
+
cacheRead: 0,
|
|
23
|
+
cacheWrite: 0,
|
|
24
|
+
totalTokens: 0,
|
|
25
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
|
|
26
|
+
},
|
|
27
|
+
stopReason: "pending",
|
|
28
|
+
timestamp: Date.now()
|
|
29
|
+
};
|
|
30
|
+
try {
|
|
31
|
+
if (n?.fetch && n.fetch !== globalThis.fetch)
|
|
32
|
+
throw new Error("Custom fetch is not supported by the Google Generative AI adapter");
|
|
33
|
+
const g = n?.apiKey;
|
|
34
|
+
if (!g)
|
|
35
|
+
throw new Error(`No API key for provider: ${t.provider}`);
|
|
36
|
+
const c = U(t, g, n?.headers);
|
|
37
|
+
let s = D(t, a, n);
|
|
38
|
+
const f = await n?.onPayload?.(s, t);
|
|
39
|
+
f !== void 0 && (s = f);
|
|
40
|
+
const h = await v(() => c.models.generateContentStream(s), n);
|
|
41
|
+
i.push({ type: "start", partial: e });
|
|
42
|
+
let o = null;
|
|
43
|
+
const b = e.content, u = () => b.length - 1;
|
|
44
|
+
for await (const l of h) {
|
|
45
|
+
e.responseId ||= l.responseId;
|
|
46
|
+
const p = l.candidates?.[0];
|
|
47
|
+
if (p?.content?.parts)
|
|
48
|
+
for (const r of p.content.parts) {
|
|
49
|
+
if (r.text !== void 0) {
|
|
50
|
+
const d = M(r);
|
|
51
|
+
(!o || d && o.type !== "thinking" || !d && o.type !== "text") && (o && (o.type === "text" ? i.push({
|
|
52
|
+
type: "text_end",
|
|
53
|
+
contentIndex: b.length - 1,
|
|
54
|
+
content: o.text,
|
|
55
|
+
partial: e
|
|
56
|
+
}) : i.push({
|
|
57
|
+
type: "thinking_end",
|
|
58
|
+
contentIndex: u(),
|
|
59
|
+
content: o.thinking,
|
|
60
|
+
partial: e
|
|
61
|
+
})), d ? (o = { type: "thinking", thinking: "", thinkingSignature: void 0 }, e.content.push(o), i.push({ type: "thinking_start", contentIndex: u(), partial: e })) : (o = { type: "text", text: "" }, e.content.push(o), i.push({ type: "text_start", contentIndex: u(), partial: e }))), o.type === "thinking" ? (o.thinking += r.text, o.thinkingSignature = I(o.thinkingSignature, r.thoughtSignature), i.push({
|
|
62
|
+
type: "thinking_delta",
|
|
63
|
+
contentIndex: u(),
|
|
64
|
+
delta: r.text,
|
|
65
|
+
partial: e
|
|
66
|
+
})) : (o.text += r.text, o.textSignature = I(o.textSignature, r.thoughtSignature), i.push({
|
|
67
|
+
type: "text_delta",
|
|
68
|
+
contentIndex: u(),
|
|
69
|
+
delta: r.text,
|
|
70
|
+
partial: e
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
if (r.functionCall) {
|
|
74
|
+
o && (o.type === "text" ? i.push({
|
|
75
|
+
type: "text_end",
|
|
76
|
+
contentIndex: u(),
|
|
77
|
+
content: o.text,
|
|
78
|
+
partial: e
|
|
79
|
+
}) : i.push({
|
|
80
|
+
type: "thinking_end",
|
|
81
|
+
contentIndex: u(),
|
|
82
|
+
content: o.thinking,
|
|
83
|
+
partial: e
|
|
84
|
+
}), o = null);
|
|
85
|
+
const d = r.functionCall.id, m = {
|
|
86
|
+
type: "toolCall",
|
|
87
|
+
id: !d || e.content.some((C) => C.type === "toolCall" && C.id === d) ? `${r.functionCall.name}_${Date.now()}_${++B}` : d,
|
|
88
|
+
name: r.functionCall.name || "",
|
|
89
|
+
arguments: r.functionCall.args ?? {},
|
|
90
|
+
...r.thoughtSignature && { thoughtSignature: r.thoughtSignature }
|
|
91
|
+
};
|
|
92
|
+
e.content.push(m), i.push({ type: "toolcall_start", contentIndex: u(), partial: e }), i.push({
|
|
93
|
+
type: "toolcall_delta",
|
|
94
|
+
contentIndex: u(),
|
|
95
|
+
delta: JSON.stringify(m.arguments),
|
|
96
|
+
partial: e
|
|
97
|
+
}), i.push({ type: "toolcall_end", contentIndex: u(), toolCall: m, partial: e });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
p?.finishReason && (e.rawStopReason = p.finishReason, e.stopReason = T(p.finishReason), e.content.some((r) => r.type === "toolCall") && e.stopReason === "stop" && (e.stopReason = "toolUse")), l.usageMetadata && (e.usage = {
|
|
101
|
+
input: (l.usageMetadata.promptTokenCount || 0) - (l.usageMetadata.cachedContentTokenCount || 0),
|
|
102
|
+
output: (l.usageMetadata.candidatesTokenCount || 0) + (l.usageMetadata.thoughtsTokenCount || 0),
|
|
103
|
+
cacheRead: l.usageMetadata.cachedContentTokenCount || 0,
|
|
104
|
+
cacheWrite: 0,
|
|
105
|
+
reasoning: l.usageMetadata.thoughtsTokenCount || 0,
|
|
106
|
+
totalTokens: l.usageMetadata.totalTokenCount || 0,
|
|
107
|
+
cost: {
|
|
108
|
+
input: 0,
|
|
109
|
+
output: 0,
|
|
110
|
+
cacheRead: 0,
|
|
111
|
+
cacheWrite: 0,
|
|
112
|
+
total: 0
|
|
113
|
+
}
|
|
114
|
+
}, E(t, e.usage));
|
|
115
|
+
}
|
|
116
|
+
if (o && (o.type === "text" ? i.push({
|
|
117
|
+
type: "text_end",
|
|
118
|
+
contentIndex: u(),
|
|
119
|
+
content: o.text,
|
|
120
|
+
partial: e
|
|
121
|
+
}) : i.push({
|
|
122
|
+
type: "thinking_end",
|
|
123
|
+
contentIndex: u(),
|
|
124
|
+
content: o.thinking,
|
|
125
|
+
partial: e
|
|
126
|
+
})), n?.signal?.aborted)
|
|
127
|
+
throw new Error("Request was aborted");
|
|
128
|
+
if (e.stopReason === "pending")
|
|
129
|
+
throw new Error("Google stream ended without a finish reason");
|
|
130
|
+
if (e.stopReason === "aborted" || e.stopReason === "error") {
|
|
131
|
+
const l = e.rawStopReason ? `Provider stopped with: ${e.rawStopReason}` : "An unknown error occurred";
|
|
132
|
+
throw new Error(l);
|
|
133
|
+
}
|
|
134
|
+
i.push({ type: "done", reason: e.stopReason, message: e }), i.end();
|
|
135
|
+
} catch (g) {
|
|
136
|
+
for (const c of e.content)
|
|
137
|
+
"index" in c && delete c.index;
|
|
138
|
+
e.stopReason = n?.signal?.aborted ? "aborted" : "error", e.errorMessage = O(N(g)), i.push({ type: "error", reason: e.stopReason, error: e }), i.end();
|
|
139
|
+
}
|
|
140
|
+
})(), i;
|
|
141
|
+
}, Z = (t, a, n) => {
|
|
142
|
+
const i = n?.apiKey;
|
|
143
|
+
if (!i)
|
|
144
|
+
throw new Error(`No API key for provider: ${t.provider}`);
|
|
145
|
+
const e = W(t, a, n, i);
|
|
146
|
+
if (!n?.reasoning)
|
|
147
|
+
return k(t, a, { ...e, thinking: { enabled: !1 } });
|
|
148
|
+
const g = A(t, n.reasoning), c = g === "off" ? "high" : g, s = t;
|
|
149
|
+
return w(s) || x(s) || y(s) ? k(t, a, {
|
|
150
|
+
...e,
|
|
151
|
+
thinking: {
|
|
152
|
+
enabled: !0,
|
|
153
|
+
level: q(c, s)
|
|
154
|
+
}
|
|
155
|
+
}) : k(t, a, {
|
|
156
|
+
...e,
|
|
157
|
+
thinking: {
|
|
158
|
+
enabled: !0,
|
|
159
|
+
budgetTokens: j(s, c, n.thinkingBudgets)
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
function U(t, a, n) {
|
|
164
|
+
const i = {};
|
|
165
|
+
t.baseUrl && (i.baseUrl = t.baseUrl, i.apiVersion = "");
|
|
166
|
+
const e = H({ ...t.headers, ...n });
|
|
167
|
+
return e && (i.headers = e), new R({
|
|
168
|
+
apiKey: a,
|
|
169
|
+
httpOptions: Object.keys(i).length > 0 ? i : void 0
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function D(t, a, n = {}) {
|
|
173
|
+
const i = S(t, a), e = {};
|
|
174
|
+
n.temperature !== void 0 && (e.temperature = n.temperature), n.maxTokens !== void 0 && (e.maxOutputTokens = n.maxTokens);
|
|
175
|
+
const g = G(t.id), c = a.tools?.length ? L(a.tools, n.toolChoice, g) : void 0, s = {
|
|
176
|
+
...Object.keys(e).length > 0 && e,
|
|
177
|
+
...a.systemPrompt && { systemInstruction: $(a.systemPrompt) },
|
|
178
|
+
...a.tools && a.tools.length > 0 && {
|
|
179
|
+
tools: _(a.tools, !1, g)
|
|
180
|
+
},
|
|
181
|
+
...c !== void 0 && {
|
|
182
|
+
toolConfig: { functionCallingConfig: { mode: c } }
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
if (n.thinking?.enabled && t.reasoning) {
|
|
186
|
+
const h = { includeThoughts: !0 };
|
|
187
|
+
n.thinking.level !== void 0 ? h.thinkingLevel = n.thinking.level : n.thinking.budgetTokens !== void 0 && (h.thinkingBudget = n.thinking.budgetTokens), s.thinkingConfig = h;
|
|
188
|
+
} else t.reasoning && n.thinking && !n.thinking.enabled && (s.thinkingConfig = K(t));
|
|
189
|
+
if (n.signal) {
|
|
190
|
+
if (n.signal.aborted)
|
|
191
|
+
throw new Error("Request aborted");
|
|
192
|
+
s.abortSignal = n.signal;
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
model: t.id,
|
|
196
|
+
contents: i,
|
|
197
|
+
config: s
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function y(t) {
|
|
201
|
+
return /gemma-?4/.test(t.id.toLowerCase());
|
|
202
|
+
}
|
|
203
|
+
function w(t) {
|
|
204
|
+
return /gemini-3(?:\.\d+)?-pro/.test(t.id.toLowerCase());
|
|
205
|
+
}
|
|
206
|
+
function x(t) {
|
|
207
|
+
const a = t.id.toLowerCase();
|
|
208
|
+
return /gemini-3(?:\.\d+)?-flash/.test(a) || a === "gemini-flash-latest" || a === "gemini-flash-lite-latest";
|
|
209
|
+
}
|
|
210
|
+
function K(t) {
|
|
211
|
+
return w(t) ? { thinkingLevel: "LOW" } : x(t) ? { thinkingLevel: "MINIMAL" } : y(t) ? { thinkingLevel: "MINIMAL" } : { thinkingBudget: 0 };
|
|
212
|
+
}
|
|
213
|
+
function q(t, a) {
|
|
214
|
+
if (w(a))
|
|
215
|
+
switch (t) {
|
|
216
|
+
case "minimal":
|
|
217
|
+
case "low":
|
|
218
|
+
return "LOW";
|
|
219
|
+
case "medium":
|
|
220
|
+
case "high":
|
|
221
|
+
return "HIGH";
|
|
222
|
+
}
|
|
223
|
+
if (y(a))
|
|
224
|
+
switch (t) {
|
|
225
|
+
case "minimal":
|
|
226
|
+
case "low":
|
|
227
|
+
return "MINIMAL";
|
|
228
|
+
case "medium":
|
|
229
|
+
case "high":
|
|
230
|
+
return "HIGH";
|
|
231
|
+
}
|
|
232
|
+
switch (t) {
|
|
233
|
+
case "minimal":
|
|
234
|
+
return "MINIMAL";
|
|
235
|
+
case "low":
|
|
236
|
+
return "LOW";
|
|
237
|
+
case "medium":
|
|
238
|
+
return "MEDIUM";
|
|
239
|
+
case "high":
|
|
240
|
+
return "HIGH";
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function j(t, a, n) {
|
|
244
|
+
return n?.[a] !== void 0 ? n[a] : t.id.includes("2.5-pro") ? {
|
|
245
|
+
minimal: 128,
|
|
246
|
+
low: 2048,
|
|
247
|
+
medium: 8192,
|
|
248
|
+
high: 32768
|
|
249
|
+
}[a] : t.id.includes("2.5-flash-lite") ? {
|
|
250
|
+
minimal: 512,
|
|
251
|
+
low: 2048,
|
|
252
|
+
medium: 8192,
|
|
253
|
+
high: 24576
|
|
254
|
+
}[a] : t.id.includes("2.5-flash") ? {
|
|
255
|
+
minimal: 128,
|
|
256
|
+
low: 2048,
|
|
257
|
+
medium: 8192,
|
|
258
|
+
high: 24576
|
|
259
|
+
}[a] : -1;
|
|
260
|
+
}
|
|
261
|
+
export {
|
|
262
|
+
k as stream,
|
|
263
|
+
Z as streamSimple
|
|
264
|
+
};
|