mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-18 13:55:57 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4de4d6b7bc |
No files matched your search
@@ -85,6 +85,7 @@ export const enAiMessages: Messages = {
|
||||
'ai.providers.test.ok': 'Connected ({latency} ms)',
|
||||
'ai.providers.test.warn': 'Reached endpoint, but response looks incomplete ({latency} ms)',
|
||||
'ai.providers.test.warnSlow': 'Connected, but slow ({latency} ms)',
|
||||
'ai.providers.test.modelListUnavailable': 'Model list unavailable (HTTP 404). Enter a model ID manually, then try a chat to verify the connection.',
|
||||
'ai.providers.test.error': 'Failed ({detail})',
|
||||
'ai.providers.test.missingBaseUrl': 'Enter a Base URL first',
|
||||
'ai.providers.test.missingApiKey': 'Enter an API key first',
|
||||
|
||||
@@ -76,6 +76,7 @@ export const esAiMessages: Messages = {
|
||||
'ai.providers.test.ok': 'Conectado ({latency} ms)',
|
||||
'ai.providers.test.warn': 'Se alcanzó el endpoint, pero la respuesta parece incompleta ({latency} ms)',
|
||||
'ai.providers.test.warnSlow': 'Conectado, pero lento ({latency} ms)',
|
||||
'ai.providers.test.modelListUnavailable': 'Lista de modelos no disponible (HTTP 404). Introduce el ID de un modelo y prueba un chat para verificar la conexión.',
|
||||
'ai.providers.test.error': 'Falló ({detail})',
|
||||
'ai.providers.test.missingBaseUrl': 'Primero ingresa una URL base',
|
||||
'ai.providers.test.missingApiKey': 'Primero ingresa una clave de API',
|
||||
|
||||
@@ -57,6 +57,7 @@ export const ruAiMessages: Messages = {
|
||||
'ai.providers.test.ok': 'Подключено ({latency} ms)',
|
||||
'ai.providers.test.warn': 'Эндпоинт доступен, но ответ выглядит неполным ({latency} ms)',
|
||||
'ai.providers.test.warnSlow': 'Подключено, но медленно ({latency} ms)',
|
||||
'ai.providers.test.modelListUnavailable': 'Список моделей недоступен (HTTP 404). Введите ID модели вручную и отправьте сообщение в чате, чтобы проверить подключение.',
|
||||
'ai.providers.test.error': 'Ошибка ({detail})',
|
||||
'ai.providers.test.missingBaseUrl': 'Сначала укажите Base URL',
|
||||
'ai.providers.test.missingApiKey': 'Сначала укажите API-ключ',
|
||||
|
||||
@@ -85,6 +85,7 @@ export const zhCNAiMessages: Messages = {
|
||||
'ai.providers.test.ok': '连接正常({latency} ms)',
|
||||
'ai.providers.test.warn': '已连通,但响应不完整({latency} ms)',
|
||||
'ai.providers.test.warnSlow': '已连通,但较慢({latency} ms)',
|
||||
'ai.providers.test.modelListUnavailable': '无法获取模型列表(HTTP 404)。请手动填写模型 ID,再发送一条消息验证连接。',
|
||||
'ai.providers.test.error': '检测失败({detail})',
|
||||
'ai.providers.test.missingBaseUrl': '请先填写 Base URL',
|
||||
'ai.providers.test.missingApiKey': '请先填写 API Key',
|
||||
|
||||
@@ -85,6 +85,7 @@ export const zhTWAiMessages: Messages = {
|
||||
'ai.providers.test.ok': '連線正常({latency} ms)',
|
||||
'ai.providers.test.warn': '已連通,但回應不完整({latency} ms)',
|
||||
'ai.providers.test.warnSlow': '已連通,但較慢({latency} ms)',
|
||||
'ai.providers.test.modelListUnavailable': '無法取得模型清單(HTTP 404)。請手動輸入模型 ID,再傳送一則訊息驗證連線。',
|
||||
'ai.providers.test.error': '檢測失敗({detail})',
|
||||
'ai.providers.test.missingBaseUrl': '請先填寫 Base URL',
|
||||
'ai.providers.test.missingApiKey': '請先填寫 API Key',
|
||||
|
||||
@@ -339,9 +339,11 @@ export const ProviderConfigForm: React.FC<{
|
||||
message: t("ai.providers.test.ok", { latency }),
|
||||
});
|
||||
} else if (classified.health === "warn") {
|
||||
const warnKey = classified.modelCount === 0 || classified.error
|
||||
? "ai.providers.test.warn"
|
||||
: "ai.providers.test.warnSlow";
|
||||
const warnKey = classified.notice === "model-list-unavailable"
|
||||
? "ai.providers.test.modelListUnavailable"
|
||||
: classified.modelCount === 0 || classified.error
|
||||
? "ai.providers.test.warn"
|
||||
: "ai.providers.test.warnSlow";
|
||||
setProbeResult({
|
||||
health: "warn",
|
||||
message: t(warnKey, { latency }),
|
||||
|
||||
@@ -208,3 +208,43 @@ test("probeProviderConnection does not double /v1 for Anthropic AI SDK style bas
|
||||
assert.deepEqual(calls, ["https://gateway.example/v1/models"]);
|
||||
assert.equal(run.ok, true);
|
||||
});
|
||||
|
||||
test("Volcengine Agent Plan OpenAI Detect distinguishes a missing catalog from a failed chat request", async () => {
|
||||
const calls: Array<{ url: string; method?: string }> = [];
|
||||
const run = (baseURL: string, status: number, style: "openai" | "anthropic" = "openai") =>
|
||||
probeProviderConnection({
|
||||
bridge: {
|
||||
aiFetch: async (url, method) => {
|
||||
calls.push({ url, method });
|
||||
return { ok: false, status, data: "" };
|
||||
},
|
||||
},
|
||||
baseURL,
|
||||
apiKey: "fixture-key",
|
||||
providerId: "custom",
|
||||
style,
|
||||
now: () => 0,
|
||||
});
|
||||
|
||||
const base = "https://ark.cn-beijing.volces.com/api/plan/v3";
|
||||
const missingCatalog = await run(base + "/", 404);
|
||||
assert.deepEqual(missingCatalog, {
|
||||
ok: true,
|
||||
classification: { health: "warn", statusCode: 404, latencyMs: 0, notice: "model-list-unavailable" },
|
||||
});
|
||||
assert.deepEqual(calls, [{ url: base + "/models", method: "GET" }]);
|
||||
for (const [url, status, style] of [
|
||||
[base, 401, "openai"],
|
||||
[base, 503, "openai"],
|
||||
[base, 404, "anthropic"],
|
||||
[base + "/typo", 404, "openai"],
|
||||
["https://ark.cn-beijing.volces.com/api/v3", 404, "openai"],
|
||||
["https://ark.cn-beijing.volces.com.evil.example/api/plan/v3", 404, "openai"],
|
||||
["https://example.test/api/plan/v3", 404, "openai"],
|
||||
] as const) {
|
||||
const result = await run(url, status, style);
|
||||
assert.ok(result.ok);
|
||||
assert.equal(result.classification.health, "error", `${url}: ${status} (${style})`);
|
||||
assert.equal(result.classification.notice, undefined);
|
||||
}
|
||||
});
|
||||
@@ -15,6 +15,7 @@ export type ProviderProbeClassification = {
|
||||
latencyMs: number;
|
||||
statusCode: number;
|
||||
modelCount?: number;
|
||||
notice?: "model-list-unavailable";
|
||||
error?: string;
|
||||
};
|
||||
|
||||
@@ -61,6 +62,17 @@ export function buildProviderProbeUrl(baseURL: string, endpoint: string): string
|
||||
return `${base}${path.startsWith("/") ? path : `/${path}`}`;
|
||||
}
|
||||
|
||||
function isVolcengineAgentPlanCatalog(url: string): boolean {
|
||||
try {
|
||||
const target = new URL(url);
|
||||
return target.origin === "https://ark.cn-beijing.volces.com"
|
||||
&& !target.username && !target.password && !target.search && !target.hash
|
||||
&& target.pathname === "/api/plan/v3/models";
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function validateProviderProbeInputs(input: {
|
||||
baseURL: string;
|
||||
apiKey: string;
|
||||
@@ -193,12 +205,21 @@ export async function probeProviderConnection(input: {
|
||||
undefined,
|
||||
input.skipTLSVerify,
|
||||
);
|
||||
const latencyMs = Math.max(0, now() - startedAt);
|
||||
// The Agent Plan chat endpoint can work even when this catalog returns 404.
|
||||
// Do not reinterpret generic 404s, other protocols, or authentication errors.
|
||||
if (input.style === "openai" && !result.ok && result.status === 404 && isVolcengineAgentPlanCatalog(url)) {
|
||||
return {
|
||||
ok: true,
|
||||
classification: { health: "warn", statusCode: 404, latencyMs, notice: "model-list-unavailable" },
|
||||
};
|
||||
}
|
||||
return {
|
||||
ok: true,
|
||||
classification: classifyProviderProbeResponse({
|
||||
ok: result.ok,
|
||||
status: result.status ?? (result.ok ? 200 : 0),
|
||||
latencyMs: Math.max(0, now() - startedAt),
|
||||
latencyMs,
|
||||
data: result.data,
|
||||
error: result.error,
|
||||
slowThresholdMs: input.slowThresholdMs,
|
||||
|
||||
Reference in new issue
Block a user