feat: add bounded connection network diagnostics
This commit is contained in:
+8
-1
@@ -187,6 +187,13 @@ return async (request, response) => {
|
||||
const hub = provider.modelHub(store);
|
||||
const importer = () => hub.importer ??= new ConfigImporter(hub);
|
||||
if (method === 'GET' && route === '/api/model-center') return json(response, hub.view());
|
||||
if (method === 'GET' && route === '/api/model-center/network-diagnostics') return json(response, hub.networkDiagnostics().view());
|
||||
const networkStop = route.match(/^\/api\/model-center\/network-diagnostics\/([a-f0-9-]{36})\/stop$/i);
|
||||
if (method === 'POST' && networkStop) return json(response, await hub.networkDiagnostics().stop(networkStop[1], await body(request)));
|
||||
if (method === 'POST' && route === '/api/model-center/network-diagnostics') {
|
||||
if (runtime.hasActivity()) throw Object.assign(new Error('请等待当前任务或诊断结束,再开始新的连接诊断。'), { status: 409 });
|
||||
return json(response, hub.networkDiagnostics().start(await body(request)), 201);
|
||||
}
|
||||
if (method === 'GET' && route === '/api/model-center/selection') return json(response, {
|
||||
config: { ...store.config, hasKey: provider.hasKey() }, modelSelection: hub.selectionView(),
|
||||
});
|
||||
@@ -195,7 +202,7 @@ return async (request, response) => {
|
||||
if (method === 'POST') {
|
||||
const input = await body(request);
|
||||
if (route === '/api/model-center/toggle') return json(response, hub.toggle(input.id, input.enabled));
|
||||
if (runtime.hasActivity()) throw Object.assign(new Error('请先停止正在运行的任务,再修改或测试模型配置。'), { status: 409 });
|
||||
if (runtime.hasActivity() || hub.networkChecks?.active.size) throw Object.assign(new Error('请等待正在运行的任务或连接诊断结束,再修改或测试模型配置。'), { status: 409 });
|
||||
if (route === '/api/model-center/runtime-budgets') {
|
||||
store.saveConfig(validateRuntimeBudgets(input));
|
||||
return json(response, { config: { ...store.config, hasKey: provider.hasKey() }, modelSelection: hub.selectionView() });
|
||||
|
||||
Reference in New Issue
Block a user