Build chatbot with Ollama
2025-10-222 turns2,635 charsgpt-5
Summary
User wants to build a chatbot using Ollama with the Mistral model and a custom system prompt.
Messages
I need a CLIne prompt which will build using the folder next as a starting point and I want to build a chatbot that works with Ollama and mistral-small3.2:latest and I want it to use the prompt01.md as a system prompt
Here’s a polished CLIne-style prompt that will:
✅ Use your **existing folder (`next`)** as the project root
✅ Build a **chatbot** integrated with **Ollama using the model `mistral-small:3.2:latest`**
✅ Use **`prompt01.md` as the system prompt** for every interaction
✅ Be written in the style expected for CLIne (clear instructions to the AI agent to modify files)
---
### ✅ **CLINE Prompt**
```
You are CLIne, an AI coding agent.
Your task is to create a functional chatbot application using the existing folder named `next` as the project root.
Project Requirements:
- Use Next.js (from the `next` folder as the base).
- Integrate a backend API route that communicates with **Ollama locally**.
- Use the model **mistral-small:3.2:latest** when making requests to Ollama.
- Read the file `prompt01.md` at the project root and load its content as the **system prompt** for the chatbot.
- The chatbot should send user messages and the system prompt to Ollama in the request body.
- The response from Ollama should be streamed back to the frontend.
Tasks to perform:
1. Verify project structure inside the `next/` folder.
2. Create or update:
- `pages/api/chat.ts` (or `/app/api/chat/route.ts` if using App Router)
- A frontend chat component at `components/Chat.tsx`
- Update `pages/index.tsx` or `app/page.tsx` to display the chat.
3. In `pages/api/chat.ts`:
- Import `fs` and read `prompt01.md`.
- Send system prompt + user message to Ollama using a POST request:
```
POST http://localhost:11434/api/chat
{
"model": "mistral-small:3.2:latest",
"messages": [
{ "role": "system", "content": "<content of prompt01.md>" },
{ "role": "user", "content": userMessage }
],
"stream": true
}
```
- Stream the response to the client.
4. Build a minimal chat UI with:
- A scrolling chat history window
- A textarea input + send button
- Handle streaming responses
Development Rules:
- Do not remove existing project settings unless required.
- Always comment where major changes are made.
- Ask me if a file is missing or unclear before generating assumptions.
After completing setup, reply with: **"✅ Chatbot setup complete."**
```
---
### ⚡ **Want me to generate the actual files too (API route + React component)?**
I can immediately start scaffolding them for you.
Just say: **"Yes, generate the files"** ✅
gpt-5