agent-tool-chat 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/dist/index.cjs +29 -0
- package/dist/index.js +1574 -0
- package/dist/style.css +1 -0
- package/package.json +38 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1574 @@
|
|
|
1
|
+
var re = Object.defineProperty;
|
|
2
|
+
var ce = (t, e, s) => e in t ? re(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
|
|
3
|
+
var G = (t, e, s) => (ce(t, typeof e != "symbol" ? e + "" : e, s), s);
|
|
4
|
+
import { ref as W, computed as Y, onMounted as de, watch as ee, defineComponent as N, openBlock as a, createElementBlock as m, createElementVNode as f, toDisplayString as V, createCommentVNode as z, createBlock as j, resolveDynamicComponent as me, Fragment as K, renderList as U, resolveComponent as S, createVNode as _, withCtx as v, createTextVNode as R, normalizeClass as ne, unref as A, withKeys as pe, Transition as ge, nextTick as fe } from "vue";
|
|
5
|
+
import { ElMessageBox as _e } from "element-plus";
|
|
6
|
+
class he {
|
|
7
|
+
constructor(e) {
|
|
8
|
+
G(this, "messages", []);
|
|
9
|
+
G(this, "config");
|
|
10
|
+
G(this, "listeners", /* @__PURE__ */ new Set());
|
|
11
|
+
G(this, "abortController", null);
|
|
12
|
+
G(this, "_loading", !1);
|
|
13
|
+
var s;
|
|
14
|
+
this.config = { ...e, maxToolRounds: (s = e.maxToolRounds) != null ? s : 6 };
|
|
15
|
+
}
|
|
16
|
+
get loading() {
|
|
17
|
+
return this._loading;
|
|
18
|
+
}
|
|
19
|
+
updateProviderConfig(e) {
|
|
20
|
+
this.config.providerConfig = { ...this.config.providerConfig, ...e };
|
|
21
|
+
}
|
|
22
|
+
initialize(e) {
|
|
23
|
+
this.messages.length = 0, this.messages.push(...e);
|
|
24
|
+
}
|
|
25
|
+
clear() {
|
|
26
|
+
var e;
|
|
27
|
+
this.stop(), this.messages.length = 0, (e = this.config.storage) == null || e.save([]);
|
|
28
|
+
}
|
|
29
|
+
on(e) {
|
|
30
|
+
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
31
|
+
}
|
|
32
|
+
emit(e) {
|
|
33
|
+
this.listeners.forEach((s) => s(e));
|
|
34
|
+
}
|
|
35
|
+
async sendMessage(e) {
|
|
36
|
+
var r;
|
|
37
|
+
const s = e.trim();
|
|
38
|
+
if (!s || this._loading)
|
|
39
|
+
return;
|
|
40
|
+
this._loading = !0, this.abortController = new AbortController(), this.emit({ type: "status", loading: !0 });
|
|
41
|
+
const d = { role: "user", content: s };
|
|
42
|
+
this.messages.push(d), this.emit({ type: "message", message: d });
|
|
43
|
+
try {
|
|
44
|
+
let l = 0;
|
|
45
|
+
const p = this.config.maxToolRounds;
|
|
46
|
+
for (; l < p; ) {
|
|
47
|
+
l++;
|
|
48
|
+
const E = { role: "assistant", content: "" };
|
|
49
|
+
this.messages.push(E), this.emit({ type: "message", message: E });
|
|
50
|
+
const u = this.buildApiMessages(), n = await this.config.provider.streamChat({
|
|
51
|
+
config: this.config.providerConfig,
|
|
52
|
+
messages: u,
|
|
53
|
+
tools: this.config.tools.getDefinitions(),
|
|
54
|
+
signal: this.abortController.signal,
|
|
55
|
+
onContent: (g) => {
|
|
56
|
+
E.content += g, this.emit({ type: "stream:delta", delta: { content: g } });
|
|
57
|
+
},
|
|
58
|
+
onReasoning: (g) => {
|
|
59
|
+
this.emit({ type: "stream:delta", delta: { reasoning: g } });
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
if (E.content = n.content, this.emit({ type: "stream:end", content: n.content, reasoning: n.reasoning }), n.tool_calls.length > 0) {
|
|
63
|
+
E.tool_calls = n.tool_calls;
|
|
64
|
+
for (const g of n.tool_calls) {
|
|
65
|
+
this.emit({ type: "tool:start", call: g });
|
|
66
|
+
const y = await this.config.tools.execute(g.function.name, g.function.arguments);
|
|
67
|
+
this.emit({ type: "tool:end", call: g, output: y }), this.messages.push({
|
|
68
|
+
role: "tool",
|
|
69
|
+
tool_call_id: g.id,
|
|
70
|
+
content: y.result,
|
|
71
|
+
name: g.function.name
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
await ((r = this.config.storage) == null ? void 0 : r.save(this.messages));
|
|
79
|
+
} catch (l) {
|
|
80
|
+
if ((l == null ? void 0 : l.name) !== "AbortError")
|
|
81
|
+
this.emit({ type: "error", error: (l == null ? void 0 : l.message) || "\u8BF7\u6C42\u51FA\u9519" });
|
|
82
|
+
else {
|
|
83
|
+
const p = this.messages[this.messages.length - 1];
|
|
84
|
+
(p == null ? void 0 : p.role) === "assistant" && !p.content && (p.content = "\uFF08\u5DF2\u505C\u6B62\u751F\u6210\uFF09");
|
|
85
|
+
}
|
|
86
|
+
} finally {
|
|
87
|
+
this._loading = !1, this.abortController = null, this.emit({ type: "status", loading: !1 });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
stop() {
|
|
91
|
+
var e;
|
|
92
|
+
(e = this.abortController) == null || e.abort();
|
|
93
|
+
}
|
|
94
|
+
buildApiMessages() {
|
|
95
|
+
const e = this.messages, d = e.length > 0 && e[e.length - 1].role === "assistant" && e[e.length - 1].content === "" && !e[e.length - 1].tool_calls ? e.slice(0, -1) : e;
|
|
96
|
+
return this.config.systemPrompt ? [{ role: "system", content: this.config.systemPrompt }, ...d] : [...d];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
class ve {
|
|
100
|
+
constructor() {
|
|
101
|
+
G(this, "_definitions", []);
|
|
102
|
+
G(this, "_handlers", /* @__PURE__ */ new Map());
|
|
103
|
+
}
|
|
104
|
+
register(e, s) {
|
|
105
|
+
return this._definitions.push(e), this._handlers.set(e.function.name, s), this;
|
|
106
|
+
}
|
|
107
|
+
registerBatch(e) {
|
|
108
|
+
for (const s of e)
|
|
109
|
+
this.register(s.definition, s.handler);
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
getDefinitions() {
|
|
113
|
+
return [...this._definitions];
|
|
114
|
+
}
|
|
115
|
+
async execute(e, s) {
|
|
116
|
+
const d = this._handlers.get(e);
|
|
117
|
+
if (!d)
|
|
118
|
+
return { success: !1, result: `\u672A\u77E5\u5DE5\u5177\uFF1A${e}` };
|
|
119
|
+
try {
|
|
120
|
+
const r = s ? JSON.parse(s) : {};
|
|
121
|
+
return await d(r);
|
|
122
|
+
} catch (r) {
|
|
123
|
+
return { success: !1, result: `\u5DE5\u5177\u6267\u884C\u5F02\u5E38\uFF1A${(r == null ? void 0 : r.message) || String(r)}` };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function Fe(t) {
|
|
128
|
+
let e = t.trim().replace(/\/+$/, "");
|
|
129
|
+
return e = e.replace(/\/v1$/, ""), e;
|
|
130
|
+
}
|
|
131
|
+
function ye() {
|
|
132
|
+
return {
|
|
133
|
+
async streamChat(t) {
|
|
134
|
+
var P;
|
|
135
|
+
const {
|
|
136
|
+
config: { baseUrl: e, apiKey: s, model: d, temperature: r },
|
|
137
|
+
messages: l,
|
|
138
|
+
tools: p,
|
|
139
|
+
signal: E,
|
|
140
|
+
onContent: u,
|
|
141
|
+
onReasoning: n
|
|
142
|
+
} = t;
|
|
143
|
+
if (!s)
|
|
144
|
+
throw new Error("\u672A\u914D\u7F6E API Key");
|
|
145
|
+
const g = `${Fe(e)}/chat/completions`, y = { model: d, messages: l, stream: !0 };
|
|
146
|
+
typeof r == "number" && (y.temperature = r), p != null && p.length && (y.tools = p, y.tool_choice = "auto");
|
|
147
|
+
const C = await fetch(g, {
|
|
148
|
+
method: "POST",
|
|
149
|
+
headers: {
|
|
150
|
+
"Content-Type": "application/json",
|
|
151
|
+
Authorization: `Bearer ${s}`
|
|
152
|
+
},
|
|
153
|
+
body: JSON.stringify(y),
|
|
154
|
+
signal: E
|
|
155
|
+
});
|
|
156
|
+
if (!C.ok || !C.body) {
|
|
157
|
+
let x = `\u8BF7\u6C42\u5931\u8D25\uFF08HTTP ${C.status}\uFF09`;
|
|
158
|
+
try {
|
|
159
|
+
const I = await C.json();
|
|
160
|
+
(P = I == null ? void 0 : I.error) != null && P.message && (x = I.error.message);
|
|
161
|
+
} catch {
|
|
162
|
+
}
|
|
163
|
+
throw new Error(x);
|
|
164
|
+
}
|
|
165
|
+
const M = C.body.getReader(), O = new TextDecoder("utf-8");
|
|
166
|
+
let T = "", h = "", w = "", F = "stop";
|
|
167
|
+
const c = /* @__PURE__ */ new Map(), H = (x) => {
|
|
168
|
+
var L;
|
|
169
|
+
if (!x)
|
|
170
|
+
return;
|
|
171
|
+
const I = (L = x.index) != null ? L : 0;
|
|
172
|
+
c.has(I) || c.set(I, { id: "", type: "function", function: { name: "", arguments: "" } });
|
|
173
|
+
const D = c.get(I);
|
|
174
|
+
x.id && (D.id = x.id), x.type && (D.type = x.type), x.function && (x.function.name && (D.function.name += x.function.name), x.function.arguments && (D.function.arguments += x.function.arguments));
|
|
175
|
+
}, J = (x) => {
|
|
176
|
+
var L;
|
|
177
|
+
const I = (L = x == null ? void 0 : x.choices) == null ? void 0 : L[0];
|
|
178
|
+
if (!I)
|
|
179
|
+
return;
|
|
180
|
+
const D = I.delta || {};
|
|
181
|
+
typeof D.content == "string" && D.content && (h += D.content, u == null || u(D.content)), typeof D.reasoning_content == "string" && D.reasoning_content && (w += D.reasoning_content, n == null || n(D.reasoning_content)), Array.isArray(D.tool_calls) && D.tool_calls.forEach((X) => H(X)), I.finish_reason && (F = I.finish_reason);
|
|
182
|
+
};
|
|
183
|
+
for (; ; ) {
|
|
184
|
+
const { done: x, value: I } = await M.read();
|
|
185
|
+
if (x)
|
|
186
|
+
break;
|
|
187
|
+
T += O.decode(I, { stream: !0 });
|
|
188
|
+
let D;
|
|
189
|
+
for (; (D = T.indexOf(`
|
|
190
|
+
`)) !== -1; ) {
|
|
191
|
+
const L = T.slice(0, D).replace(/\r$/, "").trim();
|
|
192
|
+
if (T = T.slice(D + 1), !L || L.startsWith(":") || !L.startsWith("data:"))
|
|
193
|
+
continue;
|
|
194
|
+
const X = L.slice(5).trim();
|
|
195
|
+
if (X === "[DONE]")
|
|
196
|
+
return q();
|
|
197
|
+
try {
|
|
198
|
+
J(JSON.parse(X));
|
|
199
|
+
} catch {
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return q();
|
|
204
|
+
function q() {
|
|
205
|
+
const x = Array.from(c.values()).filter((I) => I.function.name);
|
|
206
|
+
return { content: h, reasoning: w, tool_calls: x, finish_reason: F };
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function Ee(t) {
|
|
212
|
+
var s, d, r, l, p;
|
|
213
|
+
const e = [];
|
|
214
|
+
return (s = t.displayHints) != null && s.suggestComponent && e.push(`\u5C55\u793A\u5EFA\u8BAE: \u4F7F\u7528 ${t.displayHints.suggestComponent} \u7EC4\u4EF6`), (d = t.displayHints) != null && d.resultFormat && e.push(`\u683C\u5F0F: ${t.displayHints.resultFormat}`), (l = (r = t.displayHints) == null ? void 0 : r.previewFields) != null && l.length && e.push(`\u9884\u89C8\u5B57\u6BB5: ${t.displayHints.previewFields.join(", ")}`), (p = t.displayHints) != null && p.summaryTemplate && e.push(`\u6982\u8981\u6A21\u677F: ${t.displayHints.summaryTemplate}`), e.length ? e.join(" | ") : "";
|
|
215
|
+
}
|
|
216
|
+
function Ce(t) {
|
|
217
|
+
const e = [
|
|
218
|
+
"\u4F60\u662F\u4E00\u4E2A AI \u52A9\u624B\uFF0C\u53EF\u4EE5\u5E2E\u52A9\u7528\u6237\u5B8C\u6210\u5404\u79CD\u64CD\u4F5C\u3002",
|
|
219
|
+
"",
|
|
220
|
+
"\u4F60\u53EF\u4EE5\u4F7F\u7528\u4EE5\u4E0B\u5DE5\u5177\u5305\uFF1A",
|
|
221
|
+
""
|
|
222
|
+
];
|
|
223
|
+
for (const s of t) {
|
|
224
|
+
e.push(`\u3010${s.name}\u3011${s.description}`);
|
|
225
|
+
for (const d of s.tools) {
|
|
226
|
+
const r = Ee(d);
|
|
227
|
+
e.push(` - ${d.name}: ${d.description}`), r && e.push(` ${r}`);
|
|
228
|
+
}
|
|
229
|
+
e.push("");
|
|
230
|
+
}
|
|
231
|
+
return e.push("\u6CE8\u610F\uFF1A"), e.push("1. \u5F53\u4F60\u9700\u8981\u67E5\u8BE2\u6216\u64CD\u4F5C\u6570\u636E\u65F6\uFF0C\u8C03\u7528\u5BF9\u5E94\u5DE5\u5177\u5305\u4E2D\u7684\u51FD\u6570\u3002"), e.push("2. \u5DE5\u5177\u51FD\u6570\u7531\u5BBF\u4E3B\u7CFB\u7EDF\u6267\u884C\uFF0C\u4F60\u53EA\u9700\u8981\u4F20\u9012\u6B63\u786E\u7684\u53C2\u6570\u3002"), e.push("3. \u83B7\u53D6\u5230\u5DE5\u5177\u7ED3\u679C\u540E\uFF0C\u56DE\u590D\u7528\u6237\u5E76\u544A\u77E5\u7ED3\u679C\u3002"), e.push("4. \u5982\u679C\u5DE5\u5177\u8FD4\u56DE\u4E86\u7ED3\u6784\u5316\u6570\u636E\uFF08\u5982\u8BA2\u5355\u4FE1\u606F\u3001\u7CFB\u7EDF\u72B6\u6001\u7B49\uFF09\uFF0C\u5728\u56DE\u590D\u4E2D\u6E05\u6670\u5730\u5C55\u793A\u7ED9\u7528\u6237\u3002"), e.push("5. \u6839\u636E\u7ED3\u679C\u52A8\u6001\u5EFA\u8BAE\u7528\u6237\u63A5\u4E0B\u6765\u53EF\u4EE5\u505A\u4EC0\u4E48\u3002"), e.push("6. \u5982\u679C\u7528\u6237\u4E0A\u4F20\u4E86\u6587\u4EF6\uFF0C\u6587\u4EF6\u683C\u5F0F\u4E3A\uFF08.txt\u3001.json\u3001.geojson\u7B49\u683C\u5F0F\uFF09\uFF0C\u4F60\u5FC5\u987B\u8C03\u7528 open_mapview_file \u5DE5\u5177\u5728\u5730\u56FE\u4E0A\u5C55\u793A\uFF0C\u4E0D\u8981\u53EA\u56DE\u590D\u6587\u5B57\u3002"), e.push(""), e.push("--- \u6587\u4EF6\u4E0A\u4F20\u89C4\u5219 ---"), e.push("\u7528\u6237\u53EF\u80FD\u4E0A\u4F20\u6587\u4EF6\uFF0C\u6587\u4EF6\u4EE5\u5982\u4E0B\u683C\u5F0F\u51FA\u73B0\u5728\u6D88\u606F\u4E2D\uFF1A"), e.push("[Uploaded file: fileId] \u6587\u4EF6\u540D (\u7C7B\u578B, \u5927\u5C0FKB)"), e.push("\u4F60\u65E0\u6CD5\u67E5\u770B\u6587\u4EF6\u5185\u5BB9\uFF0C\u53EA\u80FD\u770B\u5230\u6587\u4EF6\u540D\u548C\u7C7B\u578B\u3002"), e.push("\u4F60\u5FC5\u987B\u6839\u636E\u6587\u4EF6\u540D\u3001\u6269\u5C55\u540D\u548C\u7528\u6237\u7684\u6587\u5B57\u6307\u4EE4\uFF0C\u8C03\u7528\u5BF9\u5E94\u7684\u5DE5\u5177\u6765\u5904\u7406\u6587\u4EF6\u3002"), e.push("\u5982\u679C\u67D0\u4E2A\u5DE5\u5177\u9700\u8981\u5904\u7406\u8BE5\u6587\u4EF6\uFF0C\u5728\u5DE5\u5177\u53C2\u6570\u4E2D\u4F20\u5165 fileId\u3002"), e.push('\u4E0D\u8981\u56DE\u590D\u5047\u6027\u6210\u529F\u6D88\u606F\uFF08\u5982"\u5DF2\u5728\u5730\u56FE\u4E0A\u663E\u793A"\uFF09\uFF0C\u5982\u679C\u4E0D\u8C03\u7528\u5DE5\u5177\uFF0C\u6587\u4EF6\u4E0D\u4F1A\u88AB\u5B9E\u9645\u5904\u7406\u3002'), e.push("\u4E0D\u8981\u7F16\u9020\u6587\u4EF6\u5185\u5BB9\uFF0C\u4E0D\u8981\u5047\u88C5\u4F60\u770B\u5230\u4E86\u6587\u4EF6\u6570\u636E\u3002"), e.join(`
|
|
232
|
+
`);
|
|
233
|
+
}
|
|
234
|
+
const ue = {
|
|
235
|
+
apiKey: "",
|
|
236
|
+
baseUrl: "https://api.deepseek.com",
|
|
237
|
+
model: "deepseek-chat",
|
|
238
|
+
temperature: 0
|
|
239
|
+
};
|
|
240
|
+
function xe(t) {
|
|
241
|
+
return {
|
|
242
|
+
type: "function",
|
|
243
|
+
function: {
|
|
244
|
+
name: t.name,
|
|
245
|
+
description: t.description,
|
|
246
|
+
parameters: t.parameters
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function se() {
|
|
251
|
+
return `m_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
252
|
+
}
|
|
253
|
+
function ae(t) {
|
|
254
|
+
const e = [];
|
|
255
|
+
for (const s of t)
|
|
256
|
+
if (s.role === "user")
|
|
257
|
+
e.push({ role: "user", content: s.content });
|
|
258
|
+
else if (s.role === "assistant" && (e.push({ role: "assistant", content: s.content, tool_calls: s.tool_calls }), s.toolResults))
|
|
259
|
+
for (const d of s.toolResults)
|
|
260
|
+
e.push({ role: "tool", tool_call_id: d.callId, content: d.result, name: d.name });
|
|
261
|
+
return e;
|
|
262
|
+
}
|
|
263
|
+
function qt(t) {
|
|
264
|
+
const {
|
|
265
|
+
toolPackages: e,
|
|
266
|
+
onToolCall: s,
|
|
267
|
+
provider: d,
|
|
268
|
+
providerConfig: r,
|
|
269
|
+
systemPrompt: l,
|
|
270
|
+
storagePrefix: p = "agent_chat_",
|
|
271
|
+
sendFileToLLM: E = !1
|
|
272
|
+
} = t, u = {
|
|
273
|
+
messages: `${p}messages`,
|
|
274
|
+
settings: `${p}settings`
|
|
275
|
+
}, n = W([]), g = W({ ...ue }), y = W(!1), C = W(""), M = /* @__PURE__ */ new Map(), O = new ve();
|
|
276
|
+
for (const i of e)
|
|
277
|
+
for (const k of i.tools) {
|
|
278
|
+
const b = xe(k);
|
|
279
|
+
O.register(b, async (o) => {
|
|
280
|
+
const B = { packageId: i.id, toolName: k.name, args: o };
|
|
281
|
+
return await F(B, i, k);
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
const T = d || ye(), h = new he({
|
|
285
|
+
provider: T,
|
|
286
|
+
providerConfig: {
|
|
287
|
+
baseUrl: g.value.baseUrl,
|
|
288
|
+
apiKey: g.value.apiKey,
|
|
289
|
+
model: g.value.model,
|
|
290
|
+
temperature: g.value.temperature,
|
|
291
|
+
...r
|
|
292
|
+
},
|
|
293
|
+
tools: O,
|
|
294
|
+
systemPrompt: l || Ce(e)
|
|
295
|
+
});
|
|
296
|
+
let w = null;
|
|
297
|
+
async function F(i, k, b) {
|
|
298
|
+
const o = {
|
|
299
|
+
toolCallId: `${Date.now()}_${Math.random().toString(36).slice(2, 6)}`,
|
|
300
|
+
packageId: i.packageId,
|
|
301
|
+
toolName: i.toolName,
|
|
302
|
+
args: i.args
|
|
303
|
+
};
|
|
304
|
+
try {
|
|
305
|
+
const B = await s(o);
|
|
306
|
+
return w = { pkg: k, toolDef: b, data: B }, { success: !0, result: typeof B == "string" ? B : JSON.stringify(B) };
|
|
307
|
+
} catch (B) {
|
|
308
|
+
return { success: !1, result: (B == null ? void 0 : B.message) || "\u5DE5\u5177\u6267\u884C\u5931\u8D25" };
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
function c() {
|
|
312
|
+
var $;
|
|
313
|
+
if (!w)
|
|
314
|
+
return;
|
|
315
|
+
const { pkg: i, toolDef: k, data: b } = w, o = k.displayHints;
|
|
316
|
+
if (!o)
|
|
317
|
+
return;
|
|
318
|
+
const B = n.value[n.value.length - 1];
|
|
319
|
+
if (!(!B || B.role !== "assistant")) {
|
|
320
|
+
if (o.suggestComponent) {
|
|
321
|
+
let te = b;
|
|
322
|
+
if (($ = b == null ? void 0 : b.data) != null && $.fileId) {
|
|
323
|
+
const Z = M.get(b.data.fileId);
|
|
324
|
+
Z && (te = Z.name.endsWith(".geojson") || Z.name.endsWith(".json") ? { data: { wkt: "", geojson: Z.data } } : { data: { wkt: Z.data, geojson: "" } });
|
|
325
|
+
}
|
|
326
|
+
B.renderBlocks = [{
|
|
327
|
+
type: "component",
|
|
328
|
+
packageId: i.id,
|
|
329
|
+
componentName: o.suggestComponent,
|
|
330
|
+
data: te
|
|
331
|
+
}], console.log("resolvedData===", te);
|
|
332
|
+
}
|
|
333
|
+
o.suggestedNext && (B.suggestedNext = o.suggestedNext);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
const H = /* @__PURE__ */ new Map();
|
|
337
|
+
h.on((i) => {
|
|
338
|
+
var k, b;
|
|
339
|
+
switch (i.type) {
|
|
340
|
+
case "message": {
|
|
341
|
+
if (i.message.role === "tool")
|
|
342
|
+
break;
|
|
343
|
+
const o = {
|
|
344
|
+
id: se(),
|
|
345
|
+
role: i.message.role,
|
|
346
|
+
content: i.message.content,
|
|
347
|
+
reasoning: "",
|
|
348
|
+
status: i.message.role === "assistant" ? "streaming" : "done",
|
|
349
|
+
timestamp: Date.now(),
|
|
350
|
+
tool_calls: i.message.tool_calls
|
|
351
|
+
};
|
|
352
|
+
n.value.push(o);
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
case "stream:delta": {
|
|
356
|
+
const o = n.value[n.value.length - 1];
|
|
357
|
+
(o == null ? void 0 : o.role) === "assistant" && o.status === "streaming" && (i.delta.content && (o.content += i.delta.content), i.delta.reasoning && (o.reasoning = (o.reasoning || "") + i.delta.reasoning));
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
case "stream:end": {
|
|
361
|
+
const o = n.value[n.value.length - 1];
|
|
362
|
+
(o == null ? void 0 : o.role) === "assistant" && (o.content = i.content, i.reasoning && (o.reasoning = i.reasoning));
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
case "tool:start": {
|
|
366
|
+
const o = n.value[n.value.length - 1];
|
|
367
|
+
if (!o || o.role !== "assistant")
|
|
368
|
+
break;
|
|
369
|
+
o.tool_calls || (o.tool_calls = []), o.toolResults || (o.toolResults = []);
|
|
370
|
+
const B = o.toolResults.length;
|
|
371
|
+
o.toolResults.push({
|
|
372
|
+
callId: i.call.id,
|
|
373
|
+
name: i.call.function.name,
|
|
374
|
+
arguments: i.call.function.arguments,
|
|
375
|
+
result: "",
|
|
376
|
+
success: !1,
|
|
377
|
+
status: "running"
|
|
378
|
+
}), H.set(i.call.id, { msgIndex: n.value.length - 1, toolIndex: B }), o.tool_calls.find(($) => $.id === i.call.id) || o.tool_calls.push({
|
|
379
|
+
id: i.call.id,
|
|
380
|
+
type: "function",
|
|
381
|
+
function: {
|
|
382
|
+
name: i.call.function.name,
|
|
383
|
+
arguments: i.call.function.arguments
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
break;
|
|
387
|
+
}
|
|
388
|
+
case "tool:end": {
|
|
389
|
+
const o = H.get(i.call.id);
|
|
390
|
+
if (!o)
|
|
391
|
+
break;
|
|
392
|
+
const B = (b = (k = n.value[o.msgIndex]) == null ? void 0 : k.toolResults) == null ? void 0 : b[o.toolIndex];
|
|
393
|
+
B && (B.result = i.output.result, B.success = i.output.success, B.status = i.output.success ? "success" : "error"), H.delete(i.call.id);
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
case "error": {
|
|
397
|
+
C.value = i.error;
|
|
398
|
+
const o = n.value[n.value.length - 1];
|
|
399
|
+
(o == null ? void 0 : o.role) === "assistant" && (o.status = "error", o.error = i.error);
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
case "status": {
|
|
403
|
+
if (y.value = i.loading, !i.loading) {
|
|
404
|
+
const o = n.value[n.value.length - 1];
|
|
405
|
+
(o == null ? void 0 : o.role) === "assistant" && o.status === "streaming" && (o.status = "done", o.content || (o.content = "\uFF08\u5DF2\u505C\u6B62\u751F\u6210\uFF09")), c();
|
|
406
|
+
}
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
function J() {
|
|
412
|
+
try {
|
|
413
|
+
const i = localStorage.getItem(u.settings);
|
|
414
|
+
i && (g.value = { ...ue, ...JSON.parse(i) });
|
|
415
|
+
} catch {
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
function q() {
|
|
419
|
+
try {
|
|
420
|
+
const i = localStorage.getItem(u.messages);
|
|
421
|
+
if (i) {
|
|
422
|
+
const k = JSON.parse(i);
|
|
423
|
+
if (Array.isArray(k)) {
|
|
424
|
+
n.value = k;
|
|
425
|
+
for (const b of k)
|
|
426
|
+
if (b.files)
|
|
427
|
+
for (const o of b.files)
|
|
428
|
+
o.id && M.set(o.id, o);
|
|
429
|
+
h.initialize(ae(k));
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
} catch {
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
function P(i) {
|
|
436
|
+
g.value = { ...i }, localStorage.setItem(u.settings, JSON.stringify(i)), h.updateProviderConfig({
|
|
437
|
+
baseUrl: i.baseUrl,
|
|
438
|
+
apiKey: i.apiKey,
|
|
439
|
+
model: i.model,
|
|
440
|
+
temperature: i.temperature
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
function x() {
|
|
444
|
+
try {
|
|
445
|
+
localStorage.setItem(u.messages, JSON.stringify(n.value));
|
|
446
|
+
} catch {
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
function I(i) {
|
|
450
|
+
return i.startsWith("data:");
|
|
451
|
+
}
|
|
452
|
+
async function D(i, k) {
|
|
453
|
+
const b = i.trim();
|
|
454
|
+
if (!b && (!k || k.length === 0))
|
|
455
|
+
return;
|
|
456
|
+
if (C.value = "", !g.value.apiKey) {
|
|
457
|
+
C.value = "\u8BF7\u5148\u914D\u7F6E API Key\u3002";
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
if (h.updateProviderConfig({
|
|
461
|
+
baseUrl: g.value.baseUrl,
|
|
462
|
+
apiKey: g.value.apiKey,
|
|
463
|
+
model: g.value.model,
|
|
464
|
+
temperature: g.value.temperature
|
|
465
|
+
}), w = null, H.clear(), k && k.length > 0) {
|
|
466
|
+
for (const $ of k)
|
|
467
|
+
$.id = se(), M.set($.id, { ...$ });
|
|
468
|
+
const B = {
|
|
469
|
+
id: se(),
|
|
470
|
+
role: "user",
|
|
471
|
+
content: b,
|
|
472
|
+
status: "done",
|
|
473
|
+
timestamp: Date.now(),
|
|
474
|
+
files: k
|
|
475
|
+
};
|
|
476
|
+
n.value.push(B), h.initialize(ae(n.value));
|
|
477
|
+
}
|
|
478
|
+
let o = b;
|
|
479
|
+
k && k.length > 0 && (E ? o = k.map(($) => I($.data) ? `[File: ${$.name} (${$.type}, ${($.size / 1024).toFixed(1)}KB)]
|
|
480
|
+
${$.data}` : `[File: ${$.name} (${$.type}, ${($.size / 1024).toFixed(1)}KB)]
|
|
481
|
+
\`\`\`
|
|
482
|
+
${$.data}
|
|
483
|
+
\`\`\``).join(`
|
|
484
|
+
|
|
485
|
+
`) + (b ? `
|
|
486
|
+
|
|
487
|
+
${b}` : "") : o = k.map(
|
|
488
|
+
($) => `[Uploaded file: ${$.id}] ${$.name} (${$.type}, ${($.size / 1024).toFixed(1)}KB)`
|
|
489
|
+
).join(`
|
|
490
|
+
`) + (b ? `
|
|
491
|
+
|
|
492
|
+
${b}` : "")), await h.sendMessage(o);
|
|
493
|
+
}
|
|
494
|
+
function L() {
|
|
495
|
+
h.stop();
|
|
496
|
+
}
|
|
497
|
+
function X() {
|
|
498
|
+
h.clear(), n.value = [], C.value = "", w = null, M.clear(), localStorage.removeItem(u.messages);
|
|
499
|
+
}
|
|
500
|
+
const ie = Y(() => !!g.value.apiKey);
|
|
501
|
+
return de(() => {
|
|
502
|
+
J(), q();
|
|
503
|
+
}), ee(n, () => x(), { deep: !0 }), {
|
|
504
|
+
messages: n,
|
|
505
|
+
settings: g,
|
|
506
|
+
loading: y,
|
|
507
|
+
errorMsg: C,
|
|
508
|
+
hasApiKey: ie,
|
|
509
|
+
toolPackages: e,
|
|
510
|
+
fileStore: M,
|
|
511
|
+
sendMessage: D,
|
|
512
|
+
stopGeneration: L,
|
|
513
|
+
clearMessages: X,
|
|
514
|
+
saveSettings: P
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
function Gt(t, e, s) {
|
|
518
|
+
var l;
|
|
519
|
+
let d = null;
|
|
520
|
+
if (t.type === "component" && t.componentName) {
|
|
521
|
+
let p;
|
|
522
|
+
t.packageId && (p = e.find((E) => E.id === t.packageId)), !p && s && (p = e.find((E) => E.id === s)), (l = p == null ? void 0 : p.components) != null && l[t.componentName] && (d = p.components[t.componentName]);
|
|
523
|
+
}
|
|
524
|
+
const r = De(t);
|
|
525
|
+
return { component: d, block: t, fallbackText: r };
|
|
526
|
+
}
|
|
527
|
+
function De(t) {
|
|
528
|
+
switch (t.type) {
|
|
529
|
+
case "table":
|
|
530
|
+
return ke(t);
|
|
531
|
+
case "card":
|
|
532
|
+
return Be(t);
|
|
533
|
+
case "list":
|
|
534
|
+
return we(t);
|
|
535
|
+
default:
|
|
536
|
+
return JSON.stringify(t.data, null, 2);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
function ke(t) {
|
|
540
|
+
const e = t.data;
|
|
541
|
+
if (!e)
|
|
542
|
+
return "";
|
|
543
|
+
const s = Array.isArray(e) ? e : e.list || e.items || [e];
|
|
544
|
+
if (!s.length)
|
|
545
|
+
return "\uFF08\u65E0\u6570\u636E\uFF09";
|
|
546
|
+
const d = t.title ? `**${t.title}**
|
|
547
|
+
|
|
548
|
+
` : "", r = Object.keys(s[0]), l = `| ${r.join(" | ")} |`, p = `| ${r.map(() => "---").join(" | ")} |`, E = s.map((u) => `| ${r.map((n) => {
|
|
549
|
+
var g;
|
|
550
|
+
return String((g = u[n]) != null ? g : "");
|
|
551
|
+
}).join(" | ")} |`).join(`
|
|
552
|
+
`);
|
|
553
|
+
return `${d}${l}
|
|
554
|
+
${p}
|
|
555
|
+
${E}`;
|
|
556
|
+
}
|
|
557
|
+
function Be(t) {
|
|
558
|
+
const e = t.data;
|
|
559
|
+
if (!e)
|
|
560
|
+
return "";
|
|
561
|
+
const s = Array.isArray(e) ? e : e.list || e.items || [e];
|
|
562
|
+
if (!s.length)
|
|
563
|
+
return "\uFF08\u65E0\u6570\u636E\uFF09";
|
|
564
|
+
const d = t.title ? `**${t.title}**
|
|
565
|
+
|
|
566
|
+
` : "", r = s.map((l) => Object.entries(l).map(([E, u]) => `- **${E}**: ${u}`).join(`
|
|
567
|
+
`)).join(`
|
|
568
|
+
|
|
569
|
+
---
|
|
570
|
+
|
|
571
|
+
`);
|
|
572
|
+
return `${d}${r}`;
|
|
573
|
+
}
|
|
574
|
+
function we(t) {
|
|
575
|
+
const e = t.data;
|
|
576
|
+
if (!e)
|
|
577
|
+
return "";
|
|
578
|
+
const s = Array.isArray(e) ? e : e.list || e.items || [e];
|
|
579
|
+
if (!s.length)
|
|
580
|
+
return "\uFF08\u65E0\u6570\u636E\uFF09";
|
|
581
|
+
const d = t.title ? `**${t.title}**
|
|
582
|
+
|
|
583
|
+
` : "", r = s.map((l) => `- ${typeof l == "string" ? l : Object.values(l).join(" - ")}`).join(`
|
|
584
|
+
`);
|
|
585
|
+
return `${d}${r}`;
|
|
586
|
+
}
|
|
587
|
+
/*! Element Plus Icons Vue v2.3.2 */
|
|
588
|
+
var Ae = /* @__PURE__ */ N({
|
|
589
|
+
name: "ChatDotRound",
|
|
590
|
+
__name: "chat-dot-round",
|
|
591
|
+
setup(t) {
|
|
592
|
+
return (e, s) => (a(), m("svg", {
|
|
593
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
594
|
+
viewBox: "0 0 1024 1024"
|
|
595
|
+
}, [
|
|
596
|
+
f("path", {
|
|
597
|
+
fill: "currentColor",
|
|
598
|
+
d: "m174.72 855.68 135.296-45.12 23.68 11.84C388.096 849.536 448.576 864 512 864c211.84 0 384-166.784 384-352S723.84 160 512 160 128 326.784 128 512c0 69.12 24.96 139.264 70.848 199.232l22.08 28.8-46.272 115.584zm-45.248 82.56A32 32 0 0 1 89.6 896l58.368-145.92C94.72 680.32 64 596.864 64 512 64 299.904 256 96 512 96s448 203.904 448 416-192 416-448 416a461.06 461.06 0 0 1-206.912-48.384l-175.616 58.56z"
|
|
599
|
+
}),
|
|
600
|
+
f("path", {
|
|
601
|
+
fill: "currentColor",
|
|
602
|
+
d: "M512 563.2a51.2 51.2 0 1 1 0-102.4 51.2 51.2 0 0 1 0 102.4m192 0a51.2 51.2 0 1 1 0-102.4 51.2 51.2 0 0 1 0 102.4m-384 0a51.2 51.2 0 1 1 0-102.4 51.2 51.2 0 0 1 0 102.4"
|
|
603
|
+
})
|
|
604
|
+
]));
|
|
605
|
+
}
|
|
606
|
+
}), be = Ae, $e = /* @__PURE__ */ N({
|
|
607
|
+
name: "Delete",
|
|
608
|
+
__name: "delete",
|
|
609
|
+
setup(t) {
|
|
610
|
+
return (e, s) => (a(), m("svg", {
|
|
611
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
612
|
+
viewBox: "0 0 1024 1024"
|
|
613
|
+
}, [
|
|
614
|
+
f("path", {
|
|
615
|
+
fill: "currentColor",
|
|
616
|
+
d: "M160 256H96a32 32 0 0 1 0-64h256V95.936a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32V192h256a32 32 0 1 1 0 64h-64v672a32 32 0 0 1-32 32H192a32 32 0 0 1-32-32zm448-64v-64H416v64zM224 896h576V256H224zm192-128a32 32 0 0 1-32-32V416a32 32 0 0 1 64 0v320a32 32 0 0 1-32 32m192 0a32 32 0 0 1-32-32V416a32 32 0 0 1 64 0v320a32 32 0 0 1-32 32"
|
|
617
|
+
})
|
|
618
|
+
]));
|
|
619
|
+
}
|
|
620
|
+
}), Se = $e, Ie = /* @__PURE__ */ N({
|
|
621
|
+
name: "Document",
|
|
622
|
+
__name: "document",
|
|
623
|
+
setup(t) {
|
|
624
|
+
return (e, s) => (a(), m("svg", {
|
|
625
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
626
|
+
viewBox: "0 0 1024 1024"
|
|
627
|
+
}, [
|
|
628
|
+
f("path", {
|
|
629
|
+
fill: "currentColor",
|
|
630
|
+
d: "M832 384H576V128H192v768h640zm-26.496-64L640 154.496V320zM160 64h480l256 256v608a32 32 0 0 1-32 32H160a32 32 0 0 1-32-32V96a32 32 0 0 1 32-32m160 448h384v64H320zm0-192h160v64H320zm0 384h384v64H320z"
|
|
631
|
+
})
|
|
632
|
+
]));
|
|
633
|
+
}
|
|
634
|
+
}), le = Ie, Me = /* @__PURE__ */ N({
|
|
635
|
+
name: "Paperclip",
|
|
636
|
+
__name: "paperclip",
|
|
637
|
+
setup(t) {
|
|
638
|
+
return (e, s) => (a(), m("svg", {
|
|
639
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
640
|
+
viewBox: "0 0 1024 1024"
|
|
641
|
+
}, [
|
|
642
|
+
f("path", {
|
|
643
|
+
fill: "currentColor",
|
|
644
|
+
d: "M602.496 240.448A192 192 0 1 1 874.048 512l-316.8 316.8A256 256 0 0 1 195.2 466.752L602.496 59.456l45.248 45.248L240.448 512A192 192 0 0 0 512 783.552l316.8-316.8a128 128 0 1 0-181.056-181.056L353.6 579.904a32 32 0 1 0 45.248 45.248l294.144-294.144 45.312 45.248L444.096 670.4a96 96 0 1 1-135.744-135.744z"
|
|
645
|
+
})
|
|
646
|
+
]));
|
|
647
|
+
}
|
|
648
|
+
}), Ve = Me, ze = /* @__PURE__ */ N({
|
|
649
|
+
name: "Picture",
|
|
650
|
+
__name: "picture",
|
|
651
|
+
setup(t) {
|
|
652
|
+
return (e, s) => (a(), m("svg", {
|
|
653
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
654
|
+
viewBox: "0 0 1024 1024"
|
|
655
|
+
}, [
|
|
656
|
+
f("path", {
|
|
657
|
+
fill: "currentColor",
|
|
658
|
+
d: "M160 160v704h704V160zm-32-64h768a32 32 0 0 1 32 32v768a32 32 0 0 1-32 32H128a32 32 0 0 1-32-32V128a32 32 0 0 1 32-32"
|
|
659
|
+
}),
|
|
660
|
+
f("path", {
|
|
661
|
+
fill: "currentColor",
|
|
662
|
+
d: "M384 288q64 0 64 64t-64 64-64-64 64-64M185.408 876.992l-50.816-38.912L350.72 556.032a96 96 0 0 1 134.592-17.856l1.856 1.472 122.88 99.136a32 32 0 0 0 44.992-4.864l216-269.888 49.92 39.936-215.808 269.824-.256.32a96 96 0 0 1-135.04 14.464l-122.88-99.072-.64-.512a32 32 0 0 0-44.8 5.952z"
|
|
663
|
+
})
|
|
664
|
+
]));
|
|
665
|
+
}
|
|
666
|
+
}), Te = ze, Pe = /* @__PURE__ */ N({
|
|
667
|
+
name: "Promotion",
|
|
668
|
+
__name: "promotion",
|
|
669
|
+
setup(t) {
|
|
670
|
+
return (e, s) => (a(), m("svg", {
|
|
671
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
672
|
+
viewBox: "0 0 1024 1024"
|
|
673
|
+
}, [
|
|
674
|
+
f("path", {
|
|
675
|
+
fill: "currentColor",
|
|
676
|
+
d: "m64 448 832-320-128 704-446.08-243.328L832 192 242.816 545.472zm256 512V657.024L512 768z"
|
|
677
|
+
})
|
|
678
|
+
]));
|
|
679
|
+
}
|
|
680
|
+
}), je = Pe, Ne = /* @__PURE__ */ N({
|
|
681
|
+
name: "Setting",
|
|
682
|
+
__name: "setting",
|
|
683
|
+
setup(t) {
|
|
684
|
+
return (e, s) => (a(), m("svg", {
|
|
685
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
686
|
+
viewBox: "0 0 1024 1024"
|
|
687
|
+
}, [
|
|
688
|
+
f("path", {
|
|
689
|
+
fill: "currentColor",
|
|
690
|
+
d: "M600.704 64a32 32 0 0 1 30.464 22.208l35.2 109.376c14.784 7.232 28.928 15.36 42.432 24.512l112.384-24.192a32 32 0 0 1 34.432 15.36L944.32 364.8a32 32 0 0 1-4.032 37.504l-77.12 85.12a357 357 0 0 1 0 49.024l77.12 85.248a32 32 0 0 1 4.032 37.504l-88.704 153.6a32 32 0 0 1-34.432 15.296L708.8 803.904c-13.44 9.088-27.648 17.28-42.368 24.512l-35.264 109.376A32 32 0 0 1 600.704 960H423.296a32 32 0 0 1-30.464-22.208L357.696 828.48a352 352 0 0 1-42.56-24.64l-112.32 24.256a32 32 0 0 1-34.432-15.36L79.68 659.2a32 32 0 0 1 4.032-37.504l77.12-85.248a357 357 0 0 1 0-48.896l-77.12-85.248A32 32 0 0 1 79.68 364.8l88.704-153.6a32 32 0 0 1 34.432-15.296l112.32 24.256c13.568-9.152 27.776-17.408 42.56-24.64l35.2-109.312A32 32 0 0 1 423.232 64H600.64zm-23.424 64H446.72l-36.352 113.088-24.512 11.968a294 294 0 0 0-34.816 20.096l-22.656 15.36-116.224-25.088-65.28 113.152 79.68 88.192-1.92 27.136a293 293 0 0 0 0 40.192l1.92 27.136-79.808 88.192 65.344 113.152 116.224-25.024 22.656 15.296a294 294 0 0 0 34.816 20.096l24.512 11.968L446.72 896h130.688l36.48-113.152 24.448-11.904a288 288 0 0 0 34.752-20.096l22.592-15.296 116.288 25.024 65.28-113.152-79.744-88.192 1.92-27.136a293 293 0 0 0 0-40.256l-1.92-27.136 79.808-88.128-65.344-113.152-116.288 24.96-22.592-15.232a288 288 0 0 0-34.752-20.096l-24.448-11.904L577.344 128zM512 320a192 192 0 1 1 0 384 192 192 0 0 1 0-384m0 64a128 128 0 1 0 0 256 128 128 0 0 0 0-256"
|
|
691
|
+
})
|
|
692
|
+
]));
|
|
693
|
+
}
|
|
694
|
+
}), oe = Ne, Re = /* @__PURE__ */ N({
|
|
695
|
+
name: "UserFilled",
|
|
696
|
+
__name: "user-filled",
|
|
697
|
+
setup(t) {
|
|
698
|
+
return (e, s) => (a(), m("svg", {
|
|
699
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
700
|
+
viewBox: "0 0 1024 1024"
|
|
701
|
+
}, [
|
|
702
|
+
f("path", {
|
|
703
|
+
fill: "currentColor",
|
|
704
|
+
d: "M288 320a224 224 0 1 0 448 0 224 224 0 1 0-448 0m544 608H160a32 32 0 0 1-32-32v-96a160 160 0 0 1 160-160h448a160 160 0 0 1 160 160v96a32 32 0 0 1-32 32z"
|
|
705
|
+
})
|
|
706
|
+
]));
|
|
707
|
+
}
|
|
708
|
+
}), He = Re, Ke = /* @__PURE__ */ N({
|
|
709
|
+
name: "VideoPause",
|
|
710
|
+
__name: "video-pause",
|
|
711
|
+
setup(t) {
|
|
712
|
+
return (e, s) => (a(), m("svg", {
|
|
713
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
714
|
+
viewBox: "0 0 1024 1024"
|
|
715
|
+
}, [
|
|
716
|
+
f("path", {
|
|
717
|
+
fill: "currentColor",
|
|
718
|
+
d: "M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896m0 832a384 384 0 0 0 0-768 384 384 0 0 0 0 768m-96-544q32 0 32 32v256q0 32-32 32t-32-32V384q0-32 32-32m192 0q32 0 32 32v256q0 32-32 32t-32-32V384q0-32 32-32"
|
|
719
|
+
})
|
|
720
|
+
]));
|
|
721
|
+
}
|
|
722
|
+
}), Le = Ke;
|
|
723
|
+
const Ue = { class: "render-block" }, Oe = {
|
|
724
|
+
key: 0,
|
|
725
|
+
class: "render-block__title"
|
|
726
|
+
}, Je = {
|
|
727
|
+
key: 2,
|
|
728
|
+
class: "render-block__cards"
|
|
729
|
+
}, We = { class: "card-item" }, qe = { class: "card-label" }, Ge = { class: "card-value" }, Xe = {
|
|
730
|
+
key: 3,
|
|
731
|
+
class: "render-block__table"
|
|
732
|
+
}, Ye = { key: 0 }, Qe = {
|
|
733
|
+
key: 4,
|
|
734
|
+
class: "render-block__cards"
|
|
735
|
+
}, Ze = { class: "card-label" }, et = { class: "card-value" }, tt = {
|
|
736
|
+
key: 5,
|
|
737
|
+
class: "render-block__list"
|
|
738
|
+
}, st = /* @__PURE__ */ N({
|
|
739
|
+
__name: "RenderBlock",
|
|
740
|
+
props: {
|
|
741
|
+
block: {},
|
|
742
|
+
resolvedComponent: {}
|
|
743
|
+
},
|
|
744
|
+
setup(t) {
|
|
745
|
+
const e = t, s = Y(() => e.block.data || {}), d = Y(() => Array.isArray(s.value) ? s.value : s.value.list ? Array.isArray(s.value.list) ? s.value.list : [] : s.value.items ? Array.isArray(s.value.items) ? s.value.items : [] : [s.value]), r = Y(() => d.value.length ? Object.keys(d.value[0]) : []);
|
|
746
|
+
function l(p) {
|
|
747
|
+
return typeof p == "string" ? p : Object.values(p).join(" - ");
|
|
748
|
+
}
|
|
749
|
+
return (p, E) => (a(), m("div", Ue, [
|
|
750
|
+
t.block.title ? (a(), m("div", Oe, V(t.block.title), 1)) : z("", !0),
|
|
751
|
+
t.resolvedComponent ? (a(), j(me(t.resolvedComponent), {
|
|
752
|
+
key: 1,
|
|
753
|
+
class: "render-block__component",
|
|
754
|
+
data: t.block.data
|
|
755
|
+
}, null, 8, ["data"])) : t.block.type === "component" ? (a(), m("div", Je, [
|
|
756
|
+
f("div", We, [
|
|
757
|
+
(a(!0), m(K, null, U(d.value[0], (u, n) => (a(), m("div", {
|
|
758
|
+
key: n,
|
|
759
|
+
class: "card-field"
|
|
760
|
+
}, [
|
|
761
|
+
f("span", qe, V(n) + ":", 1),
|
|
762
|
+
f("span", Ge, V(u), 1)
|
|
763
|
+
]))), 128))
|
|
764
|
+
])
|
|
765
|
+
])) : t.block.type === "table" ? (a(), m("div", Xe, [
|
|
766
|
+
f("table", null, [
|
|
767
|
+
r.value.length ? (a(), m("thead", Ye, [
|
|
768
|
+
f("tr", null, [
|
|
769
|
+
(a(!0), m(K, null, U(r.value, (u) => (a(), m("th", { key: u }, V(u), 1))), 128))
|
|
770
|
+
])
|
|
771
|
+
])) : z("", !0),
|
|
772
|
+
f("tbody", null, [
|
|
773
|
+
(a(!0), m(K, null, U(d.value, (u, n) => (a(), m("tr", { key: n }, [
|
|
774
|
+
(a(!0), m(K, null, U(r.value, (g) => {
|
|
775
|
+
var y;
|
|
776
|
+
return a(), m("td", { key: g }, V((y = u[g]) != null ? y : ""), 1);
|
|
777
|
+
}), 128))
|
|
778
|
+
]))), 128))
|
|
779
|
+
])
|
|
780
|
+
])
|
|
781
|
+
])) : t.block.type === "card" ? (a(), m("div", Qe, [
|
|
782
|
+
(a(!0), m(K, null, U(d.value, (u, n) => (a(), m("div", {
|
|
783
|
+
key: n,
|
|
784
|
+
class: "card-item"
|
|
785
|
+
}, [
|
|
786
|
+
(a(!0), m(K, null, U(u, (g, y) => (a(), m("div", {
|
|
787
|
+
key: y,
|
|
788
|
+
class: "card-field"
|
|
789
|
+
}, [
|
|
790
|
+
f("span", Ze, V(y) + ":", 1),
|
|
791
|
+
f("span", et, V(g), 1)
|
|
792
|
+
]))), 128))
|
|
793
|
+
]))), 128))
|
|
794
|
+
])) : t.block.type === "list" ? (a(), m("div", tt, [
|
|
795
|
+
(a(!0), m(K, null, U(d.value, (u, n) => (a(), m("div", {
|
|
796
|
+
key: n,
|
|
797
|
+
class: "list-item"
|
|
798
|
+
}, V(l(u)), 1))), 128))
|
|
799
|
+
])) : z("", !0)
|
|
800
|
+
]));
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
const Q = (t, e) => {
|
|
804
|
+
const s = t.__vccOpts || t;
|
|
805
|
+
for (const [d, r] of e)
|
|
806
|
+
s[d] = r;
|
|
807
|
+
return s;
|
|
808
|
+
}, nt = /* @__PURE__ */ Q(st, [["__scopeId", "data-v-89cef1ee"]]), ut = {
|
|
809
|
+
key: 0,
|
|
810
|
+
class: "suggested-next"
|
|
811
|
+
}, at = { class: "suggested-next__text" }, ot = /* @__PURE__ */ N({
|
|
812
|
+
__name: "SuggestedNext",
|
|
813
|
+
props: {
|
|
814
|
+
text: {}
|
|
815
|
+
},
|
|
816
|
+
emits: ["execute"],
|
|
817
|
+
setup(t, { emit: e }) {
|
|
818
|
+
const s = t, d = e;
|
|
819
|
+
function r() {
|
|
820
|
+
d("execute", s.text);
|
|
821
|
+
}
|
|
822
|
+
return (l, p) => {
|
|
823
|
+
const E = S("el-button");
|
|
824
|
+
return t.text ? (a(), m("div", ut, [
|
|
825
|
+
p[1] || (p[1] = f("span", { class: "suggested-next__icon" }, "\u{1F4A1}", -1)),
|
|
826
|
+
f("span", at, V(t.text), 1),
|
|
827
|
+
_(E, {
|
|
828
|
+
size: "small",
|
|
829
|
+
type: "primary",
|
|
830
|
+
plain: "",
|
|
831
|
+
onClick: r
|
|
832
|
+
}, {
|
|
833
|
+
default: v(() => [...p[0] || (p[0] = [
|
|
834
|
+
R("\u53BB\u6267\u884C", -1)
|
|
835
|
+
])]),
|
|
836
|
+
_: 1
|
|
837
|
+
})
|
|
838
|
+
])) : z("", !0);
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
});
|
|
842
|
+
const lt = /* @__PURE__ */ Q(ot, [["__scopeId", "data-v-0e0e9b65"]]), it = { class: "message-avatar" }, rt = { class: "message-body" }, ct = {
|
|
843
|
+
key: 0,
|
|
844
|
+
class: "message-files"
|
|
845
|
+
}, dt = ["src", "alt"], mt = { class: "file-info" }, pt = { class: "file-name" }, gt = { class: "file-size" }, ft = {
|
|
846
|
+
key: 1,
|
|
847
|
+
class: "message-user-text"
|
|
848
|
+
}, _t = {
|
|
849
|
+
key: 0,
|
|
850
|
+
class: "message-reasoning"
|
|
851
|
+
}, ht = ["innerHTML"], vt = {
|
|
852
|
+
key: 3,
|
|
853
|
+
class: "message-cursor"
|
|
854
|
+
}, Ft = {
|
|
855
|
+
key: 4,
|
|
856
|
+
class: "message-error"
|
|
857
|
+
}, yt = /* @__PURE__ */ N({
|
|
858
|
+
__name: "ChatMessage",
|
|
859
|
+
props: {
|
|
860
|
+
message: {},
|
|
861
|
+
toolPackages: {}
|
|
862
|
+
},
|
|
863
|
+
emits: ["execute"],
|
|
864
|
+
setup(t, { emit: e }) {
|
|
865
|
+
const s = t, d = e;
|
|
866
|
+
function r(u) {
|
|
867
|
+
if (!u)
|
|
868
|
+
return "";
|
|
869
|
+
let n = u.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
870
|
+
return n = n.replace(/`([^`]+)`/g, "<code>$1</code>"), n = n.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>"), n = n.replace(/\*([^*]+)\*/g, "<em>$1</em>"), n = n.replace(/\n/g, "<br>"), n;
|
|
871
|
+
}
|
|
872
|
+
const l = Y(() => r(s.message.content));
|
|
873
|
+
function p(u) {
|
|
874
|
+
var g;
|
|
875
|
+
if (u.type !== "component" || !u.componentName)
|
|
876
|
+
return null;
|
|
877
|
+
let n = u.packageId ? s.toolPackages.find((y) => y.id === u.packageId) : null;
|
|
878
|
+
return n || (n = s.toolPackages.find(
|
|
879
|
+
(y) => y.components && u.componentName in y.components
|
|
880
|
+
)), n || (n = s.toolPackages[s.toolPackages.length - 1]), n && ((g = n.components) == null ? void 0 : g[u.componentName]) || null;
|
|
881
|
+
}
|
|
882
|
+
function E(u) {
|
|
883
|
+
d("execute", u);
|
|
884
|
+
}
|
|
885
|
+
return (u, n) => {
|
|
886
|
+
var y;
|
|
887
|
+
const g = S("el-icon");
|
|
888
|
+
return a(), m("div", {
|
|
889
|
+
class: ne(["chat-message", [`role-${t.message.role}`, { "is-streaming": t.message.status === "streaming" }]])
|
|
890
|
+
}, [
|
|
891
|
+
f("div", it, [
|
|
892
|
+
t.message.role === "user" ? (a(), j(g, { key: 0 }, {
|
|
893
|
+
default: v(() => [
|
|
894
|
+
_(A(He))
|
|
895
|
+
]),
|
|
896
|
+
_: 1
|
|
897
|
+
})) : (a(), j(g, { key: 1 }, {
|
|
898
|
+
default: v(() => [
|
|
899
|
+
_(A(be))
|
|
900
|
+
]),
|
|
901
|
+
_: 1
|
|
902
|
+
}))
|
|
903
|
+
]),
|
|
904
|
+
f("div", rt, [
|
|
905
|
+
(y = t.message.files) != null && y.length ? (a(), m("div", ct, [
|
|
906
|
+
(a(!0), m(K, null, U(t.message.files, (C, M) => (a(), m("div", {
|
|
907
|
+
key: M,
|
|
908
|
+
class: ne(["message-file", { "is-image": C.type.startsWith("image/") }])
|
|
909
|
+
}, [
|
|
910
|
+
C.type.startsWith("image/") ? (a(), m("img", {
|
|
911
|
+
key: 0,
|
|
912
|
+
src: C.data,
|
|
913
|
+
alt: C.name,
|
|
914
|
+
class: "file-image"
|
|
915
|
+
}, null, 8, dt)) : (a(), j(g, { key: 1 }, {
|
|
916
|
+
default: v(() => [
|
|
917
|
+
_(A(le))
|
|
918
|
+
]),
|
|
919
|
+
_: 1
|
|
920
|
+
})),
|
|
921
|
+
f("div", mt, [
|
|
922
|
+
f("span", pt, V(C.name), 1),
|
|
923
|
+
f("span", gt, V((C.size / 1024).toFixed(1)) + " KB", 1)
|
|
924
|
+
])
|
|
925
|
+
], 2))), 128))
|
|
926
|
+
])) : z("", !0),
|
|
927
|
+
t.message.role === "user" ? (a(), m("div", ft, V(t.message.content), 1)) : z("", !0),
|
|
928
|
+
t.message.role === "assistant" ? (a(), m(K, { key: 2 }, [
|
|
929
|
+
t.message.reasoning ? (a(), m("div", _t, [
|
|
930
|
+
f("details", null, [
|
|
931
|
+
n[0] || (n[0] = f("summary", null, "\u63A8\u7406\u8FC7\u7A0B", -1)),
|
|
932
|
+
f("pre", null, V(t.message.reasoning), 1)
|
|
933
|
+
])
|
|
934
|
+
])) : z("", !0),
|
|
935
|
+
f("div", {
|
|
936
|
+
class: "message-content markdown-body",
|
|
937
|
+
innerHTML: l.value
|
|
938
|
+
}, null, 8, ht),
|
|
939
|
+
(a(!0), m(K, null, U(t.message.renderBlocks, (C, M) => (a(), j(nt, {
|
|
940
|
+
key: M,
|
|
941
|
+
block: C,
|
|
942
|
+
"resolved-component": p(C)
|
|
943
|
+
}, null, 8, ["block", "resolved-component"]))), 128)),
|
|
944
|
+
t.message.suggestedNext ? (a(), j(lt, {
|
|
945
|
+
key: 1,
|
|
946
|
+
text: t.message.suggestedNext,
|
|
947
|
+
onExecute: E
|
|
948
|
+
}, null, 8, ["text"])) : z("", !0)
|
|
949
|
+
], 64)) : z("", !0),
|
|
950
|
+
t.message.status === "streaming" ? (a(), m("div", vt, "\u258D")) : z("", !0),
|
|
951
|
+
t.message.status === "error" ? (a(), m("div", Ft, V(t.message.error), 1)) : z("", !0)
|
|
952
|
+
])
|
|
953
|
+
], 2);
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
});
|
|
957
|
+
const Et = /* @__PURE__ */ Q(yt, [["__scopeId", "data-v-fe82b4e5"]]), Ct = { class: "chat-input" }, xt = {
|
|
958
|
+
key: 0,
|
|
959
|
+
class: "chat-input__files"
|
|
960
|
+
}, Dt = { class: "chat-input__wrap" }, kt = { class: "chat-input__actions" }, Bt = /* @__PURE__ */ N({
|
|
961
|
+
__name: "ChatInput",
|
|
962
|
+
props: {
|
|
963
|
+
loading: { type: Boolean },
|
|
964
|
+
disabled: { type: Boolean },
|
|
965
|
+
placeholder: {}
|
|
966
|
+
},
|
|
967
|
+
emits: ["send"],
|
|
968
|
+
setup(t, { emit: e }) {
|
|
969
|
+
const s = t, d = e, r = W(""), l = W([]), p = W(null), E = Y(
|
|
970
|
+
() => (r.value.trim().length > 0 || l.value.length > 0) && !s.disabled
|
|
971
|
+
);
|
|
972
|
+
function u() {
|
|
973
|
+
var h;
|
|
974
|
+
(h = p.value) == null || h.click();
|
|
975
|
+
}
|
|
976
|
+
const n = /* @__PURE__ */ new Set([
|
|
977
|
+
"text/plain",
|
|
978
|
+
"text/html",
|
|
979
|
+
"text/css",
|
|
980
|
+
"text/javascript",
|
|
981
|
+
"text/typescript",
|
|
982
|
+
"text/markdown",
|
|
983
|
+
"text/csv",
|
|
984
|
+
"text/xml",
|
|
985
|
+
"application/json",
|
|
986
|
+
"application/xml",
|
|
987
|
+
"application/javascript",
|
|
988
|
+
"application/typescript",
|
|
989
|
+
"application/yaml",
|
|
990
|
+
"application/x-yaml"
|
|
991
|
+
]);
|
|
992
|
+
function g(h) {
|
|
993
|
+
var w;
|
|
994
|
+
if (h.type.startsWith("text/") || n.has(h.type))
|
|
995
|
+
return !0;
|
|
996
|
+
if (h.type === "" || h.type.startsWith("application/")) {
|
|
997
|
+
const F = (w = h.name.split(".").pop()) == null ? void 0 : w.toLowerCase();
|
|
998
|
+
return (/* @__PURE__ */ new Set([
|
|
999
|
+
"txt",
|
|
1000
|
+
"md",
|
|
1001
|
+
"json",
|
|
1002
|
+
"geojson",
|
|
1003
|
+
"xml",
|
|
1004
|
+
"yml",
|
|
1005
|
+
"yaml",
|
|
1006
|
+
"csv",
|
|
1007
|
+
"ts",
|
|
1008
|
+
"js",
|
|
1009
|
+
"tsx",
|
|
1010
|
+
"jsx",
|
|
1011
|
+
"vue",
|
|
1012
|
+
"html",
|
|
1013
|
+
"css",
|
|
1014
|
+
"scss",
|
|
1015
|
+
"less",
|
|
1016
|
+
"sh",
|
|
1017
|
+
"bat",
|
|
1018
|
+
"ps1",
|
|
1019
|
+
"py",
|
|
1020
|
+
"java",
|
|
1021
|
+
"c",
|
|
1022
|
+
"cpp",
|
|
1023
|
+
"h",
|
|
1024
|
+
"hpp",
|
|
1025
|
+
"go",
|
|
1026
|
+
"rs",
|
|
1027
|
+
"rb",
|
|
1028
|
+
"php",
|
|
1029
|
+
"sql",
|
|
1030
|
+
"toml",
|
|
1031
|
+
"ini",
|
|
1032
|
+
"cfg",
|
|
1033
|
+
"conf",
|
|
1034
|
+
"log",
|
|
1035
|
+
"env",
|
|
1036
|
+
"gitignore",
|
|
1037
|
+
"dockerfile",
|
|
1038
|
+
"wkt",
|
|
1039
|
+
"wkb",
|
|
1040
|
+
"kml",
|
|
1041
|
+
"gpx",
|
|
1042
|
+
"geojson",
|
|
1043
|
+
"topojson",
|
|
1044
|
+
"xlsx",
|
|
1045
|
+
"docx"
|
|
1046
|
+
])).has(F != null ? F : "");
|
|
1047
|
+
}
|
|
1048
|
+
return !1;
|
|
1049
|
+
}
|
|
1050
|
+
function y(h) {
|
|
1051
|
+
return new Promise((w) => {
|
|
1052
|
+
const F = new FileReader();
|
|
1053
|
+
F.onload = () => {
|
|
1054
|
+
w({
|
|
1055
|
+
id: "",
|
|
1056
|
+
name: h.name,
|
|
1057
|
+
size: h.size,
|
|
1058
|
+
type: h.type,
|
|
1059
|
+
data: F.result
|
|
1060
|
+
});
|
|
1061
|
+
}, g(h) ? F.readAsText(h) : F.readAsDataURL(h);
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
async function C(h) {
|
|
1065
|
+
var F;
|
|
1066
|
+
const w = h.target;
|
|
1067
|
+
if (!!((F = w.files) != null && F.length)) {
|
|
1068
|
+
for (const c of Array.from(w.files)) {
|
|
1069
|
+
const H = await y(c);
|
|
1070
|
+
l.value.push(H);
|
|
1071
|
+
}
|
|
1072
|
+
w.value = "";
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
function M(h) {
|
|
1076
|
+
l.value.splice(h, 1);
|
|
1077
|
+
}
|
|
1078
|
+
function O(h) {
|
|
1079
|
+
h.shiftKey || (h.preventDefault(), T());
|
|
1080
|
+
}
|
|
1081
|
+
function T() {
|
|
1082
|
+
if (!E.value || s.loading)
|
|
1083
|
+
return;
|
|
1084
|
+
const h = r.value.trim();
|
|
1085
|
+
d("send", h, l.value), r.value = "", l.value = [];
|
|
1086
|
+
}
|
|
1087
|
+
return (h, w) => {
|
|
1088
|
+
const F = S("el-icon"), c = S("el-tag"), H = S("el-input"), J = S("el-button"), q = S("el-tooltip");
|
|
1089
|
+
return a(), m("div", Ct, [
|
|
1090
|
+
l.value.length ? (a(), m("div", xt, [
|
|
1091
|
+
(a(!0), m(K, null, U(l.value, (P, x) => (a(), j(c, {
|
|
1092
|
+
key: x,
|
|
1093
|
+
closable: "",
|
|
1094
|
+
size: "small",
|
|
1095
|
+
type: P.type.startsWith("image/") ? "success" : "info",
|
|
1096
|
+
onClose: (I) => M(x)
|
|
1097
|
+
}, {
|
|
1098
|
+
default: v(() => [
|
|
1099
|
+
P.type.startsWith("image/") ? (a(), j(F, {
|
|
1100
|
+
key: 0,
|
|
1101
|
+
style: { "margin-right": "4px" }
|
|
1102
|
+
}, {
|
|
1103
|
+
default: v(() => [
|
|
1104
|
+
_(A(Te))
|
|
1105
|
+
]),
|
|
1106
|
+
_: 1
|
|
1107
|
+
})) : (a(), j(F, {
|
|
1108
|
+
key: 1,
|
|
1109
|
+
style: { "margin-right": "4px" }
|
|
1110
|
+
}, {
|
|
1111
|
+
default: v(() => [
|
|
1112
|
+
_(A(le))
|
|
1113
|
+
]),
|
|
1114
|
+
_: 1
|
|
1115
|
+
})),
|
|
1116
|
+
R(" " + V(P.name), 1)
|
|
1117
|
+
]),
|
|
1118
|
+
_: 2
|
|
1119
|
+
}, 1032, ["type", "onClose"]))), 128))
|
|
1120
|
+
])) : z("", !0),
|
|
1121
|
+
f("div", Dt, [
|
|
1122
|
+
_(H, {
|
|
1123
|
+
modelValue: r.value,
|
|
1124
|
+
"onUpdate:modelValue": w[0] || (w[0] = (P) => r.value = P),
|
|
1125
|
+
type: "textarea",
|
|
1126
|
+
autosize: { minRows: 1, maxRows: 6 },
|
|
1127
|
+
resize: "none",
|
|
1128
|
+
placeholder: t.placeholder,
|
|
1129
|
+
onKeydown: pe(O, ["enter"])
|
|
1130
|
+
}, null, 8, ["modelValue", "placeholder"]),
|
|
1131
|
+
f("div", kt, [
|
|
1132
|
+
_(q, {
|
|
1133
|
+
content: "\u4E0A\u4F20\u6587\u4EF6",
|
|
1134
|
+
placement: "top"
|
|
1135
|
+
}, {
|
|
1136
|
+
default: v(() => [
|
|
1137
|
+
_(J, {
|
|
1138
|
+
text: "",
|
|
1139
|
+
circle: "",
|
|
1140
|
+
onClick: u
|
|
1141
|
+
}, {
|
|
1142
|
+
default: v(() => [
|
|
1143
|
+
_(F, null, {
|
|
1144
|
+
default: v(() => [
|
|
1145
|
+
_(A(Ve))
|
|
1146
|
+
]),
|
|
1147
|
+
_: 1
|
|
1148
|
+
})
|
|
1149
|
+
]),
|
|
1150
|
+
_: 1
|
|
1151
|
+
})
|
|
1152
|
+
]),
|
|
1153
|
+
_: 1
|
|
1154
|
+
}),
|
|
1155
|
+
f("input", {
|
|
1156
|
+
ref_key: "fileInputRef",
|
|
1157
|
+
ref: p,
|
|
1158
|
+
type: "file",
|
|
1159
|
+
multiple: "",
|
|
1160
|
+
hidden: "",
|
|
1161
|
+
onChange: C
|
|
1162
|
+
}, null, 544),
|
|
1163
|
+
_(q, {
|
|
1164
|
+
content: "Enter \u53D1\u9001\uFF0CShift+Enter \u6362\u884C",
|
|
1165
|
+
placement: "top"
|
|
1166
|
+
}, {
|
|
1167
|
+
default: v(() => [
|
|
1168
|
+
_(J, {
|
|
1169
|
+
type: "primary",
|
|
1170
|
+
icon: A(je),
|
|
1171
|
+
loading: t.loading,
|
|
1172
|
+
disabled: !E.value,
|
|
1173
|
+
circle: "",
|
|
1174
|
+
onClick: T
|
|
1175
|
+
}, null, 8, ["icon", "loading", "disabled"])
|
|
1176
|
+
]),
|
|
1177
|
+
_: 1
|
|
1178
|
+
})
|
|
1179
|
+
])
|
|
1180
|
+
])
|
|
1181
|
+
]);
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
const wt = /* @__PURE__ */ Q(Bt, [["__scopeId", "data-v-1f9902c6"]]), At = [
|
|
1186
|
+
{ label: "deepseek-chat (V3 \u6700\u5F3A)", value: "deepseek-chat" },
|
|
1187
|
+
{ label: "deepseek-reasoner (R1 \u63A8\u7406)", value: "deepseek-reasoner" }
|
|
1188
|
+
], bt = { class: "form-tip" }, $t = { class: "temp-row" }, St = { class: "temp-val" }, It = /* @__PURE__ */ N({
|
|
1189
|
+
__name: "ChatSettings",
|
|
1190
|
+
props: {
|
|
1191
|
+
modelValue: { type: Boolean },
|
|
1192
|
+
settings: {}
|
|
1193
|
+
},
|
|
1194
|
+
emits: ["update:modelValue", "save"],
|
|
1195
|
+
setup(t, { emit: e }) {
|
|
1196
|
+
const s = t, d = e, r = W(s.modelValue);
|
|
1197
|
+
ee(
|
|
1198
|
+
() => s.modelValue,
|
|
1199
|
+
(E) => {
|
|
1200
|
+
r.value = E, E && (l.value = { ...s.settings });
|
|
1201
|
+
}
|
|
1202
|
+
), ee(r, (E) => d("update:modelValue", E));
|
|
1203
|
+
const l = W({ ...s.settings });
|
|
1204
|
+
function p() {
|
|
1205
|
+
d("save", { ...l.value }), r.value = !1;
|
|
1206
|
+
}
|
|
1207
|
+
return (E, u) => {
|
|
1208
|
+
const n = S("el-input"), g = S("el-link"), y = S("el-form-item"), C = S("el-option"), M = S("el-select"), O = S("el-slider"), T = S("el-switch"), h = S("el-form"), w = S("el-button"), F = S("el-dialog");
|
|
1209
|
+
return a(), j(F, {
|
|
1210
|
+
modelValue: r.value,
|
|
1211
|
+
"onUpdate:modelValue": u[6] || (u[6] = (c) => r.value = c),
|
|
1212
|
+
title: "AI \u52A9\u624B\u8BBE\u7F6E",
|
|
1213
|
+
width: "520px",
|
|
1214
|
+
"append-to-body": ""
|
|
1215
|
+
}, {
|
|
1216
|
+
footer: v(() => [
|
|
1217
|
+
_(w, {
|
|
1218
|
+
onClick: u[5] || (u[5] = (c) => r.value = !1)
|
|
1219
|
+
}, {
|
|
1220
|
+
default: v(() => [...u[11] || (u[11] = [
|
|
1221
|
+
R("\u53D6\u6D88", -1)
|
|
1222
|
+
])]),
|
|
1223
|
+
_: 1
|
|
1224
|
+
}),
|
|
1225
|
+
_(w, {
|
|
1226
|
+
type: "primary",
|
|
1227
|
+
onClick: p
|
|
1228
|
+
}, {
|
|
1229
|
+
default: v(() => [...u[12] || (u[12] = [
|
|
1230
|
+
R("\u4FDD\u5B58", -1)
|
|
1231
|
+
])]),
|
|
1232
|
+
_: 1
|
|
1233
|
+
})
|
|
1234
|
+
]),
|
|
1235
|
+
default: v(() => [
|
|
1236
|
+
_(h, {
|
|
1237
|
+
model: l.value,
|
|
1238
|
+
"label-width": "110px",
|
|
1239
|
+
"label-position": "right"
|
|
1240
|
+
}, {
|
|
1241
|
+
default: v(() => [
|
|
1242
|
+
_(y, { label: "API Key" }, {
|
|
1243
|
+
default: v(() => [
|
|
1244
|
+
_(n, {
|
|
1245
|
+
modelValue: l.value.apiKey,
|
|
1246
|
+
"onUpdate:modelValue": u[0] || (u[0] = (c) => l.value.apiKey = c),
|
|
1247
|
+
type: "password",
|
|
1248
|
+
"show-password": "",
|
|
1249
|
+
placeholder: "sk-xxxxxxxxxxxxxxxx",
|
|
1250
|
+
clearable: ""
|
|
1251
|
+
}, null, 8, ["modelValue"]),
|
|
1252
|
+
f("div", bt, [
|
|
1253
|
+
u[8] || (u[8] = R(" \u5728 ", -1)),
|
|
1254
|
+
_(g, {
|
|
1255
|
+
type: "primary",
|
|
1256
|
+
href: "https://platform.deepseek.com/api_keys",
|
|
1257
|
+
target: "_blank"
|
|
1258
|
+
}, {
|
|
1259
|
+
default: v(() => [...u[7] || (u[7] = [
|
|
1260
|
+
R(" DeepSeek \u5F00\u653E\u5E73\u53F0 ", -1)
|
|
1261
|
+
])]),
|
|
1262
|
+
_: 1
|
|
1263
|
+
}),
|
|
1264
|
+
u[9] || (u[9] = R(" \u83B7\u53D6\uFF0C\u4EC5\u4FDD\u5B58\u5728\u6D4F\u89C8\u5668\u672C\u5730\u3002 ", -1))
|
|
1265
|
+
])
|
|
1266
|
+
]),
|
|
1267
|
+
_: 1
|
|
1268
|
+
}),
|
|
1269
|
+
_(y, { label: "\u63A5\u53E3\u5730\u5740" }, {
|
|
1270
|
+
default: v(() => [
|
|
1271
|
+
_(n, {
|
|
1272
|
+
modelValue: l.value.baseUrl,
|
|
1273
|
+
"onUpdate:modelValue": u[1] || (u[1] = (c) => l.value.baseUrl = c),
|
|
1274
|
+
placeholder: "https://api.deepseek.com",
|
|
1275
|
+
clearable: ""
|
|
1276
|
+
}, null, 8, ["modelValue"])
|
|
1277
|
+
]),
|
|
1278
|
+
_: 1
|
|
1279
|
+
}),
|
|
1280
|
+
_(y, { label: "\u6A21\u578B" }, {
|
|
1281
|
+
default: v(() => [
|
|
1282
|
+
_(M, {
|
|
1283
|
+
modelValue: l.value.model,
|
|
1284
|
+
"onUpdate:modelValue": u[2] || (u[2] = (c) => l.value.model = c),
|
|
1285
|
+
style: { width: "100%" }
|
|
1286
|
+
}, {
|
|
1287
|
+
default: v(() => [
|
|
1288
|
+
(a(!0), m(K, null, U(A(At), (c) => (a(), j(C, {
|
|
1289
|
+
key: c.value,
|
|
1290
|
+
label: c.label,
|
|
1291
|
+
value: c.value
|
|
1292
|
+
}, null, 8, ["label", "value"]))), 128))
|
|
1293
|
+
]),
|
|
1294
|
+
_: 1
|
|
1295
|
+
}, 8, ["modelValue"])
|
|
1296
|
+
]),
|
|
1297
|
+
_: 1
|
|
1298
|
+
}),
|
|
1299
|
+
_(y, { label: "\u6E29\u5EA6" }, {
|
|
1300
|
+
default: v(() => [
|
|
1301
|
+
f("div", $t, [
|
|
1302
|
+
_(O, {
|
|
1303
|
+
modelValue: l.value.temperature,
|
|
1304
|
+
"onUpdate:modelValue": u[3] || (u[3] = (c) => l.value.temperature = c),
|
|
1305
|
+
min: 0,
|
|
1306
|
+
max: 2,
|
|
1307
|
+
step: 0.1,
|
|
1308
|
+
style: { flex: "1" }
|
|
1309
|
+
}, null, 8, ["modelValue"]),
|
|
1310
|
+
f("span", St, V(l.value.temperature.toFixed(1)), 1)
|
|
1311
|
+
])
|
|
1312
|
+
]),
|
|
1313
|
+
_: 1
|
|
1314
|
+
}),
|
|
1315
|
+
_(y, { label: "\u542F\u7528\u5DE5\u5177" }, {
|
|
1316
|
+
default: v(() => [
|
|
1317
|
+
_(T, {
|
|
1318
|
+
modelValue: l.value.useTools,
|
|
1319
|
+
"onUpdate:modelValue": u[4] || (u[4] = (c) => l.value.useTools = c)
|
|
1320
|
+
}, null, 8, ["modelValue"]),
|
|
1321
|
+
u[10] || (u[10] = f("span", { class: "form-tip-inline" }, "\u5173\u95ED\u540E\u52A9\u624B\u4EC5\u5BF9\u8BDD\uFF0C\u4E0D\u4F1A\u6267\u884C\u9875\u9762\u5BFC\u822A/\u6570\u636E\u67E5\u8BE2\u7B49\u64CD\u4F5C", -1))
|
|
1322
|
+
]),
|
|
1323
|
+
_: 1
|
|
1324
|
+
})
|
|
1325
|
+
]),
|
|
1326
|
+
_: 1
|
|
1327
|
+
}, 8, ["model"])
|
|
1328
|
+
]),
|
|
1329
|
+
_: 1
|
|
1330
|
+
}, 8, ["modelValue"]);
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
});
|
|
1334
|
+
const Mt = /* @__PURE__ */ Q(It, [["__scopeId", "data-v-21ad42a2"]]), Vt = { class: "chat-panel" }, zt = {
|
|
1335
|
+
key: 0,
|
|
1336
|
+
class: "chat-panel__header"
|
|
1337
|
+
}, Tt = { class: "chat-panel__title" }, Pt = { class: "chat-panel__ops" }, jt = {
|
|
1338
|
+
key: 0,
|
|
1339
|
+
class: "chat-empty"
|
|
1340
|
+
}, Nt = { class: "chat-empty__logo" }, Rt = {
|
|
1341
|
+
key: 0,
|
|
1342
|
+
class: "chat-panel__error"
|
|
1343
|
+
}, Ht = { class: "chat-panel__footer" }, Kt = {
|
|
1344
|
+
key: 0,
|
|
1345
|
+
class: "chat-panel__stop"
|
|
1346
|
+
}, Lt = /* @__PURE__ */ N({
|
|
1347
|
+
__name: "ChatPanel",
|
|
1348
|
+
props: {
|
|
1349
|
+
chat: {},
|
|
1350
|
+
showHeader: { type: Boolean }
|
|
1351
|
+
},
|
|
1352
|
+
setup(t) {
|
|
1353
|
+
const e = t, {
|
|
1354
|
+
messages: s,
|
|
1355
|
+
settings: d,
|
|
1356
|
+
loading: r,
|
|
1357
|
+
errorMsg: l,
|
|
1358
|
+
hasApiKey: p,
|
|
1359
|
+
toolPackages: E,
|
|
1360
|
+
sendMessage: u,
|
|
1361
|
+
stopGeneration: n,
|
|
1362
|
+
clearMessages: g,
|
|
1363
|
+
saveSettings: y
|
|
1364
|
+
} = e.chat, C = W(!1), M = W(null);
|
|
1365
|
+
function O() {
|
|
1366
|
+
fe(() => {
|
|
1367
|
+
const F = M.value;
|
|
1368
|
+
F && (F.scrollTop = F.scrollHeight);
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
function T(F, c) {
|
|
1372
|
+
u(F, c), O();
|
|
1373
|
+
}
|
|
1374
|
+
function h(F) {
|
|
1375
|
+
y(F);
|
|
1376
|
+
}
|
|
1377
|
+
function w() {
|
|
1378
|
+
_e.confirm("\u786E\u5B9A\u8981\u6E05\u7A7A\u6240\u6709\u5BF9\u8BDD\u8BB0\u5F55\u5417\uFF1F", "\u63D0\u793A", {
|
|
1379
|
+
type: "warning",
|
|
1380
|
+
confirmButtonText: "\u6E05\u7A7A",
|
|
1381
|
+
cancelButtonText: "\u53D6\u6D88"
|
|
1382
|
+
}).then(() => {
|
|
1383
|
+
g();
|
|
1384
|
+
}).catch(() => {
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
return ee(
|
|
1388
|
+
() => s.value.map((F) => {
|
|
1389
|
+
var c;
|
|
1390
|
+
return F.content + F.status + (((c = F.renderBlocks) == null ? void 0 : c.length) || 0);
|
|
1391
|
+
}).join("|"),
|
|
1392
|
+
() => O()
|
|
1393
|
+
), (F, c) => {
|
|
1394
|
+
const H = S("ChatDotRound"), J = S("el-icon"), q = S("el-tag"), P = S("el-button"), x = S("el-tooltip"), I = S("el-alert");
|
|
1395
|
+
return a(), m("div", Vt, [
|
|
1396
|
+
t.showHeader ? (a(), m("div", zt, [
|
|
1397
|
+
f("div", Tt, [
|
|
1398
|
+
_(J, { class: "title-icon" }, {
|
|
1399
|
+
default: v(() => [
|
|
1400
|
+
_(H)
|
|
1401
|
+
]),
|
|
1402
|
+
_: 1
|
|
1403
|
+
}),
|
|
1404
|
+
c[5] || (c[5] = f("span", null, "AI \u667A\u80FD\u52A9\u624B", -1)),
|
|
1405
|
+
A(p) ? (a(), j(q, {
|
|
1406
|
+
key: 0,
|
|
1407
|
+
size: "small",
|
|
1408
|
+
type: "success",
|
|
1409
|
+
effect: "plain"
|
|
1410
|
+
}, {
|
|
1411
|
+
default: v(() => [...c[3] || (c[3] = [
|
|
1412
|
+
R("\u5DF2\u914D\u7F6E", -1)
|
|
1413
|
+
])]),
|
|
1414
|
+
_: 1
|
|
1415
|
+
})) : (a(), j(q, {
|
|
1416
|
+
key: 1,
|
|
1417
|
+
size: "small",
|
|
1418
|
+
type: "warning",
|
|
1419
|
+
effect: "plain"
|
|
1420
|
+
}, {
|
|
1421
|
+
default: v(() => [...c[4] || (c[4] = [
|
|
1422
|
+
R("\u672A\u914D\u7F6E", -1)
|
|
1423
|
+
])]),
|
|
1424
|
+
_: 1
|
|
1425
|
+
}))
|
|
1426
|
+
]),
|
|
1427
|
+
f("div", Pt, [
|
|
1428
|
+
_(x, {
|
|
1429
|
+
content: "\u8BBE\u7F6E",
|
|
1430
|
+
placement: "bottom"
|
|
1431
|
+
}, {
|
|
1432
|
+
default: v(() => [
|
|
1433
|
+
_(P, {
|
|
1434
|
+
text: "",
|
|
1435
|
+
circle: "",
|
|
1436
|
+
onClick: c[0] || (c[0] = (D) => C.value = !0)
|
|
1437
|
+
}, {
|
|
1438
|
+
default: v(() => [
|
|
1439
|
+
_(J, null, {
|
|
1440
|
+
default: v(() => [
|
|
1441
|
+
_(A(oe))
|
|
1442
|
+
]),
|
|
1443
|
+
_: 1
|
|
1444
|
+
})
|
|
1445
|
+
]),
|
|
1446
|
+
_: 1
|
|
1447
|
+
})
|
|
1448
|
+
]),
|
|
1449
|
+
_: 1
|
|
1450
|
+
}),
|
|
1451
|
+
_(x, {
|
|
1452
|
+
content: "\u6E05\u7A7A\u5BF9\u8BDD",
|
|
1453
|
+
placement: "bottom"
|
|
1454
|
+
}, {
|
|
1455
|
+
default: v(() => [
|
|
1456
|
+
_(P, {
|
|
1457
|
+
text: "",
|
|
1458
|
+
circle: "",
|
|
1459
|
+
disabled: !A(s).length,
|
|
1460
|
+
onClick: w
|
|
1461
|
+
}, {
|
|
1462
|
+
default: v(() => [
|
|
1463
|
+
_(J, null, {
|
|
1464
|
+
default: v(() => [
|
|
1465
|
+
_(A(Se))
|
|
1466
|
+
]),
|
|
1467
|
+
_: 1
|
|
1468
|
+
})
|
|
1469
|
+
]),
|
|
1470
|
+
_: 1
|
|
1471
|
+
}, 8, ["disabled"])
|
|
1472
|
+
]),
|
|
1473
|
+
_: 1
|
|
1474
|
+
})
|
|
1475
|
+
])
|
|
1476
|
+
])) : z("", !0),
|
|
1477
|
+
f("div", {
|
|
1478
|
+
ref_key: "scrollRef",
|
|
1479
|
+
ref: M,
|
|
1480
|
+
class: "chat-panel__body"
|
|
1481
|
+
}, [
|
|
1482
|
+
A(s).length ? (a(!0), m(K, { key: 1 }, U(A(s), (D) => (a(), j(Et, {
|
|
1483
|
+
key: D.id,
|
|
1484
|
+
message: D,
|
|
1485
|
+
"tool-packages": A(E),
|
|
1486
|
+
onExecute: T
|
|
1487
|
+
}, null, 8, ["message", "tool-packages"]))), 128)) : (a(), m("div", jt, [
|
|
1488
|
+
f("div", Nt, [
|
|
1489
|
+
_(J, null, {
|
|
1490
|
+
default: v(() => [
|
|
1491
|
+
_(H)
|
|
1492
|
+
]),
|
|
1493
|
+
_: 1
|
|
1494
|
+
})
|
|
1495
|
+
]),
|
|
1496
|
+
c[7] || (c[7] = f("h3", null, "\u4F60\u597D\uFF0C\u6211\u662F\u7CFB\u7EDF AI \u52A9\u624B", -1)),
|
|
1497
|
+
c[8] || (c[8] = f("p", { class: "chat-empty__desc" }, [
|
|
1498
|
+
R(" \u6211\u53EF\u4EE5\u5E2E\u4F60"),
|
|
1499
|
+
f("span", { class: "hl" }, "\u67E5\u8BE2\u6570\u636E"),
|
|
1500
|
+
R("\u3001"),
|
|
1501
|
+
f("span", { class: "hl" }, "\u6267\u884C\u64CD\u4F5C"),
|
|
1502
|
+
R("\u3002\u8BD5\u8BD5\u8F93\u5165\u6307\u4EE4\uFF1A ")
|
|
1503
|
+
], -1)),
|
|
1504
|
+
A(p) ? z("", !0) : (a(), j(P, {
|
|
1505
|
+
key: 0,
|
|
1506
|
+
type: "primary",
|
|
1507
|
+
icon: A(oe),
|
|
1508
|
+
onClick: c[1] || (c[1] = (D) => C.value = !0)
|
|
1509
|
+
}, {
|
|
1510
|
+
default: v(() => [...c[6] || (c[6] = [
|
|
1511
|
+
R(" \u5148\u914D\u7F6E API Key ", -1)
|
|
1512
|
+
])]),
|
|
1513
|
+
_: 1
|
|
1514
|
+
}, 8, ["icon"]))
|
|
1515
|
+
]))
|
|
1516
|
+
], 512),
|
|
1517
|
+
_(ge, { name: "fade" }, {
|
|
1518
|
+
default: v(() => [
|
|
1519
|
+
A(l) ? (a(), m("div", Rt, [
|
|
1520
|
+
_(I, {
|
|
1521
|
+
title: A(l),
|
|
1522
|
+
type: "error",
|
|
1523
|
+
"show-icon": "",
|
|
1524
|
+
closable: !1
|
|
1525
|
+
}, null, 8, ["title"])
|
|
1526
|
+
])) : z("", !0)
|
|
1527
|
+
]),
|
|
1528
|
+
_: 1
|
|
1529
|
+
}),
|
|
1530
|
+
f("div", Ht, [
|
|
1531
|
+
A(r) ? (a(), m("div", Kt, [
|
|
1532
|
+
_(P, {
|
|
1533
|
+
size: "small",
|
|
1534
|
+
icon: A(Le),
|
|
1535
|
+
onClick: A(n)
|
|
1536
|
+
}, {
|
|
1537
|
+
default: v(() => [...c[9] || (c[9] = [
|
|
1538
|
+
R("\u505C\u6B62\u751F\u6210", -1)
|
|
1539
|
+
])]),
|
|
1540
|
+
_: 1
|
|
1541
|
+
}, 8, ["icon", "onClick"])
|
|
1542
|
+
])) : z("", !0),
|
|
1543
|
+
_(wt, {
|
|
1544
|
+
loading: A(r),
|
|
1545
|
+
placeholder: A(p) ? "\u8F93\u5165\u6307\u4EE4..." : "\u8BF7\u5148\u914D\u7F6E API Key",
|
|
1546
|
+
onSend: T
|
|
1547
|
+
}, null, 8, ["loading", "placeholder"])
|
|
1548
|
+
]),
|
|
1549
|
+
_(Mt, {
|
|
1550
|
+
modelValue: C.value,
|
|
1551
|
+
"onUpdate:modelValue": c[2] || (c[2] = (D) => C.value = D),
|
|
1552
|
+
settings: A(d),
|
|
1553
|
+
onSave: h
|
|
1554
|
+
}, null, 8, ["modelValue", "settings"])
|
|
1555
|
+
]);
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
});
|
|
1559
|
+
const Xt = /* @__PURE__ */ Q(Lt, [["__scopeId", "data-v-b29b5a67"]]);
|
|
1560
|
+
export {
|
|
1561
|
+
he as Agent,
|
|
1562
|
+
wt as ChatInput,
|
|
1563
|
+
Et as ChatMessage,
|
|
1564
|
+
Xt as ChatPanel,
|
|
1565
|
+
Mt as ChatSettings,
|
|
1566
|
+
ue as DEFAULT_SETTINGS,
|
|
1567
|
+
nt as RenderBlock,
|
|
1568
|
+
lt as SuggestedNext,
|
|
1569
|
+
ve as ToolRegistry,
|
|
1570
|
+
Ce as buildSystemPrompt,
|
|
1571
|
+
ye as createDeepSeekProvider,
|
|
1572
|
+
Gt as resolveRenderBlock,
|
|
1573
|
+
qt as useAgentChat
|
|
1574
|
+
};
|