scrimba
AI Engineering
Open-source AI Models
Download and Run AI Models on Your Computer with Ollama
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Download and Run AI Models on Your Computer with Ollama
AboutCommentsNotes
Download and Run AI Models on Your Computer with Ollama
Expand for more info
index.js
run
preview
console
import ollama from "ollama";
import express from "express";

const app = express();
const port = 3000;

app.get('/', async (req, res) => {
const question = req.query.question;
if (!question) {
res.status(200).send("Ask something via the `?question=` parameter");
} else {
const response = await ollama.chat({
model: 'mistral',
messages: [{ role: 'user', content: question }],
});
res.status(200).send(response.message.content);
}
});

app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});

Console
/index.html
-3:44