const OLLAMA_URL = process.env.OLLAMA_URL ?? "http://localhost:11434";
const EMBED_MODEL = process.env.EMBED_MODEL ?? "nomic-embed-text";
export async function embed(text) {
    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) {
        const body = await res.text();
        throw new Error(`Ollama embedding failed (${res.status}): ${body}`);
    }
    const data = (await res.json());
    if (!Array.isArray(data.embeddings) || data.embeddings.length === 0) {
        throw new Error("Ollama returned invalid embedding response — expected non-empty embeddings array");
    }
    return data.embeddings[0];
}
//# sourceMappingURL=embeddings.js.map