filter out models that don't have a valid id (#4920)

3668e95d9513f7732d52201210601896ddadba43

Ben <44178664+cxmplex@users.noreply.github.com>

Signed
1 files changed, +15 -13Ignore whitespace
src/endpoints/backends/chat-completions.js+15 -13
@@ -1842,19 +1842,21 @@ router.post('/status', async function (request, statusResponse) {
18421842 }
18431843
18441844 if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.CHUTES && Array.isArray(data?.data)) {
18451845 data.data = data.data.map(model => {
1846- if (model.pricing?.prompt !== undefined && model.pricing?.completion !== undefined) {
1846+ .filter(model => model?.id)
1847- return {
1847+ .map(model => {
1848- ...model,
1848+ if (model.pricing?.prompt !== undefined && model.pricing?.completion !== undefined) {
18491849 pricing:return {
18501850 ...model.pricing,
1851- input: model.pricing.prompt,
1851+ pricing: {
1852- output: model.pricing.completion,
1852+ ...model.pricing,
1853- },
1853+ input: model.pricing.prompt,
1854- };
1854+ output: model.pricing.completion,
1855- }
1855+ },
1856- return model;
1856+ };
1857- });
1857+ }
1858+ return model;
1859+ });
18581860 }
18591861
18601862 statusResponse.send(data);