import { prisma } from './lib/prisma';
import { getSystemConfig } from './lib/config';
import { getAIProvider } from './lib/ai/factory';

async function run() {
  const config = await getSystemConfig();
  const provider = getAIProvider(config);
  
  const currentMessages = [
    { role: 'user', content: 'hello' },
    { role: 'assistant', content: 'Hi there' },
    { role: 'user', content: 'help me' }
  ];
  
  const systemPrompt = "Tu es l'assistant de Keep Notes.";

  try {
    const aiResponse = await provider.chat(currentMessages, systemPrompt);
    console.log("SUCCESS:", aiResponse.text.substring(0, 100));
  } catch (err: any) {
    console.error("FAILURE:", err.message);
    if (err.cause) console.error("CAUSE:", err.cause);
    if (err.data) console.error("DATA:", err.data);
  }
}
run();
