Fix ooba model name displaying as turbo

This commit is contained in:
Cohee 2023-11-09 19:27:19 +02:00
parent 0a409c8c54
commit 3780321ae6
1 changed files with 21 additions and 1 deletions

View File

@ -506,6 +506,7 @@ app.post("/api/textgenerationwebui/status", jsonParser, async function (request,
setAdditionalHeaders(request, args, baseUrl); setAdditionalHeaders(request, args, baseUrl);
let url = baseUrl; let url = baseUrl;
let result = '';
if (request.body.legacy_api) { if (request.body.legacy_api) {
url += "/v1/model"; url += "/v1/model";
@ -542,7 +543,26 @@ app.post("/api/textgenerationwebui/status", jsonParser, async function (request,
const modelIds = data.data.map(x => x.id); const modelIds = data.data.map(x => x.id);
console.log('Models available:', modelIds); console.log('Models available:', modelIds);
const result = modelIds[0] ?? 'Valid'; // Set result to the first model ID
result = modelIds[0] || 'Valid';
if (request.body.use_ooba) {
try {
const modelInfoUrl = baseUrl + '/v1/internal/model/info';
const modelInfoReply = await fetch(modelInfoUrl, args);
if (modelInfoReply.ok) {
const modelInfo = await modelInfoReply.json();
console.log('Ooba model info:', modelInfo);
const modelName = modelInfo?.model_name;
result = modelName || result;
}
} catch (error) {
console.error('Failed to get Ooba model info:', error);
}
}
return response.send({ result, data: data.data }); return response.send({ result, data: data.data });
} catch (error) { } catch (error) {
console.error(error); console.error(error);