@anvaka/vue-llm 0.3.1 → 0.4.0

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.
@@ -1,37 +1,40 @@
1
- import { ref as u, computed as L, watch as G, onMounted as Ne, onUnmounted as Je, openBlock as o, createElementBlock as n, createElementVNode as s, withModifiers as J, createTextVNode as R, toDisplayString as d, createCommentVNode as r, withDirectives as y, Fragment as S, renderList as z, unref as re, vModelSelect as ue, vModelText as I, vModelCheckbox as Re, normalizeClass as Y, createVNode as je, nextTick as qe } from "vue";
2
- import { useLLM as Oe, createDefaultConfig as de } from "../useLLM.js";
3
- import { DEFAULT_CONFIGS as Be, createProvider as We } from "../../providers/factory.js";
4
- import Ge from "./StoredKeysManager.vue.js";
1
+ import { ref as d, computed as P, watch as Q, onMounted as ze, onUnmounted as Ye, openBlock as o, createElementBlock as n, createElementVNode as a, withModifiers as J, createTextVNode as O, toDisplayString as c, createCommentVNode as r, withDirectives as k, Fragment as f, renderList as $, unref as me, vModelSelect as X, vModelText as R, normalizeClass as q, vModelCheckbox as He, createVNode as Qe, nextTick as Xe } from "vue";
2
+ import { useLLM as Ze, createDefaultConfig as be } from "../useLLM.js";
3
+ import { DEFAULT_CONFIGS as el, createProvider as ll } from "../../providers/factory.js";
4
+ import tl from "./StoredKeysManager.vue.js";
5
5
  /* empty css */
