const OLLAMA_URL = process.env.OLLAMA_URL ?? "http://localhost:11434";
const EMBED_MODEL = process.env.EMBED_MODEL ?? "nomic-embed-text";
export async function computeEmbedding(text) {
    if (!text.trim())
        return [];
    try {
        const res = await fetch(`${OLLAMA_URL}/api/embed`, {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify({ model: EMBED_MODEL, input: text }),
        });
        if (!res.ok) {
            console.error(`[email-fetch] embedding: Ollama returned ${res.status} (${OLLAMA_URL}/api/embed)`);
            return [];
        }
        const data = (await res.json());
        return data.embeddings[0] ?? [];
    }
    catch (err) {
        console.error(`[email-fetch] embedding: Ollama unreachable — ${err instanceof Error ? err.message : err} (${OLLAMA_URL}/api/embed)`);
        return [];
    }
}
//# sourceMappingURL=embedding.js.map