test_ha.cjs 939 B

123456789101112131415161718192021222324
  1. const { callLLMWithMessages } = require('/data/ai/audio/server/dist/services/llm/index');
  2. const messages = [
  3. { role: 'system', content: 'You are a test.' },
  4. { role: 'user', content: 'Reply with the single word: HA_OK' },
  5. ];
  6. (async () => {
  7. const t0 = Date.now();
  8. try {
  9. const r = await callLLMWithMessages(messages, 'fake-model-xxx-no-such-model', 30);
  10. console.log('UNEXPECTED_OK', r.substring(0, 80));
  11. } catch (e) {
  12. console.log('ERROR_NAME:', e.name);
  13. console.log('ERROR_MSG:', (e.message || '').substring(0, 400));
  14. if (e.attempts) {
  15. console.log('PROVIDERS_TRIED:', e.attempts.length);
  16. for (const a of e.attempts) {
  17. console.log(' ', a.provider + '/' + a.model, '|', a.errorType, '|', a.attempts, '次 |', (a.error || '').substring(0, 80));
  18. }
  19. } else {
  20. console.log('NO_ATTEMPTS_FIELD (说明没走 HA 调度)');
  21. }
  22. }
  23. console.log('ELAPSED_MS:', Date.now() - t0);
  24. })();