@llmnative/react 1.10.0 → 1.10.2
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/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8371,7 +8371,13 @@ var al = (e, t) => {
|
|
|
8371
8371
|
model: n,
|
|
8372
8372
|
label: `${t} / ${n}`
|
|
8373
8373
|
})), gl = async (e, t = !1) => {
|
|
8374
|
-
let n = await Promise.all(Object.entries(e).map(async ([e, n]) =>
|
|
8374
|
+
let n = await Promise.all(Object.entries(e).map(async ([e, n]) => {
|
|
8375
|
+
try {
|
|
8376
|
+
return [e, await n.getCapabilities(t)];
|
|
8377
|
+
} catch (t) {
|
|
8378
|
+
return console.warn(`getAIModelCatalog: provider "${e}" getCapabilities() failed`, t), [e, { models: [] }];
|
|
8379
|
+
}
|
|
8380
|
+
})), r = n.reduce((e, [t, n]) => (e[t] = n, e), {}), i = n.reduce((e, [t, n]) => (e[t] = n.models, e), {}), a = /* @__PURE__ */ new Set();
|
|
8375
8381
|
return {
|
|
8376
8382
|
models: n.flatMap(([, e]) => e.models).filter((e) => a.has(e.id) ? !1 : (a.add(e.id), !0)),
|
|
8377
8383
|
modelsByProvider: i,
|
|
@@ -9229,12 +9235,12 @@ var nu = ({ mode: e, availability: n, renderAIUnavailable: r }) => {
|
|
|
9229
9235
|
let { handleChange: C, record: w } = Dd({
|
|
9230
9236
|
name: e,
|
|
9231
9237
|
subscribeToFullRecord: !0
|
|
9232
|
-
}), T = Y("prompt"), E = Fn("prompt"), D = n || e, [O, k] = h(!1), [A, j] = h(o?.value ?? ""), [M, N] = h(!1), [P, F] = h(null), I = $c(), L = el(), R = typeof localStorage < "u"
|
|
9238
|
+
}), T = Y("prompt"), E = Fn("prompt"), D = n || e, [O, k] = h(!1), [A, j] = h(o?.value ?? ""), [M, N] = h(!1), [P, F] = h(null), I = $c(), L = el(), { modelOptions: R } = eu(), z = typeof localStorage < "u" ? localStorage.getItem("prompt.model") : null, B = z && R.some((e) => e.value === z) ? z : "", V = t.useMemo(() => lu(r?.prompt, o), [o, r?.prompt]), H = V.model || B, U = u(), W = tu(H, !!m), ee = !W.configured || !m && !H, [G, te] = h(null), ne = !G && !W.configured ? g?.({
|
|
9233
9239
|
mode: "run",
|
|
9234
|
-
providerId:
|
|
9235
|
-
reason:
|
|
9236
|
-
configured:
|
|
9237
|
-
}) : null,
|
|
9240
|
+
providerId: W.providerId,
|
|
9241
|
+
reason: W.reason,
|
|
9242
|
+
configured: W.configured
|
|
9243
|
+
}) : null, re = t.useMemo(() => {
|
|
9238
9244
|
if (!A) return "";
|
|
9239
9245
|
let e = {
|
|
9240
9246
|
...w,
|
|
@@ -9245,35 +9251,35 @@ var nu = ({ mode: e, availability: n, renderAIUnavailable: r }) => {
|
|
|
9245
9251
|
A,
|
|
9246
9252
|
w,
|
|
9247
9253
|
_
|
|
9248
|
-
]),
|
|
9254
|
+
]), K = re !== A, ie = (e, t) => C?.({ target: {
|
|
9249
9255
|
name: e,
|
|
9250
9256
|
value: t
|
|
9251
|
-
} }),
|
|
9257
|
+
} }), ae = x?.map((e) => e.key === "tokenUsage" && !e.content ? {
|
|
9252
9258
|
...e,
|
|
9253
9259
|
content: P ? /* @__PURE__ */ t.createElement("div", { className: "px-3 py-2 text-xs space-y-1" }, /* @__PURE__ */ t.createElement("p", { className: "font-medium text-foreground" }, E.tokenUsage), /* @__PURE__ */ t.createElement("p", { className: "text-muted-foreground" }, Dn(E.tokenInput, { count: String(P.tokensIn) })), /* @__PURE__ */ t.createElement("p", { className: "text-muted-foreground" }, Dn(E.tokenOutput, { count: String(P.tokensOut) })), P.contextPercent !== null && /* @__PURE__ */ t.createElement("p", { className: "text-muted-foreground" }, Dn(E.tokenContext, { percent: P.contextPercent.toFixed(1) })), P.estimatedCost !== null && /* @__PURE__ */ t.createElement("p", { className: "text-muted-foreground" }, Dn(E.tokenCost, { amount: P.estimatedCost.toFixed(5) })), /* @__PURE__ */ t.createElement("p", { className: "text-muted-foreground" }, Dn(E.tokenTime, { seconds: (P.durationMs / 1e3).toFixed(1) }))) : /* @__PURE__ */ t.createElement("p", { className: "px-3 py-2 text-xs text-muted-foreground" }, E.tokenUsageEmpty)
|
|
9254
|
-
} : e),
|
|
9255
|
-
let n = t.model ||
|
|
9260
|
+
} : e), oe = async (t) => {
|
|
9261
|
+
let n = t.model || H || B, r = Xc(n), i = r ? L?.registry[r.provider] ?? I ?? void 0 : I ?? void 0, a = Date.now();
|
|
9256
9262
|
try {
|
|
9257
9263
|
let r = {
|
|
9258
9264
|
...w,
|
|
9259
9265
|
..._
|
|
9260
9266
|
}, o = await Promise.all(t.files.map((e) => Cl.fileToAttachment(e))), s = await fu({
|
|
9261
|
-
...
|
|
9267
|
+
...V,
|
|
9262
9268
|
model: n,
|
|
9263
|
-
role: t.role ??
|
|
9264
|
-
voice: t.voice ??
|
|
9265
|
-
style: t.style ??
|
|
9266
|
-
language: t.language ??
|
|
9267
|
-
temperature: t.temperature ??
|
|
9269
|
+
role: t.role ?? V.role,
|
|
9270
|
+
voice: t.voice ?? V.voice,
|
|
9271
|
+
style: t.style ?? V.style,
|
|
9272
|
+
language: t.language ?? V.language,
|
|
9273
|
+
temperature: t.temperature ?? V.temperature
|
|
9268
9274
|
}, r, m, i, o.length > 0 ? o : void 0, {
|
|
9269
9275
|
noProvider: E.noProvider,
|
|
9270
9276
|
noResponse: E.noResponse
|
|
9271
9277
|
}), c = Date.now() - a;
|
|
9272
|
-
if (
|
|
9278
|
+
if (te(null), C?.({ target: {
|
|
9273
9279
|
name: e + ".value",
|
|
9274
9280
|
value: s
|
|
9275
|
-
} }), t.role !== void 0 &&
|
|
9276
|
-
let e = Jc.parsePrompt(
|
|
9281
|
+
} }), t.role !== void 0 && ie(e + ".prompt.role", t.role), t.voice !== void 0 && ie(e + ".prompt.voice", t.voice), t.style !== void 0 && ie(e + ".prompt.style", t.style), t.language !== void 0 && ie(e + ".prompt.language", t.language), S && S.length > 0) {
|
|
9282
|
+
let e = Jc.parsePrompt(V.value ?? "", r), t = Cl.countTokens(e), i = Cl.countTokens(s ?? ""), a = Cl.contextPercent(t, n), o = Cl.estimateCost(t, i, n);
|
|
9277
9283
|
F({
|
|
9278
9284
|
tokensIn: t,
|
|
9279
9285
|
tokensOut: i,
|
|
@@ -9284,11 +9290,11 @@ var nu = ({ mode: e, availability: n, renderAIUnavailable: r }) => {
|
|
|
9284
9290
|
});
|
|
9285
9291
|
}
|
|
9286
9292
|
} catch (e) {
|
|
9287
|
-
|
|
9293
|
+
te(Ql(e, E.runFailed));
|
|
9288
9294
|
}
|
|
9289
9295
|
};
|
|
9290
9296
|
return /* @__PURE__ */ t.createElement(Z, { className: f || T.Prompt.wrapperClassName }, /* @__PURE__ */ t.createElement("div", { className: "flex items-center gap-2" }, l && /* @__PURE__ */ t.createElement("div", { className: "shrink-0" }, l), /* @__PURE__ */ t.createElement("div", { className: `${ql} min-w-0 flex-1` }, D && /* @__PURE__ */ t.createElement($l, {
|
|
9291
|
-
htmlFor:
|
|
9297
|
+
htmlFor: U,
|
|
9292
9298
|
label: O ? `${E.promptLabel}${D}` : D,
|
|
9293
9299
|
required: i
|
|
9294
9300
|
}), /* @__PURE__ */ t.createElement("div", { className: "group relative" }, /* @__PURE__ */ t.createElement("button", {
|
|
@@ -9300,7 +9306,7 @@ var nu = ({ mode: e, availability: n, renderAIUnavailable: r }) => {
|
|
|
9300
9306
|
name: O ? "x" : "settings",
|
|
9301
9307
|
size: 13
|
|
9302
9308
|
})), O ? /* @__PURE__ */ t.createElement("div", { className: "overflow-hidden rounded-xl border border-input shadow-sm transition-shadow focus-within:shadow-md focus-within:ring-2 focus-within:ring-warning focus-within:ring-offset-0" }, /* @__PURE__ */ t.createElement(Ps, {
|
|
9303
|
-
id:
|
|
9309
|
+
id: U,
|
|
9304
9310
|
name: e + ".prompt.value",
|
|
9305
9311
|
defaultValue: o?.value,
|
|
9306
9312
|
onChange: (e) => {
|
|
@@ -9312,7 +9318,7 @@ var nu = ({ mode: e, availability: n, renderAIUnavailable: r }) => {
|
|
|
9312
9318
|
className: `${p || T.Prompt.className} ${su}`,
|
|
9313
9319
|
minHeight: s,
|
|
9314
9320
|
maxHeight: c
|
|
9315
|
-
}),
|
|
9321
|
+
}), K && M && /* @__PURE__ */ t.createElement("div", { className: "border-t border-input px-4 py-3 bg-muted/20" }, /* @__PURE__ */ t.createElement("p", { className: "whitespace-pre-wrap text-sm text-foreground/70" }, re)), K && /* @__PURE__ */ t.createElement("div", { className: "flex items-center justify-end border-t border-input px-2 py-1" }, /* @__PURE__ */ t.createElement("button", {
|
|
9316
9322
|
type: "button",
|
|
9317
9323
|
title: M ? E.hidePreview : E.showPreview,
|
|
9318
9324
|
className: `${cu} flex items-center justify-center ${M ? "bg-muted text-foreground" : ""}`,
|
|
@@ -9338,32 +9344,32 @@ var nu = ({ mode: e, availability: n, renderAIUnavailable: r }) => {
|
|
|
9338
9344
|
onChange: C ?? (() => {})
|
|
9339
9345
|
});
|
|
9340
9346
|
},
|
|
9341
|
-
disabled:
|
|
9347
|
+
disabled: ee,
|
|
9342
9348
|
onSubmit: (e) => {
|
|
9343
|
-
|
|
9349
|
+
oe(e);
|
|
9344
9350
|
},
|
|
9345
9351
|
attachments: b,
|
|
9346
9352
|
commands: v,
|
|
9347
9353
|
commandsTrigger: y,
|
|
9348
|
-
models:
|
|
9349
|
-
selectedModel:
|
|
9350
|
-
onModelChange: (t) =>
|
|
9354
|
+
models: R,
|
|
9355
|
+
selectedModel: H,
|
|
9356
|
+
onModelChange: (t) => ie(e + ".prompt.model", t),
|
|
9351
9357
|
showSettings: !0,
|
|
9352
|
-
defaultRole:
|
|
9353
|
-
defaultVoice:
|
|
9354
|
-
defaultStyle:
|
|
9355
|
-
defaultLanguage:
|
|
9356
|
-
defaultTemperature:
|
|
9357
|
-
actions:
|
|
9358
|
+
defaultRole: V.role,
|
|
9359
|
+
defaultVoice: V.voice,
|
|
9360
|
+
defaultStyle: V.style,
|
|
9361
|
+
defaultLanguage: V.language,
|
|
9362
|
+
defaultTemperature: V.temperature,
|
|
9363
|
+
actions: ae,
|
|
9358
9364
|
minHeight: s,
|
|
9359
9365
|
maxHeight: c,
|
|
9360
9366
|
className: p || T.Prompt.className,
|
|
9361
9367
|
wrapperClassName: ""
|
|
9362
|
-
}), (
|
|
9368
|
+
}), (G || !W.configured) && (ne ? /* @__PURE__ */ t.createElement("div", { className: "mt-1" }, ne) : /* @__PURE__ */ t.createElement("span", { className: "mt-1 flex min-w-0 items-center gap-1 text-xs text-warning" }, /* @__PURE__ */ t.createElement(Q, {
|
|
9363
9369
|
name: "triangle-alert",
|
|
9364
9370
|
size: 13,
|
|
9365
9371
|
className: "shrink-0"
|
|
9366
|
-
}), /* @__PURE__ */ t.createElement("span", { className: "truncate" },
|
|
9372
|
+
}), /* @__PURE__ */ t.createElement("span", { className: "truncate" }, G ?? (W.reason || E.aiNotConfiguredShort)))), S && S.length > 0 && P && /* @__PURE__ */ t.createElement("div", { className: "mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 rounded-lg border border-input/50 bg-muted/20 px-4 py-1.5 text-[11px] text-muted-foreground" }, S.map((e) => {
|
|
9367
9373
|
if (typeof e == "string") switch (e) {
|
|
9368
9374
|
case "tokensIn": return /* @__PURE__ */ t.createElement("span", { key: "tokensIn" }, Dn(E.tokenInput, { count: P.tokensIn }));
|
|
9369
9375
|
case "tokensOut": return /* @__PURE__ */ t.createElement("span", { key: "tokensOut" }, Dn(E.tokenOutput, { count: P.tokensOut }));
|