// Nachgebauter OpenAI-kompatibler KI-Dienst (wie Ollama) für die Tests – antwortet sofort und vorhersagbar import http from 'node:http'; export function startFakeAi(port) { const server = http.createServer((req, res) => { let body = ''; req.on('data', (c) => (body += c)); req.on('end', () => { if (req.url === '/v1/models') { res.writeHead(200, { 'content-type': 'application/json' }); res.end(JSON.stringify({ object: 'list', data: [{ id: 'test-modell', object: 'model' }] })); return; } if (req.url !== '/v1/chat/completions') { res.writeHead(404).end(); return; } const [system, user] = JSON.parse(body).messages.map((m) => m.content); let text = '
Das ist ein Text in Leichter Sprache.
Er hat kurze Sätze.
'; if (system.startsWith('You translate')) { const lang = system.match(/into (\w+)/)?.[1]; const title = user.match(/Translated into ${lang}.