@fudrouter/fsrouter 0.6.109 → 0.6.111
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.
|
@@ -2,7 +2,7 @@ import { getProviderNodeById } from "../../../models/index.js";
|
|
|
2
2
|
import { isOpenAICompatibleProvider, isAnthropicCompatibleProvider, isCustomEmbeddingProvider, AI_PROVIDERS } from "../../../shared/constants/providers.js";
|
|
3
3
|
import { getDefaultModel } from "../../../open-sse/config/providerModels.js";
|
|
4
4
|
import { resolveOllamaLocalHost, resolveXiaomiTokenplanBaseUrl, PROVIDERS } from "../../../open-sse/config/providers.js";
|
|
5
|
-
import {
|
|
5
|
+
import { openaiToCommandCodeRequest } from "../../../open-sse/translator/request/openai-to-commandcode.js";
|
|
6
6
|
import { PROVIDER_ENDPOINTS } from "../../../shared/constants/config.js";
|
|
7
7
|
import { normalizeProviderId } from "../../../lib/providerNormalization.js";
|
|
8
8
|
// Probe a webSearch/webFetch provider using its searchConfig/fetchConfig.
|
|
@@ -123,10 +123,10 @@ export async function POST_handler(req, res) {
|
|
|
123
123
|
return res.status(404).json({ error: "OpenAI Compatible node not found" });
|
|
124
124
|
}
|
|
125
125
|
const modelsUrl = `${node.baseUrl?.replace(/\/$/, "")}/models`;
|
|
126
|
-
const
|
|
126
|
+
const probeRes = await fetch(modelsUrl, {
|
|
127
127
|
headers: { "Authorization": `Bearer ${apiKey}` },
|
|
128
128
|
});
|
|
129
|
-
isValid =
|
|
129
|
+
isValid = probeRes.ok;
|
|
130
130
|
return res.json({
|
|
131
131
|
valid: isValid,
|
|
132
132
|
error: isValid ? null : "Invalid API key",
|
|
@@ -172,14 +172,14 @@ export async function POST_handler(req, res) {
|
|
|
172
172
|
normalizedBase = normalizedBase.slice(0, -9); // remove /messages
|
|
173
173
|
}
|
|
174
174
|
const modelsUrl = `${normalizedBase}/models`;
|
|
175
|
-
const
|
|
175
|
+
const probeRes = await fetch(modelsUrl, {
|
|
176
176
|
headers: {
|
|
177
177
|
"x-api-key": apiKey,
|
|
178
178
|
"anthropic-version": "2023-06-01",
|
|
179
179
|
"Authorization": `Bearer ${apiKey}`
|
|
180
180
|
},
|
|
181
181
|
});
|
|
182
|
-
isValid =
|
|
182
|
+
isValid = probeRes.ok;
|
|
183
183
|
return res.json({
|
|
184
184
|
valid: isValid,
|
|
185
185
|
error: isValid ? null : "Invalid API key",
|
|
@@ -415,7 +415,7 @@ export async function POST_handler(req, res) {
|
|
|
415
415
|
case "commandcode": {
|
|
416
416
|
const cfg = PROVIDERS.commandcode;
|
|
417
417
|
const model = getDefaultModel("commandcode");
|
|
418
|
-
const payload =
|
|
418
|
+
const payload = openaiToCommandCodeRequest(model, {
|
|
419
419
|
messages: [{ role: "user", content: "ping" }],
|
|
420
420
|
max_tokens: 1,
|
|
421
421
|
stream: false,
|