This commit is contained in:
seb
2026-10-05 11:29:41 +02:00
parent 25266cfcec
commit 4a08e7f20b
6 changed files with 72 additions and 11 deletions

View File

@@ -1,4 +1,9 @@
import * as db from '../../db/modelconversation.js';
import env from '../../config/env.js';
// Model ids that are known to return empty responses from OpenRouter. Requests naming one of
// these are transparently rerouted to `env.defaultModel` instead of failing at generation time.
const RETIRED_MODELS = new Set(['stealth/space-bunny-alpha']);
import { emit } from '../sse.js';
import { getOrCreateManager, removeManager } from '../../services/conversationManager.js';
@@ -145,8 +150,16 @@ export function register(app, basePath = '') {
const { provider, model } = req.body ?? {};
// Clients may still send the retired `stealth/space-bunny-alpha` id, which now returns
// empty responses from the provider. Map it onto the configured default rather than
// ignoring the client's choice entirely, so an explicit model selection still works.
const requestedModel = typeof model === 'string' ? model.trim() : '';
const effectiveModel = RETIRED_MODELS.has(requestedModel) || !requestedModel
? env.defaultModel
: requestedModel;
try {
const conversation = await db.create(req.user.id, { provider, model });
const conversation = await db.create(req.user.id, { provider, model: effectiveModel });
emit('modelconversation', { companyId: selected.companyId });
res.status(201).json({ conversation });
} catch (error) {