feat(models): execute Responses and validated streams with capability routing
This commit is contained in:
+1
-11
@@ -176,17 +176,7 @@ return async (request, response) => {
|
||||
if (route === '/api/model-center/import-toggle') return json(response, importer().toggle(input.id, input.enabled));
|
||||
if (route === '/api/model-center/import-sync') return json(response, { results: importer().sync(), center: hub.view() });
|
||||
if (route === '/api/model-center/probe') {
|
||||
const connection = hub.connection(input.id);
|
||||
if (!hub.available({ ...connection, credentialRevision: hub.credential(connection)?.revision ?? 0 })) throw new Error('该连接不可用,请核对凭据、冷却或停用状态。');
|
||||
const config = { ...store.config, mode: 'compatible', modelRouting: { type: 'connection', id: connection.id, revision: connection.revision,
|
||||
strategy: 'round-robin', sticky: false, maxAttempts: 1, queueTimeoutMs: 1000, members: [{ ...connection, credentialRevision: hub.credential(connection)?.revision ?? 0 }] } };
|
||||
const result = await hub.complete(config, { model: connection.model, stream: false, max_tokens: 16, messages: [{ role: 'user', content: 'Reply OK.' }] }, undefined, undefined, null,
|
||||
async (selected, key, payload) => {
|
||||
const value = await provider.request(selected, '/chat/completions', payload, undefined, key, undefined, { attempts: 1 });
|
||||
if (!value.choices?.[0]?.message) throw new Error('模型响应缺少完整message。');
|
||||
return value;
|
||||
});
|
||||
return json(response, { ok: true, usage: result.usage ?? null, center: hub.view() });
|
||||
return json(response, await hub.probe(input.id, input.scope ?? 'text'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user