6
- import ze from "../../_virtual/_plugin-vue_export-helper.js";
7
- const Ye = { class: "llm-modal-header" }, He = { key: 0 }, Qe = { class: "llm-modal-body" }, Xe = { key: 0 }, Ze = { class: "llm-form-grid" }, el = ["value"], ll = ["placeholder"], tl = ["placeholder"], sl = { class: "llm-api-key-field" }, al = { class: "llm-api-key-input-row" }, ol = ["placeholder", "required"], nl = { class: "llm-security-note" }, il = { key: 0 }, rl = { class: "llm-model-selector" }, ul = ["disabled"], dl = { value: "" }, vl = ["value"], cl = ["disabled"], ml = {
6
+ import sl from "../../_virtual/_plugin-vue_export-helper.js";
7
+ const al = { class: "llm-modal-header" }, ol = { key: 0 }, nl = { class: "llm-modal-body" }, il = { key: 0 }, rl = { class: "llm-form-grid" }, ul = ["value"], dl = ["placeholder"], cl = { class: "llm-region-row" }, vl = ["value"], ml = {
8
+ key: 0,
9
+ class: "llm-backend-toggle"
10
+ }, bl = ["onClick"], fl = ["placeholder"], gl = { class: "llm-api-key-field" }, pl = { class: "llm-api-key-input-row" }, yl = ["placeholder", "required"], kl = { class: "llm-security-note" }, hl = { key: 0 }, Cl = { class: "llm-model-selector" }, _l = ["disabled"], wl = { value: "" }, Ul = ["value"], Pl = ["disabled"], Tl = {
8
11
  key: 0,
9
12
  class: "llm-model-error"
10
- }, fl = {
13
+ }, Sl = {
11
14
  key: 1,
12
15
  class: "llm-thinking-toggle"
13
- }, bl = { class: "llm-checkbox-label" }, gl = { class: "llm-temperature-field" }, pl = ["disabled"], yl = {
16
+ }, Ml = { class: "llm-checkbox-label" }, Kl = { class: "llm-temperature-field" }, Al = ["disabled"], El = {
14
17
  key: 0,
15
18
  class: "llm-field-note"
16
- }, kl = {
19
+ }, Ll = {
17
20
  key: 1,
18
21
  class: "llm-field-note"
19
- }, hl = { key: 1 }, Cl = {
22
+ }, xl = { key: 1 }, Il = {
20
23
  key: 0,
21
24
  class: "llm-provider-list"
22
- }, _l = ["onClick"], Pl = { class: "llm-provider-info" }, wl = { class: "llm-provider-name-row" }, Sl = { class: "llm-provider-name" }, Tl = {
25
+ }, Vl = ["onClick"], $l = { class: "llm-provider-info" }, Rl = { class: "llm-provider-name-row" }, Bl = { class: "llm-provider-name" }, Dl = {
23
26
  key: 0,
24
27
  class: "llm-disabled-badge"
25
- }, Ml = {
28
+ }, Fl = {
26
29
  key: 0,
27
30
  class: "llm-active-badge"
28
- }, Kl = {
31
+ }, Nl = {
29
32
  key: 1,
30
33
  class: "llm-judge-badge"
31
- }, Ul = { class: "llm-provider-details-row" }, Al = ["onClick", "disabled"], El = { class: "llm-provider-details" }, Ll = ["onClick", "title"], Il = ["onClick", "title"], xl = ["onClick"], Vl = ["onClick"], $l = {
34
+ }, jl = { class: "llm-provider-details-row" }, Jl = ["onClick", "disabled"], Ol = { class: "llm-provider-details" }, ql = ["onClick", "title"], Wl = ["onClick", "title"], Gl = ["onClick"], zl = ["onClick"], Yl = {
32
35
  key: 1,
33
36
  class: "llm-empty-state"
34
- }, Dl = { class: "llm-modal-footer" }, Fl = ["disabled"], H = "judge-provider", Nl = {
37
+ }, Hl = { class: "llm-modal-footer" }, Ql = ["disabled"], Z = "judge-provider", Xl = {
35
38
  __name: "LLMConfigModal",
36
39
  props: {
37
40
  isVisible: Boolean,
@@ -41,345 +44,402 @@ const Ye = { class: "llm-modal-header" }, He = { key: 0 }, Qe = { class: "llm-mo
41
44
  showAllMode: { type: Boolean, default: !1 }
42
45
  },
43
46
  emits: ["close", "configChanged"],
44
- setup(x, { emit: ve }) {
45
- const g = x, j = ve, V = Be, {
46
- client: Jl,
47
- configStore: Rl,
48
- getEnabledConfigs: jl,
49
- getAllConfigs: ce,
50
- getActiveProviderId: Q,
51
- setActiveProviderId: X,
52
- saveConfig: me,
53
- deleteConfig: fe,
54
- enableProvider: be,
55
- disableProvider: ge,
56
- getAvailableModels: pe,
57
- testConnection: Z,
58
- refresh: $,
59
- getStoredKey: ee,
60
- hasStoredKey: le,
61
- getAllStoredKeys: ye,
62
- storeKey: ql
63
- } = Oe(), t = u(de("")), T = u([]), M = u(null), k = u(null), v = u(!1), f = u(null), K = u(!1), c = u(null), U = u([]), _ = u(!1), h = u(null), C = u(/* @__PURE__ */ new Map()), q = u(!1), te = u(0), P = u(null), A = L(
64
- () => t.value.provider ? V[t.value.provider] : null
65
- ), b = u(/* @__PURE__ */ new Set()), ke = L(() => t.value.model && b.value.has("thinking")), D = L(() => {
47
+ setup(B, { emit: fe }) {
48
+ const h = B, ee = fe, K = el, {
49
+ client: Zl,
50
+ configStore: et,
51
+ getEnabledConfigs: lt,
52
+ getAllConfigs: ge,
53
+ getActiveProviderId: le,
54
+ setActiveProviderId: te,
55
+ saveConfig: pe,
56
+ deleteConfig: ye,
57
+ enableProvider: ke,
58
+ disableProvider: he,
59
+ getAvailableModels: Ce,
60
+ testConnection: se,
61
+ refresh: D,
62
+ getStoredKey: ae,
63
+ hasStoredKey: oe,
64
+ getAllStoredKeys: _e,
65
+ storeKey: tt
66
+ } = Ze(), t = d(be("")), A = d([]), E = d(null), _ = d(null), v = d(!1), g = d(null), L = d(!1), m = d(null), x = d([]), T = d(!1), w = d(null), U = d(/* @__PURE__ */ new Map()), W = d(!1), ne = d(0), S = d(null), C = P(
67
+ () => t.value.provider ? K[t.value.provider] : null
68
+ ), ie = P(() => {
69
+ var l;
70
+ return ((l = C.value) == null ? void 0 : l.regions) || [];
71
+ }), re = P(() => {
72
+ var e;
73
+ const l = (e = C.value) == null ? void 0 : e.backends;
74
+ return l ? Object.entries(l).map(([i, u]) => ({ key: i, label: u.label || i, baseUrlTemplate: u.baseUrlTemplate })) : [];
75
+ }), we = () => {
76
+ var e;
77
+ const l = C.value;
78
+ return l != null && l.backends && t.value.backend ? (e = l.backends[t.value.backend]) == null ? void 0 : e.baseUrlTemplate : l == null ? void 0 : l.baseUrlTemplate;
79
+ }, G = () => {
80
+ const l = we();
81
+ l && t.value.region && (t.value.baseUrl = l.replace("{region}", t.value.region));
82
+ }, Ue = () => {
83
+ G(), t.value.model = "", I();
84
+ }, Pe = (l) => {
85
+ t.value.backend !== l && (t.value.backend = l, G(), t.value.model = "", I());
86
+ }, z = (l, e) => {
87
+ if (!l || !e) return null;
88
+ const i = l.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), u = new RegExp("^" + i.replace("\\{region\\}", "([^.]+)") + "$"), b = e.match(u);
89
+ return b ? b[1] : null;
90
+ }, Te = (l, e) => {
91
+ const i = l == null ? void 0 : l.backends;
92
+ if (!i) return "";
93
+ for (const [u, b] of Object.entries(i))
94
+ if (z(b.baseUrlTemplate, e) != null) return u;
95
+ return l.defaultBackend || Object.keys(i)[0];
96
+ }, p = d(/* @__PURE__ */ new Set()), Se = P(() => t.value.model && p.value.has("thinking")), F = P(() => {
66
97
  var e, i;
67
98
  if (!((e = t.value) != null && e.provider) || !((i = t.value) != null && i.model) || t.value.provider !== "openai") return !1;
68
99
  const l = String(t.value.model).toLowerCase();
69
- return b.value.has("thinking") || l.startsWith("o1") || l.startsWith("o2") || l.startsWith("o3") || l.startsWith("o-") || l.includes("gpt-5") || l === "gpt5" || l.includes("reasoning");
70
- }), he = L(() => te.value > 0), se = L(() => {
100
+ return p.value.has("thinking") || l.startsWith("o1") || l.startsWith("o2") || l.startsWith("o3") || l.startsWith("o-") || l.includes("gpt-5") || l === "gpt5" || l.includes("reasoning");
101
+ }), Me = P(() => ne.value > 0), ue = P(() => {
71
102
  var l;
72
- return !(!t.value.name || !t.value.provider || !t.value.baseUrl || (l = A.value) != null && l.requiresApiKey && !t.value.apiKey);
73
- }), Ce = (l) => {
74
- const e = C.value.get(l);
103
+ return !(!t.value.name || !t.value.provider || !t.value.baseUrl || (l = C.value) != null && l.requiresApiKey && !t.value.apiKey);
104
+ }), Ke = (l) => {
105
+ const e = U.value.get(l);
75
106
  return e === "testing" ? "Testing..." : e === "success" ? "Ok" : e === "failed" ? "Failed" : "Test";
76
- }, _e = (l) => {
77
- const e = C.value.get(l);
107
+ }, Ae = (l) => {
108
+ const e = U.value.get(l);
78
109
  return {
79
110
  "llm-test-testing": e === "testing",
80
111
  "llm-test-success": e === "success",
81
112
  "llm-test-failed": e === "failed",
82
113
  "llm-test-default": !e || e === "default"
83
114
  };
84
- }, F = () => {
85
- if (T.value = ce(), M.value = Q() || "", g.showJudge)
115
+ }, N = () => {
116
+ if (A.value = ge(), E.value = le() || "", h.showJudge)
86
117
  try {
87
- k.value = localStorage.getItem("llm:" + H) || null;
118
+ _.value = localStorage.getItem("llm:" + Z) || null;
88
119
  } catch {
89
- k.value = null;
120
+ _.value = null;
90
121
  }
91
- }, O = () => {
92
- const l = ye();
93
- te.value = Object.keys(l).length;
94
- }, Pe = async () => {
95
- const l = A.value;
122
+ }, Y = () => {
123
+ const l = _e();
124
+ ne.value = Object.keys(l).length;
125
+ }, Ee = async () => {
126
+ var e;
127
+ const l = C.value;
96
128
  if (l) {
97
- t.value.baseUrl = l.baseUrl, t.value.model = "", t.value.enableThinking = !1, b.value.clear(), f.value || (t.value.name = "");
98
- const e = ee(t.value.provider);
99
- e && !t.value.apiKey && (t.value.apiKey = e), await B();
129
+ (e = l.regions) != null && e.length ? (t.value.region = l.defaultRegion, t.value.backend = l.defaultBackend || "", G()) : (t.value.region = "", t.value.backend = "", t.value.baseUrl = l.baseUrl), t.value.model = "", t.value.enableThinking = !1, p.value.clear(), g.value || (t.value.name = "");
130
+ const i = ae(t.value.provider);
131
+ i && !t.value.apiKey && (t.value.apiKey = i), await I();
100
132
  }
101
- c.value = null, h.value = null;
102
- }, B = async () => {
133
+ m.value = null, w.value = null;
134
+ }, Le = () => I({ force: !0 }), I = async (l = {}) => {
103
135
  if (!t.value.provider || !t.value.baseUrl) {
104
- U.value = [], h.value = null;
136
+ x.value = [], w.value = null;
105
137
  return;
106
138
  }
107
- _.value = !0, h.value = null;
139
+ T.value = !0, w.value = null;
108
140
  try {
109
- const l = await pe(t.value.provider, t.value);
110
- U.value = l, l.length > 0 && !t.value.model && (t.value.model = l[0], await W());
111
- } catch (l) {
112
- console.warn("Failed to load models:", l), U.value = [], h.value = l.message || "Failed to load models";
141
+ const e = await Ce(t.value.provider, t.value, l);
142
+ x.value = e, e.length > 0 && !t.value.model && (t.value.model = e[0], await H());
143
+ } catch (e) {
144
+ console.warn("Failed to load models:", e), x.value = [], w.value = e.message || "Failed to load models";
113
145
  } finally {
114
- _.value = !1;
146
+ T.value = !1;
115
147
  }
116
- }, W = async () => {
148
+ }, H = async () => {
117
149
  if (!t.value.provider || !t.value.model) {
118
- b.value.clear();
150
+ p.value.clear();
119
151
  return;
120
152
  }
121
153
  try {
122
- const l = { ...t.value }, e = We(l.provider, l);
123
- await e.initialize(), b.value = new Set(e.capabilities), b.value.has("thinking") || (t.value.enableThinking = !1);
154
+ const l = { ...t.value }, e = ll(l.provider, l);
155
+ await e.initialize(), p.value = new Set(e.capabilities), p.value.has("thinking") || (t.value.enableThinking = !1);
124
156
  } catch (l) {
125
- console.warn("Failed to detect model capabilities:", l), b.value.clear();
157
+ console.warn("Failed to detect model capabilities:", l), p.value.clear();
126
158
  }
127
- }, we = () => `provider_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, Se = () => {
159
+ }, xe = () => `provider_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, Ie = () => {
128
160
  if (!t.value.provider) return "";
129
- const l = V[t.value.provider];
161
+ const l = K[t.value.provider];
130
162
  return `e.g., My ${(l == null ? void 0 : l.name) || "Provider"}`;
131
- }, Te = () => {
163
+ }, Ve = () => {
132
164
  if (!t.value.provider || !t.value.model) return "";
133
- const l = V[t.value.provider], e = (l == null ? void 0 : l.name) || "Provider";
165
+ const l = K[t.value.provider], e = (l == null ? void 0 : l.name) || "Provider";
134
166
  let i = t.value.model;
135
- return i.includes("/") && (i = i.split("/").pop()), i = i.replace(/-(instruct|chat|base|completion)$/i, "").replace(/^(gpt-|claude-|llama-|gemini-)/i, "").replace(/-vision$/, "").replace(/-\d+b?$/i, ""), i = i.split("-").map((m) => m.charAt(0).toUpperCase() + m.slice(1)).join(" ").substring(0, 20), `${e} ${i}`.trim();
136
- }, Me = async () => {
137
- if (se.value) {
138
- K.value = !0, c.value = null;
167
+ return i.includes("/") && (i = i.split("/").pop()), i = i.replace(/-(instruct|chat|base|completion)$/i, "").replace(/^(gpt-|claude-|llama-|gemini-)/i, "").replace(/-vision$/, "").replace(/-\d+b?$/i, ""), i = i.split("-").map((u) => u.charAt(0).toUpperCase() + u.slice(1)).join(" ").substring(0, 20), `${e} ${i}`.trim();
168
+ }, $e = async () => {
169
+ if (ue.value) {
170
+ L.value = !0, m.value = null;
139
171
  try {
140
- await Z(t.value);
141
- const l = v.value && f.value ? f.value : we();
142
- me(l, t.value) ? (Q() || (X(l), M.value = l), await $(), c.value = {
172
+ await se(t.value);
173
+ const l = v.value && g.value ? g.value : xe();
174
+ pe(l, t.value) ? (le() || (te(l), E.value = l), await D(), m.value = {
143
175
  success: !0,
144
176
  message: v.value ? "Provider updated!" : "Provider added!"
145
- }, F(), w(), E(), setTimeout(() => j("close"), 1500)) : c.value = { success: !1, message: "Failed to save configuration." };
177
+ }, N(), M(), V()) : m.value = { success: !1, message: "Failed to save configuration." };
146
178
  } catch (l) {
147
- console.error("LLM connection test failed:", l), c.value = { success: !1, message: `Connection failed: ${l.message}` };
179
+ console.error("LLM connection test failed:", l), m.value = { success: !1, message: `Connection failed: ${l.message}` };
148
180
  } finally {
149
- K.value = !1;
181
+ L.value = !1;
150
182
  }
151
183
  }
152
- }, Ke = (l) => {
153
- X(l) && (M.value = l, $(), E());
154
- }, Ue = async (l) => {
155
- C.value.set(l.id, "testing");
184
+ }, Re = (l) => {
185
+ te(l) && (E.value = l, D(), V());
186
+ }, Be = async (l) => {
187
+ U.value.set(l.id, "testing");
156
188
  try {
157
- await Z(l), C.value.set(l.id, "success"), setTimeout(() => C.value.set(l.id, "default"), 3e3);
189
+ await se(l), U.value.set(l.id, "success"), setTimeout(() => U.value.set(l.id, "default"), 3e3);
158
190
  } catch (e) {
159
- console.error("LLM connection test failed:", e), C.value.set(l.id, "failed"), setTimeout(() => C.value.set(l.id, "default"), 5e3);
191
+ console.error("LLM connection test failed:", e), U.value.set(l.id, "failed"), setTimeout(() => U.value.set(l.id, "default"), 5e3);
160
192
  }
161
- }, ae = (l) => {
162
- var e;
163
- t.value = { ...l }, v.value = !0, f.value = l.id, c.value = null, B().then(() => {
164
- t.value.model && W();
165
- }), (e = g.editTarget) != null && e.focusField && qe(() => {
166
- var i, m;
167
- g.editTarget.focusField === "maxTokens" && (P != null && P.value) && (P.value.focus(), (m = (i = P.value).select) == null || m.call(i));
193
+ }, de = (l) => {
194
+ var i, u;
195
+ t.value = { ...l };
196
+ const e = K[l.provider];
197
+ e != null && e.backends ? (t.value.backend || (t.value.backend = Te(e, l.baseUrl)), t.value.region || (t.value.region = z((i = e.backends[t.value.backend]) == null ? void 0 : i.baseUrlTemplate, l.baseUrl) || e.defaultRegion)) : e != null && e.baseUrlTemplate && !t.value.region && (t.value.region = z(e.baseUrlTemplate, l.baseUrl) || e.defaultRegion), v.value = !0, g.value = l.id, m.value = null, I().then(() => {
198
+ t.value.model && H();
199
+ }), (u = h.editTarget) != null && u.focusField && Xe(() => {
200
+ var b, s;
201
+ h.editTarget.focusField === "maxTokens" && (S != null && S.value) && (S.value.focus(), (s = (b = S.value).select) == null || s.call(b));
168
202
  });
169
- }, Ae = () => {
170
- w(), v.value = !0, f.value = null;
171
- }, Ee = () => w(), Le = (l) => {
172
- confirm("Are you sure you want to delete this provider?") && fe(l) && (F(), l === f.value && w(), $(), E());
173
- }, Ie = (l) => {
174
- (l.enabled !== !1 ? ge(l.id) : be(l.id)) && (F(), $(), E());
175
- }, w = () => {
176
- t.value = de(""), v.value = !1, f.value = null, c.value = null, U.value = [], h.value = null, b.value.clear();
177
- }, N = () => {
178
- w(), j("close");
179
- }, oe = (l) => {
180
- g.isVisible && l.key === "Escape" && (l.preventDefault(), N());
181
- }, E = () => {
182
- j("configChanged");
203
+ }, De = () => {
204
+ M(), v.value = !0, g.value = null;
205
+ }, Fe = () => M(), Ne = (l) => {
206
+ confirm("Are you sure you want to delete this provider?") && ye(l) && (N(), l === g.value && M(), D(), V());
207
+ }, je = (l) => {
208
+ (l.enabled !== !1 ? he(l.id) : ke(l.id)) && (N(), D(), V());
209
+ }, M = () => {
210
+ t.value = be(""), v.value = !1, g.value = null, m.value = null, x.value = [], w.value = null, p.value.clear();
211
+ }, j = () => {
212
+ M(), ee("close");
213
+ }, ce = (l) => {
214
+ h.isVisible && l.key === "Escape" && (l.preventDefault(), j());
215
+ }, V = () => {
216
+ ee("configChanged");
183
217
  try {
184
218
  window.dispatchEvent(new CustomEvent("llm-config-changed"));
185
219
  } catch {
186
220
  }
187
221
  };
188
- G(() => g.isVisible, (l) => {
222
+ Q(() => h.isVisible, (l) => {
189
223
  var e;
190
- if (l && (F(), O(), w(), (e = g.editTarget) != null && e.name && T.value.length > 0)) {
191
- const i = T.value.find((m) => m.name === g.editTarget.name);
192
- i && ae(i);
224
+ if (l && (N(), Y(), M(), (e = h.editTarget) != null && e.name && A.value.length > 0)) {
225
+ const i = A.value.find((u) => u.name === h.editTarget.name);
226
+ i && de(i);
193
227
  }
194
- }), G(() => t.value.model, (l) => {
228
+ }), Q(() => t.value.model, (l) => {
195
229
  if (l) {
196
- if (W(), !f.value) {
197
- const e = Te();
230
+ if (H(), !g.value) {
231
+ const e = Ve();
198
232
  e && (t.value.name = e);
199
233
  }
200
- D.value && (t.value.temperature = 1);
234
+ F.value && (t.value.temperature = 1);
201
235
  } else
202
- b.value.clear(), t.value.enableThinking = !1;
203
- }), G(() => t.value.temperature, (l) => {
204
- D.value && l !== 1 && (t.value.temperature = 1);
236
+ p.value.clear(), t.value.enableThinking = !1;
237
+ }), Q(() => t.value.temperature, (l) => {
238
+ F.value && l !== 1 && (t.value.temperature = 1);
205
239
  });
206
- const xe = () => {
207
- q.value = !0;
208
- }, ne = () => {
209
- q.value = !1;
210
- }, Ve = () => {
211
- O();
212
- }, $e = () => t.value.provider === "custom" ? "Enter your API key (optional)" : le(t.value.provider) ? "Using stored key (or enter new)" : "Enter your API key", De = () => {
213
- const l = ee(t.value.provider);
240
+ const Je = () => {
241
+ W.value = !0;
242
+ }, ve = () => {
243
+ W.value = !1;
244
+ }, Oe = () => {
245
+ Y();
246
+ }, qe = () => t.value.provider === "custom" ? "Enter your API key (optional)" : oe(t.value.provider) ? "Using stored key (or enter new)" : "Enter your API key", We = () => {
247
+ const l = ae(t.value.provider);
214
248
  l && (t.value.apiKey = l);
215
- }, Fe = (l) => {
216
- if (!g.showJudge) return;
217
- const e = l.id === k.value ? null : l.id;
249
+ }, Ge = (l) => {
250
+ if (!h.showJudge) return;
251
+ const e = l.id === _.value ? null : l.id;
218
252
  try {
219
- e ? localStorage.setItem("llm:" + H, e) : localStorage.removeItem("llm:" + H), k.value = e, E();
253
+ e ? localStorage.setItem("llm:" + Z, e) : localStorage.removeItem("llm:" + Z), _.value = e, V();
220
254
  } catch {
221
255
  }
222
256
  };
223
- return Ne(() => {
224
- document.addEventListener("keydown", oe), O();
225
- }), Je(() => {
226
- document.removeEventListener("keydown", oe);
257
+ return ze(() => {
258
+ document.addEventListener("keydown", ce), Y();
259
+ }), Ye(() => {
260
+ document.removeEventListener("keydown", ce);
227
261
  }), (l, e) => {
228
- var i, m, ie;
229
- return x.isVisible ? (o(), n("div", {
262
+ var i, u, b;
263
+ return B.isVisible ? (o(), n("div", {
230
264
  key: 0,
231
265
  class: "llm-modal-overlay",
232
- onClick: N
266
+ onClick: j
233
267
  }, [
234
- s("div", {
268
+ a("div", {
235
269
  class: "llm-modal",
236
- onClick: e[11] || (e[11] = J(() => {
270
+ onClick: e[12] || (e[12] = J(() => {
237
271
  }, ["stop"]))
238
272
  }, [
239
- s("div", Ye, [
240
- s("h2", null, [
241
- e[12] || (e[12] = R(" Manage LLM Providers ", -1)),
242
- v.value ? (o(), n("span", He, d(f.value ? " - Edit" : " - Add"), 1)) : r("", !0)
273
+ a("div", al, [
274
+ a("h2", null, [
275
+ e[13] || (e[13] = O(" Manage LLM Providers ", -1)),
276
+ v.value ? (o(), n("span", ol, c(g.value ? " - Edit" : " - Add"), 1)) : r("", !0)
243
277
  ]),
244
- s("button", {
278
+ a("button", {
245
279
  class: "llm-btn llm-btn--ghost llm-btn--sm llm-close-btn",
246
- onClick: N
280
+ onClick: j
247
281
  }, "×")
248
282
  ]),
249
- s("div", Qe, [
250
- v.value ? (o(), n("div", Xe, [
251
- s("div", Ze, [
252
- e[22] || (e[22] = s("label", { class: "llm-field-label" }, "Provider Type:", -1)),
253
- y(s("select", {
254
- "onUpdate:modelValue": e[0] || (e[0] = (a) => t.value.provider = a),
255
- onChange: Pe,
283
+ a("div", nl, [
284
+ v.value ? (o(), n("div", il, [
285
+ a("div", rl, [
286
+ e[24] || (e[24] = a("label", { class: "llm-field-label" }, "Provider Type:", -1)),
287
+ k(a("select", {
288
+ "onUpdate:modelValue": e[0] || (e[0] = (s) => t.value.provider = s),
289
+ onChange: Ee,
256
290
  class: "llm-form-control"
257
291
  }, [
258
- e[13] || (e[13] = s("option", { value: "" }, "Select a provider...", -1)),
259
- (o(!0), n(S, null, z(re(V), (a, p) => (o(), n("option", {
260
- key: p,
261
- value: p
262
- }, d(a.name), 9, el))), 128))
292
+ e[14] || (e[14] = a("option", { value: "" }, "Select a provider...", -1)),
293
+ (o(!0), n(f, null, $(me(K), (s, y) => (o(), n("option", {
294
+ key: y,
295
+ value: y
296
+ }, c(s.name), 9, ul))), 128))
263
297
  ], 544), [
264
- [ue, t.value.provider]
298
+ [X, t.value.provider]
265
299
  ]),
266
- t.value.provider ? (o(), n(S, { key: 0 }, [
267
- e[14] || (e[14] = s("label", { class: "llm-field-label" }, "Provider Name:", -1)),
268
- y(s("input", {
269
- "onUpdate:modelValue": e[1] || (e[1] = (a) => t.value.name = a),
300
+ t.value.provider ? (o(), n(f, { key: 0 }, [
301
+ e[15] || (e[15] = a("label", { class: "llm-field-label" }, "Provider Name:", -1)),
302
+ k(a("input", {
303
+ "onUpdate:modelValue": e[1] || (e[1] = (s) => t.value.name = s),
270
304
  type: "text",
271
- placeholder: Se(),
305
+ placeholder: Ie(),
272
306
  class: "llm-form-control",
273
307
  required: ""
274
- }, null, 8, ll), [
275
- [I, t.value.name]
308
+ }, null, 8, dl), [
309
+ [R, t.value.name]
276
310
  ])
277
311
  ], 64)) : r("", !0),
278
- t.value.provider ? (o(), n(S, { key: 1 }, [
279
- e[18] || (e[18] = s("label", { class: "llm-field-label" }, "Base URL:", -1)),
280
- y(s("input", {
281
- "onUpdate:modelValue": e[2] || (e[2] = (a) => t.value.baseUrl = a),
282
- type: "url",
283
- placeholder: (i = A.value) == null ? void 0 : i.baseUrl,
284
- class: "llm-form-control",
285
- required: ""
286
- }, null, 8, tl), [
287
- [I, t.value.baseUrl]
288
- ]),
289
- (m = A.value) != null && m.requiresApiKey || t.value.provider === "custom" ? (o(), n(S, { key: 0 }, [
290
- e[16] || (e[16] = s("label", { class: "llm-field-label" }, "API Key:", -1)),
291
- s("div", sl, [
292
- s("div", al, [
293
- y(s("input", {
294
- "onUpdate:modelValue": e[3] || (e[3] = (a) => t.value.apiKey = a),
312
+ t.value.provider ? (o(), n(f, { key: 1 }, [
313
+ ie.value.length ? (o(), n(f, { key: 0 }, [
314
+ e[16] || (e[16] = a("label", { class: "llm-field-label" }, "Region:", -1)),
315
+ a("div", cl, [
316
+ k(a("select", {
317
+ "onUpdate:modelValue": e[2] || (e[2] = (s) => t.value.region = s),
318
+ onChange: Ue,
319
+ class: "llm-form-control"
320
+ }, [
321
+ (o(!0), n(f, null, $(ie.value, (s) => (o(), n("option", {
322
+ key: s,
323
+ value: s
324
+ }, c(s), 9, vl))), 128))
325
+ ], 544), [
326
+ [X, t.value.region]
327
+ ]),
328
+ re.value.length > 1 ? (o(), n("div", ml, [
329
+ (o(!0), n(f, null, $(re.value, (s) => (o(), n("button", {
330
+ key: s.key,
331
+ type: "button",
332
+ class: q(["llm-backend-btn", { active: t.value.backend === s.key }]),
333
+ onClick: (y) => Pe(s.key)
334
+ }, c(s.label), 11, bl))), 128))
335
+ ])) : r("", !0)
336
+ ])
337
+ ], 64)) : (o(), n(f, { key: 1 }, [
338
+ e[17] || (e[17] = a("label", { class: "llm-field-label" }, "Base URL:", -1)),
339
+ k(a("input", {
340
+ "onUpdate:modelValue": e[3] || (e[3] = (s) => t.value.baseUrl = s),
341
+ type: "url",
342
+ placeholder: (i = C.value) == null ? void 0 : i.baseUrl,
343
+ class: "llm-form-control",
344
+ required: ""
345
+ }, null, 8, fl), [
346
+ [R, t.value.baseUrl]
347
+ ])
348
+ ], 64)),
349
+ (u = C.value) != null && u.requiresApiKey || t.value.provider === "custom" ? (o(), n(f, { key: 2 }, [
350
+ e[19] || (e[19] = a("label", { class: "llm-field-label" }, "API Key:", -1)),
351
+ a("div", gl, [
352
+ a("div", pl, [
353
+ k(a("input", {
354
+ "onUpdate:modelValue": e[4] || (e[4] = (s) => t.value.apiKey = s),
295
355
  type: "password",
296
- placeholder: $e(),
356
+ placeholder: qe(),
297
357
  class: "llm-form-control",
298
- required: (ie = A.value) == null ? void 0 : ie.requiresApiKey
299
- }, null, 8, ol), [
300
- [I, t.value.apiKey]
358
+ required: (b = C.value) == null ? void 0 : b.requiresApiKey
359
+ }, null, 8, yl), [
360
+ [R, t.value.apiKey]
301
361
  ]),
302
- re(le)(t.value.provider) ? (o(), n("button", {
362
+ me(oe)(t.value.provider) ? (o(), n("button", {
303
363
  key: 0,
304
364
  type: "button",
305
365
  class: "llm-btn llm-btn--ghost llm-btn--sm",
306
- onClick: De,
366
+ onClick: We,
307
367
  title: "Use stored key"
308
368
  }, " Use Stored ")) : r("", !0)
309
369
  ]),
310
- s("small", nl, [
311
- e[15] || (e[15] = R(" ⚠️ API key is stored locally in your browser ", -1)),
312
- t.value.provider === "custom" ? (o(), n("span", il, " (optional for custom providers)")) : r("", !0)
370
+ a("small", kl, [
371
+ e[18] || (e[18] = O(" ⚠️ API key is stored locally in your browser ", -1)),
372
+ t.value.provider === "custom" ? (o(), n("span", hl, " (optional for custom providers)")) : r("", !0)
313
373
  ])
314
374
  ])
315
375
  ], 64)) : r("", !0),
316
- e[19] || (e[19] = s("label", { class: "llm-field-label" }, "Model:", -1)),
317
- s("div", rl, [
318
- y(s("select", {
319
- "onUpdate:modelValue": e[4] || (e[4] = (a) => t.value.model = a),
320
- disabled: _.value,
376
+ e[21] || (e[21] = a("label", { class: "llm-field-label" }, "Model:", -1)),
377
+ a("div", Cl, [
378
+ k(a("select", {
379
+ "onUpdate:modelValue": e[5] || (e[5] = (s) => t.value.model = s),
380
+ disabled: T.value,
321
381
  class: "llm-form-control"
322
382
  }, [
323
- s("option", dl, d(_.value ? "Loading models..." : "Select a model..."), 1),
324
- (o(!0), n(S, null, z(U.value, (a) => (o(), n("option", {
325
- key: a,
326
- value: a
327
- }, d(a), 9, vl))), 128))
328
- ], 8, ul), [
329
- [ue, t.value.model]
383
+ a("option", wl, c(T.value ? "Loading models..." : "Select a model..."), 1),
384
+ (o(!0), n(f, null, $(x.value, (s) => (o(), n("option", {
385
+ key: s,
386
+ value: s
387
+ }, c(s), 9, Ul))), 128))
388
+ ], 8, _l), [
389
+ [X, t.value.model]
330
390
  ]),
331
- s("button", {
391
+ a("button", {
332
392
  class: "llm-btn llm-btn--ghost llm-btn--sm llm-refresh-btn",
333
- onClick: B,
334
- disabled: !t.value.baseUrl || _.value,
393
+ onClick: Le,
394
+ disabled: !t.value.baseUrl || T.value,
335
395
  title: "Refresh models list"
336
- }, d(_.value ? "Loading..." : "Refresh"), 9, cl),
337
- h.value ? (o(), n("div", ml, d(h.value), 1)) : r("", !0),
338
- ke.value ? (o(), n("div", fl, [
339
- s("label", bl, [
340
- y(s("input", {
396
+ }, c(T.value ? "Loading..." : "Refresh"), 9, Pl),
397
+ w.value ? (o(), n("div", Tl, c(w.value), 1)) : r("", !0),
398
+ Se.value ? (o(), n("div", Sl, [
399
+ a("label", Ml, [
400
+ k(a("input", {
341
401
  type: "checkbox",
342
- "onUpdate:modelValue": e[5] || (e[5] = (a) => t.value.enableThinking = a),
402
+ "onUpdate:modelValue": e[6] || (e[6] = (s) => t.value.enableThinking = s),
343
403
  class: "llm-checkbox"
344
404
  }, null, 512), [
345
- [Re, t.value.enableThinking]
405
+ [He, t.value.enableThinking]
346
406
  ]),
347
- e[17] || (e[17] = R(" Enable Thinking: Show model's reasoning process ", -1))
407
+ e[20] || (e[20] = O(" Enable Thinking: Show model's reasoning process ", -1))
348
408
  ])
349
409
  ])) : r("", !0)
350
410
  ]),
351
- e[20] || (e[20] = s("label", { class: "llm-field-label" }, "Temperature:", -1)),
352
- s("div", gl, [
353
- y(s("input", {
354
- "onUpdate:modelValue": e[6] || (e[6] = (a) => t.value.temperature = a),
411
+ e[22] || (e[22] = a("label", { class: "llm-field-label" }, "Temperature:", -1)),
412
+ a("div", Kl, [
413
+ k(a("input", {
414
+ "onUpdate:modelValue": e[7] || (e[7] = (s) => t.value.temperature = s),
355
415
  type: "number",
356
416
  min: "0",
357
417
  max: "2",
358
418
  step: "0.1",
359
419
  class: "llm-form-control",
360
- disabled: D.value
361
- }, null, 8, pl), [
420
+ disabled: F.value
421
+ }, null, 8, Al), [
362
422
  [
363
- I,
423
+ R,
364
424
  t.value.temperature,
365
425
  void 0,
366
426
  { number: !0 }
367
427
  ]
368
428
  ]),
369
- D.value ? (o(), n("small", kl, " This model uses a fixed temperature of 1. ")) : (o(), n("small", yl, " Controls randomness: 0 = deterministic, 2 = very creative "))
429
+ F.value ? (o(), n("small", Ll, " This model uses a fixed temperature of 1. ")) : (o(), n("small", El, " Controls randomness: 0 = deterministic, 2 = very creative "))
370
430
  ]),
371
- e[21] || (e[21] = s("label", { class: "llm-field-label" }, "Max Tokens:", -1)),
372
- y(s("input", {
373
- "onUpdate:modelValue": e[7] || (e[7] = (a) => t.value.maxTokens = a),
431
+ e[23] || (e[23] = a("label", { class: "llm-field-label" }, "Max Tokens:", -1)),
432
+ k(a("input", {
433
+ "onUpdate:modelValue": e[8] || (e[8] = (s) => t.value.maxTokens = s),
374
434
  type: "number",
375
435
  min: "1",
376
436
  max: "100000",
377
437
  class: "llm-form-control",
378
438
  ref_key: "maxTokensInput",
379
- ref: P
439
+ ref: S
380
440
  }, null, 512), [
381
441
  [
382
- I,
442
+ R,
383
443
  t.value.maxTokens,
384
444
  void 0,
385
445
  { number: !0 }
@@ -387,116 +447,116 @@ const Ye = { class: "llm-modal-header" }, He = { key: 0 }, Qe = { class: "llm-mo
387
447
  ])
388
448
  ], 64)) : r("", !0)
389
449
  ]),
390
- c.value ? (o(), n("div", {
450
+ m.value ? (o(), n("div", {
391
451
  key: 0,
392
- class: Y(["llm-test-result", c.value.success ? "llm-test-result--success" : "llm-test-result--error"])
393
- }, d(c.value.message), 3)) : r("", !0)
394
- ])) : (o(), n("div", hl, [
395
- T.value.length > 0 ? (o(), n("div", Cl, [
396
- e[23] || (e[23] = s("h3", null, "Configured Providers", -1)),
397
- (o(!0), n(S, null, z(T.value, (a) => (o(), n("div", {
398
- key: a.id,
399
- class: Y(["llm-provider-item", {
400
- active: a.id === M.value,
401
- disabled: a.enabled === !1
452
+ class: q(["llm-test-result", m.value.success ? "llm-test-result--success" : "llm-test-result--error"])
453
+ }, c(m.value.message), 3)) : r("", !0)
454
+ ])) : (o(), n("div", xl, [
455
+ A.value.length > 0 ? (o(), n("div", Il, [
456
+ e[25] || (e[25] = a("h3", null, "Configured Providers", -1)),
457
+ (o(!0), n(f, null, $(A.value, (s) => (o(), n("div", {
458
+ key: s.id,
459
+ class: q(["llm-provider-item", {
460
+ active: s.id === E.value,
461
+ disabled: s.enabled === !1
402
462
  }]),
403
- onClick: (p) => a.enabled !== !1 ? Ke(a.id) : null
463
+ onClick: (y) => s.enabled !== !1 ? Re(s.id) : null
404
464
  }, [
405
- s("div", Pl, [
406
- s("div", wl, [
407
- s("div", Sl, [
408
- R(d(a.name) + " ", 1),
409
- a.enabled === !1 ? (o(), n("span", Tl, "Disabled")) : r("", !0)
465
+ a("div", $l, [
466
+ a("div", Rl, [
467
+ a("div", Bl, [
468
+ O(c(s.name) + " ", 1),
469
+ s.enabled === !1 ? (o(), n("span", Dl, "Disabled")) : r("", !0)
410
470
  ]),
411
- a.id === M.value ? (o(), n("span", Ml, "Active")) : r("", !0),
412
- x.showJudge && a.id === k.value ? (o(), n("span", Kl, "Judge")) : r("", !0)
471
+ s.id === E.value ? (o(), n("span", Fl, "Active")) : r("", !0),
472
+ B.showJudge && s.id === _.value ? (o(), n("span", Nl, "Judge")) : r("", !0)
413
473
  ]),
414
- s("div", Ul, [
415
- s("button", {
416
- class: Y(["llm-test-status-btn", _e(a.id)]),
417
- onClick: J((p) => Ue(a), ["stop"]),
418
- disabled: K.value
419
- }, d(Ce(a.id)), 11, Al),
420
- s("div", El, d(a.provider) + " • " + d(a.baseUrl), 1)
474
+ a("div", jl, [
475
+ a("button", {
476
+ class: q(["llm-test-status-btn", Ae(s.id)]),
477
+ onClick: J((y) => Be(s), ["stop"]),
478
+ disabled: L.value
479
+ }, c(Ke(s.id)), 11, Jl),
480
+ a("div", Ol, c(s.provider) + " • " + c(s.baseUrl), 1)
421
481
  ])
422
482
  ]),
423
- s("div", {
483
+ a("div", {
424
484
  class: "llm-provider-actions",
425
- onClick: e[8] || (e[8] = J(() => {
485
+ onClick: e[9] || (e[9] = J(() => {
426
486
  }, ["stop"]))
427
487
  }, [
428
- x.showJudge && a.enabled !== !1 ? (o(), n("button", {
488
+ B.showJudge && s.enabled !== !1 ? (o(), n("button", {
429
489
  key: 0,
430
490
  class: "llm-btn llm-btn--ghost llm-btn--sm",
431
- onClick: (p) => Fe(a),
432
- title: a.id === k.value ? "Unset as judge" : "Set as judge"
433
- }, d(a.id === k.value ? "Unmark Judge" : "Mark Judge"), 9, Ll)) : r("", !0),
434
- s("button", {
491
+ onClick: (y) => Ge(s),
492
+ title: s.id === _.value ? "Unset as judge" : "Set as judge"
493
+ }, c(s.id === _.value ? "Unmark Judge" : "Mark Judge"), 9, ql)) : r("", !0),
494
+ a("button", {
435
495
  class: "llm-btn llm-btn--ghost llm-btn--sm",
436
- onClick: (p) => Ie(a),
437
- title: a.enabled === !1 ? "Enable provider" : "Disable provider"
438
- }, d(a.enabled === !1 ? "Enable" : "Disable"), 9, Il),
439
- s("button", {
496
+ onClick: (y) => je(s),
497
+ title: s.enabled === !1 ? "Enable provider" : "Disable provider"
498
+ }, c(s.enabled === !1 ? "Enable" : "Disable"), 9, Wl),
499
+ a("button", {
440
500
  class: "llm-btn llm-btn--ghost llm-btn--sm",
441
- onClick: (p) => ae(a)
442
- }, " Edit ", 8, xl),
443
- s("button", {
501
+ onClick: (y) => de(s)
502
+ }, " Edit ", 8, Gl),
503
+ a("button", {
444
504
  class: "llm-btn llm-btn--sm llm-btn--danger",
445
- onClick: (p) => Le(a.id)
446
- }, " Delete ", 8, Vl)
505
+ onClick: (y) => Ne(s.id)
506
+ }, " Delete ", 8, zl)
447
507
  ])
448
- ], 10, _l))), 128))
449
- ])) : (o(), n("div", $l, [...e[24] || (e[24] = [
450
- s("p", null, "Connect your first AI provider to start chatting.", -1),
451
- s("p", null, `Click "Add New Provider" below. You'll need a base URL and, for some providers, an API key.`, -1),
452
- s("p", { class: "llm-security-note" }, "API keys are stored locally in your browser.", -1)
508
+ ], 10, Vl))), 128))
509
+ ])) : (o(), n("div", Yl, [...e[26] || (e[26] = [
510
+ a("p", null, "Connect your first AI provider to start chatting.", -1),
511
+ a("p", null, `Click "Add New Provider" below. You'll need a base URL and, for some providers, an API key.`, -1),
512
+ a("p", { class: "llm-security-note" }, "API keys are stored locally in your browser.", -1)
453
513
  ])]))
454
514
  ])),
455
- q.value ? (o(), n("div", {
515
+ W.value ? (o(), n("div", {
456
516
  key: 2,
457
517
  class: "llm-keys-manager-overlay",
458
- onClick: ne
518
+ onClick: ve
459
519
  }, [
460
- s("div", {
520
+ a("div", {
461
521
  class: "llm-keys-manager-content",
462
- onClick: e[9] || (e[9] = J(() => {
522
+ onClick: e[10] || (e[10] = J(() => {
463
523
  }, ["stop"]))
464
524
  }, [
465
- je(Ge, {
466
- onClose: ne,
467
- onKeysUpdated: Ve
525
+ Qe(tl, {
526
+ onClose: ve,
527
+ onKeysUpdated: Oe
468
528
  })
469
529
  ])
470
530
  ])) : r("", !0)
471
531
  ]),
472
- s("div", Dl, [
532
+ a("div", Hl, [
473
533
  v.value ? r("", !0) : (o(), n("button", {
474
534
  key: 0,
475
535
  class: "llm-btn llm-btn--secondary",
476
- onClick: Ae
536
+ onClick: De
477
537
  }, " Add New Provider ")),
478
- !v.value && he.value ? (o(), n("button", {
538
+ !v.value && Me.value ? (o(), n("button", {
479
539
  key: 1,
480
540
  class: "llm-btn llm-btn--ghost",
481
- onClick: xe
541
+ onClick: Je
482
542
  }, " Manage Keys ")) : r("", !0),
483
- e[25] || (e[25] = s("div", { class: "llm-footer-spacer" }, null, -1)),
484
- s("button", {
543
+ e[27] || (e[27] = a("div", { class: "llm-footer-spacer" }, null, -1)),
544
+ a("button", {
485
545
  class: "llm-btn llm-btn--ghost",
486
- onClick: e[10] || (e[10] = (a) => v.value ? Ee() : N())
546
+ onClick: e[11] || (e[11] = (s) => v.value ? Fe() : j())
487
547
  }, " Close "),
488
548
  v.value ? (o(), n("button", {
489
549
  key: 2,
490
550
  class: "llm-btn llm-btn--primary",
491
- onClick: Me,
492
- disabled: !se.value || K.value
493
- }, d(K.value ? "Testing..." : "Save"), 9, Fl)) : r("", !0)
551
+ onClick: $e,
552
+ disabled: !ue.value || L.value
553
+ }, c(L.value ? "Testing..." : "Save"), 9, Ql)) : r("", !0)
494
554
  ])
495
555
  ])
496
556
  ])) : r("", !0);
497
557
  };
498
558
  }
499
- }, Hl = /* @__PURE__ */ ze(Nl, [["__scopeId", "data-v-0835d20f"]]);
559
+ }, ut = /* @__PURE__ */ sl(Xl, [["__scopeId", "data-v-13e351e0"]]);
500
560
  export {
501
- Hl as default
561
+ ut as default
502
562
  };