Files
project-lyra/core/relay-backup/test-llm.js

40 lines
1.6 KiB
JavaScript

// test-llm.js
import path from "path";
import { fileURLToPath } from "url";
import dotenv from "dotenv";
import { callSpeechLLM } from "./lib/llm.js";
// ───────────────────────────────────────────────
// 🔧 Load environment
// ───────────────────────────────────────────────
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const envPath = path.join(__dirname, "../.env");
dotenv.config({ path: envPath });
console.log("🔧 Using .env from:", envPath);
console.log("🔧 LLM_FORCE_BACKEND =", process.env.LLM_FORCE_BACKEND);
console.log("🔧 LLM_PRIMARY_URL =", process.env.LLM_PRIMARY_URL);
// ───────────────────────────────────────────────
// 🧪 Run a simple test message
// ───────────────────────────────────────────────
async function testLLM() {
console.log("🧪 Testing LLM helper...");
const messages = [
{ role: "user", content: "Say hello in five words or less." }
];
try {
const { reply, backend } = await callSpeechLLM(messages);
console.log(`✅ Reply: ${reply || "[no reply]"}`);
console.log(`Backend used: ${backend || "[unknown]"}`);
} catch (err) {
console.error("💥 Test failed:", err.message);
}
}
testLLM();