2024-04-18

Ollama - JS raw API call

_ask = async (model, prompt) => {

    try {

        const response = await fetch("http://localhost:11434/api/generate", {

            method: "POST",

            headers: {"Content-Type": "application/json"},

            body: JSON.stringify({ model, prompt, stream: false })

        });

        return await response.json();

    } catch (err) {

        console.error('error:', err);

    }

};