st-comp 0.0.266 → 0.0.268
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/es/MonacoEditor.cjs +1 -1
- package/es/MonacoEditor.js +1 -1
- package/es/VarietyAiHelper.cjs +3 -3
- package/es/VarietyAiHelper.js +250 -269
- package/es/VarietySearch.cjs +1 -1
- package/es/VarietySearch.js +2 -2
- package/es/aiTools-822859d6.cjs +4 -0
- package/es/aiTools-9a9c997f.js +149 -0
- package/es/aiTools.js +2 -2
- package/es/{index-8b055879.cjs → index-eeae573e.cjs} +2 -2
- package/es/{index-d857270a.js → index-f2583ae9.js} +2 -2
- package/es/{python-5b5c9c58.cjs → python-18d44a7b.cjs} +1 -1
- package/es/{python-ad9239f9.js → python-86a0735f.js} +1 -1
- package/es/style.css +1 -1
- package/lib/aiTools.js +2 -2
- package/lib/bundle.js +1 -1
- package/lib/bundle.umd.cjs +194 -194
- package/lib/{index-53b3465c.js → index-8edd5697.js} +12864 -12883
- package/lib/{python-4a270481.js → python-5c07749c.js} +1 -1
- package/lib/style.css +1 -1
- package/package.json +1 -1
- package/packages/VarietyAiHelper/index.vue +226 -90
- package/public/aiTools.js +2 -2
- package/es/aiTools-6c9c58bd.cjs +0 -4
- package/es/aiTools-ab67ffa0.js +0 -149
package/es/aiTools-ab67ffa0.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
const O = async ({ appId: h, apiKey: u, value: g, callback: t }) => {
|
|
2
|
-
var o;
|
|
3
|
-
try {
|
|
4
|
-
const r = await fetch(`https://dashscope.aliyuncs.com/api/v1/apps/${h}/completion`, {
|
|
5
|
-
method: "POST",
|
|
6
|
-
body: JSON.stringify({
|
|
7
|
-
input: { prompt: g },
|
|
8
|
-
parameters: { incremental_output: "true" },
|
|
9
|
-
debug: {}
|
|
10
|
-
}),
|
|
11
|
-
headers: {
|
|
12
|
-
Authorization: `Bearer ${u}`,
|
|
13
|
-
"Content-Type": "application/json",
|
|
14
|
-
"X-DashScope-SSE": "enable"
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
if (!r.ok) {
|
|
18
|
-
t("error", `HTTP ${r.status}: ${r.statusText}`);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const m = r.body.getReader(), s = new TextDecoder();
|
|
22
|
-
let n = "", c = null;
|
|
23
|
-
for (; ; ) {
|
|
24
|
-
const { done: l, value: S } = await m.read();
|
|
25
|
-
if (l) {
|
|
26
|
-
n.trim() && w(n, t), t("finish", "");
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
n += s.decode(S, { stream: !0 });
|
|
30
|
-
let f;
|
|
31
|
-
for (; (f = n.indexOf(`
|
|
32
|
-
`)) !== -1; ) {
|
|
33
|
-
const p = n.substring(0, f).trim();
|
|
34
|
-
if (n = n.substring(f + 1), p.startsWith("event:")) {
|
|
35
|
-
c = p.substring(6).trim();
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
if (p.startsWith("data:")) {
|
|
39
|
-
const d = p.substring(5).trim();
|
|
40
|
-
if (c === "error" || d && d.startsWith("{"))
|
|
41
|
-
try {
|
|
42
|
-
const i = JSON.parse(d);
|
|
43
|
-
if (i.code || i.message || c === "error") {
|
|
44
|
-
const a = i.message || i.code || "未知错误";
|
|
45
|
-
t("error", `百炼服务端错误: ${a}`);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const e = (o = i == null ? void 0 : i.output) == null ? void 0 : o.text;
|
|
49
|
-
e && t && t("message", e);
|
|
50
|
-
} catch {
|
|
51
|
-
console.debug("JSON 解析失败:", d);
|
|
52
|
-
}
|
|
53
|
-
c = null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
} catch (r) {
|
|
58
|
-
console.error("流式请求失败:", r), t("error", r.message);
|
|
59
|
-
}
|
|
60
|
-
}, $ = async ({ appId: h, apiKey: u, value: g, callback: t }) => {
|
|
61
|
-
try {
|
|
62
|
-
const o = await fetch(`https://dashscope.aliyuncs.com/api/v1/apps/${h}/completion`, {
|
|
63
|
-
method: "POST",
|
|
64
|
-
body: JSON.stringify({
|
|
65
|
-
input: { prompt: g },
|
|
66
|
-
parameters: { incremental_output: "true", flow_stream_mode: "message_format_plus" },
|
|
67
|
-
debug: {}
|
|
68
|
-
}),
|
|
69
|
-
headers: {
|
|
70
|
-
Authorization: `Bearer ${u}`,
|
|
71
|
-
"Content-Type": "application/json",
|
|
72
|
-
"X-DashScope-SSE": "enable"
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
if (!o.ok) {
|
|
76
|
-
t("error", `HTTP ${o.status}: ${o.statusText}`);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const r = o.body.getReader(), m = new TextDecoder();
|
|
80
|
-
let s = "", n = "";
|
|
81
|
-
const c = {};
|
|
82
|
-
for (; ; ) {
|
|
83
|
-
const { done: l, value: S } = await r.read();
|
|
84
|
-
if (l) {
|
|
85
|
-
n && t("message", n), t("finish", "");
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
s += m.decode(S, { stream: !0 });
|
|
89
|
-
let f;
|
|
90
|
-
for (; (f = s.indexOf(`
|
|
91
|
-
`)) !== -1; ) {
|
|
92
|
-
const p = s.substring(0, f).trim();
|
|
93
|
-
if (s = s.substring(f + 1), p.startsWith("data:")) {
|
|
94
|
-
const d = p.substring(5).trim();
|
|
95
|
-
if (!d || d === "[DONE]")
|
|
96
|
-
continue;
|
|
97
|
-
try {
|
|
98
|
-
const i = JSON.parse(d), e = i == null ? void 0 : i.output, a = e == null ? void 0 : e.workflow_message;
|
|
99
|
-
if (a != null && a.node_name && (a != null && a.node_type)) {
|
|
100
|
-
const y = a.node_name, T = a.node_status, x = a.node_is_completed, _ = c[y];
|
|
101
|
-
(_ !== T || x && _ !== "success") && (c[y] = x ? "success" : T, t("node", {
|
|
102
|
-
name: y,
|
|
103
|
-
status: x ? "success" : "executing"
|
|
104
|
-
}));
|
|
105
|
-
}
|
|
106
|
-
if ((e == null ? void 0 : e.finish_reason) === "stop" && (e != null && e.text) && (n = e.text), e != null && e.code || e != null && e.message) {
|
|
107
|
-
t("error", e.message || e.code || "未知错误");
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
} catch {
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
} catch (o) {
|
|
116
|
-
console.error("工作流请求失败:", o), t("error", o.message);
|
|
117
|
-
}
|
|
118
|
-
}, w = (h, u) => {
|
|
119
|
-
var o;
|
|
120
|
-
const g = h.split(`
|
|
121
|
-
`);
|
|
122
|
-
let t = null;
|
|
123
|
-
for (const r of g) {
|
|
124
|
-
if (r.startsWith("event:")) {
|
|
125
|
-
t = r.substring(6).trim();
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
if (r.startsWith("data:")) {
|
|
129
|
-
const m = r.substring(5).trim();
|
|
130
|
-
if (m && m !== "[DONE]")
|
|
131
|
-
try {
|
|
132
|
-
const s = JSON.parse(m);
|
|
133
|
-
if (t === "error" || s.code || s.message) {
|
|
134
|
-
const c = s.message || s.code || "未知错误";
|
|
135
|
-
u("error", `百炼服务端错误: ${c}`);
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
const n = (o = s == null ? void 0 : s.output) == null ? void 0 : o.text;
|
|
139
|
-
n && u && u("message", n);
|
|
140
|
-
} catch {
|
|
141
|
-
}
|
|
142
|
-
t = null;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
export {
|
|
147
|
-
O as a,
|
|
148
|
-
$ as s
|
|
149
|
-
};
|