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