mslxdff 0.1.81 → 0.1.82
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/package.json
CHANGED
|
@@ -29,11 +29,10 @@ async function clineBenchOne({ baseUrl, model, accessToken, prompt, maxTokens, t
|
|
|
29
29
|
const reader = res.body.getReader();
|
|
30
30
|
const decoder = new TextDecoder();
|
|
31
31
|
let buf = "";
|
|
32
|
-
const firstChunkAt = performance.now();
|
|
33
32
|
for (;;) {
|
|
34
33
|
const { done, value } = await reader.read();
|
|
35
34
|
if (done) break;
|
|
36
|
-
if (ttfbMs === null) ttfbMs = Math.round(performance.now() -
|
|
35
|
+
if (ttfbMs === null) ttfbMs = Math.round(performance.now() - t0);
|
|
37
36
|
buf += decoder.decode(value, { stream: true });
|
|
38
37
|
let idx;
|
|
39
38
|
while ((idx = buf.indexOf("\n")) >= 0) {
|
|
@@ -199,8 +198,18 @@ async function handleVia({ providerId, opts, fetchImpl, loadConfigs, loadKeys, l
|
|
|
199
198
|
const auth = auths[aIdx] || auths[0] || null;
|
|
200
199
|
const cKeys = keys.filter((k) => isRefreshToken(k, p));
|
|
201
200
|
if (cKeys.length) {
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
const normBase = String(baseUrl).replace(/\/+$/, "");
|
|
202
|
+
const chatBase = normBase.endsWith("/api/v1") ? normBase.slice(0, -7) : normBase;
|
|
203
|
+
const rt = cKeys[0];
|
|
204
|
+
const at = await refreshTokenForBase({ refreshToken: rt, baseUrl: normBase, fetchImpl });
|
|
205
|
+
if (!at) return { ok: false, label: "鉴权失败", error: "refresh failed", ttfbMs: null, totalMs: 0 };
|
|
206
|
+
const targetUrl = `${chatBase}/api/v1/chat/completions`;
|
|
207
|
+
const headers = clineHeaders(`sess_bench_via_${Date.now()}`, at);
|
|
208
|
+
const rawModel = String(model).startsWith(`${p}/`) ? String(model).slice(p.length + 1) : String(model);
|
|
209
|
+
const body = { model: rawModel, messages: [{ role: "user", content: "hi" }], stream: true, max_tokens: 5, session_id: `sess_bench_via_${Date.now()}`, reasoning_effort: "high" };
|
|
210
|
+
const peer = peers.find((pe) => pe.url === peerUrl || (pe.name || pe.id) === peerUrl);
|
|
211
|
+
const peerToken = peer?.token || token;
|
|
212
|
+
return viaProbe({ peerUrl, token: peerToken, relayTarget: targetUrl, relayHeaders: headers, relayBody: body, timeoutMs: opts.timeoutMs, fetchImpl });
|
|
204
213
|
}
|
|
205
214
|
const rawModel = String(model).startsWith(`${p}/`) ? String(model).slice(p.length + 1) : String(model);
|
|
206
215
|
const targetUrl = p === "opencode" ? `${process.env.UPSTREAM_BASE_URL || "https://opencode.ai"}/zen/v1/chat/completions` : `${String(baseUrl).replace(/\/+$/, "")}${chatPath}`;
|