Elffuss BraidHub

kikocis/continue public

87f75892af56 · 10.3 KiBRawPermalink
1---
2title: "Using Ollama with Continue: A Developer's Guide"
3description: "Complete guide to setting up Ollama with Continue for local AI development. Learn installation, configuration, model selection, performance optimization, and troubleshooting for privacy-focused offline coding assistance"
4---
5
6## What Are the Prerequisites for Using Ollama
7
8Before getting started, ensure your system meets these requirements:
9
10- Operating System: macOS, Linux, or Windows
11- RAM: Minimum 8GB (16GB+ recommended)
12- Storage: At least 10GB free space
13- Continue extension installed
14
15## How to Install Ollama - Step-by-Step
16
17### Step 1: Install Ollama
18
19Choose the installation method for your operating system:
20
21```
22# macOS
23brew install ollama
24
25# Linux
26curl -fsSL https://ollama.ai/install.sh | sh
27
28# Windows
29# Download from ollama.ai
30```
31
32### Step 2: Start Ollama Service
33
34After installation, start the Ollama service:
35
36```bash
37# Check Ollama version - verify it's installed
38ollama --version
39
40# Start Ollama (runs in background)
41ollama serve
42
43# Verify it's running
44curl http://localhost:11434
45# Should return "Ollama is running"
46```
47
48### Step 3: Download Models
49
50<Warning>
51 **Important**: Always use `ollama pull` instead of `ollama run` to download
52 models. The `run` command starts an interactive session which isn't needed for
53 Continue.
54</Warning>
55
56Download models using the exact tag specified:
57
58```bash
59# Pull models with specific tags
60ollama pull deepseek-r1:32b # 32B parameter version
61ollama pull deepseek-r1:latest # Latest/default version
62ollama pull mistral:latest
63ollama pull qwen2.5-coder:1.5b
64
65# List all downloaded models
66ollama list
67```
68
69**Common Model Tags:**
70
71- `:latest` - Default version (used if no tag specified)
72- `:32b`, `:7b`, `:1.5b` - Parameter count versions
73- `:instruct`, `:base` - Model variants
74
75<Note>
76 If a model page shows `deepseek-r1:32b` on Ollama's website, you must pull it
77 with that exact tag. Using just `deepseek-r1` will pull `:latest` which may be
78 a different size.
79</Note>
80
81## How to Configure Ollama with Continue
82
83There are multiple ways to configure Ollama models in Continue:
84
85### Method 1: Using Hub Model Blocks in Local config.yaml
86
87The easiest way is to use [pre-configured model blocks](/reference#local-blocks) from the Continue Hub in your local configuration:
88
89```yaml title="~/.continue/agents/My Local Agent.yaml"
90name: My Local Agent
91version: 0.0.1
92schema: v1
93models:
94 - uses: ollama/deepseek-r1-32b
95 - uses: ollama/qwen2.5-coder-7b
96 - uses: ollama/gpt-oss-20b
97```
98
99<Warning>
100 **Important**: Hub blocks only provide configuration - you still need to pull
101 the model locally. The hub block `ollama/deepseek-r1-32b` configures Continue
102 to use `model: deepseek-r1:32b`, but the actual model must be installed:
103 ```bash
104 # Check what the hub block expects (view on hub.continue.dev)
105 # Then pull that exact model tag locally
106 ollama pull deepseek-r1:32b # Required for ollama/deepseek-r1-32b hub block
107 ```
108 If the model isn't installed, Ollama will return:
109 `404 model "deepseek-r1:32b" not found, try pulling it first`
110</Warning>
111
112### Method 2: Using Autodetect
113
114Continue can automatically detect available Ollama models. You can configure this in your YAML:
115
116```yaml title="~/.continue/config.yaml"
117models:
118 - name: Autodetect
119 provider: ollama
120 model: AUTODETECT
121 roles:
122 - chat
123 - edit
124 - apply
125 - rerank
126 - autocomplete
127```
128
129Or use it through the GUI:
130
1311. Click on the model selector dropdown
1322. Select "Autodetect" option
1333. Continue will scan for available Ollama models
1344. Select your desired model from the detected list
135
136<Note>
137 The Autodetect feature scans your local Ollama installation and lists all
138 available models. When set to `AUTODETECT`, Continue will dynamically populate
139 the model list based on what's installed locally via `ollama list`. This is
140 useful for quickly switching between models without manual configuration. For
141 any roles not covered by the detected models, you may need to manually
142 configure them.
143</Note>
144
145You can update `apiBase` with the IP address of a remote machine serving Ollama.
146
147### Method 3: Manual Configuration
148
149For custom configurations or models not on the hub:
150
151```yaml
152models:
153 - name: DeepSeek R1 32B
154 provider: ollama
155 model: deepseek-r1:32b # Must match exactly what `ollama list` shows
156 apiBase: http://localhost:11434
157 roles:
158 - chat
159 - edit
160 capabilities: # Add if not auto-detected
161 - tool_use
162 - name: Qwen2.5-Coder 1.5B
163 provider: ollama
164 model: qwen2.5-coder:1.5b
165 roles:
166 - autocomplete
167```
168
169### Model Capabilities and Tool Support
170
171Some Ollama models support tools (function calling) which is required for Agent mode. However, not all models that claim tool support work correctly:
172
173#### Checking Tool Support
174
175```yaml
176models:
177 - name: DeepSeek R1
178 provider: ollama
179 model: deepseek-r1:latest
180 capabilities:
181 - tool_use # Add this to enable tools
182```
183
184<Warning>
185 **Known Issue**: Some models like DeepSeek R1 may show "Agent mode is not
186 supported" or "does not support tools" even with capabilities configured. This
187 is a known limitation where the model's actual tool support differs from its
188 advertised capabilities.
189</Warning>
190
191#### If Agent Mode Shows "Not Supported"
192
1931. First, add `capabilities: [tool_use]` to your model config
1942. If you still get errors, the model may not actually support tools despite documentation
1953. Use a different model known to work with tools (e.g., Llama 3.1, Mistral)
196
197See the [Model Capabilities guide](/customize/deep-dives/model-capabilities) for more details.
198
199### How to Configure Advanced Settings
200
201For optimal performance, consider these advanced configuration options:
202
203```yaml
204models:
205 - name: Optimized DeepSeek
206 provider: ollama
207 model: deepseek-r1:32b
208 contextLength: 8192 # Adjust context window (default varies by model)
209 completionOptions:
210 temperature: 0.7 # Controls randomness (0.0-1.0)
211 top_p: 0.9 # Nucleus sampling threshold
212 top_k: 40 # Top-k sampling
213 num_predict: 2048 # Max tokens to generate
214 # Ollama-specific options (set via environment or modelfile)
215 # num_gpu: 35 # Number of GPU layers to offload
216 # num_thread: 8 # CPU threads to use
217```
218
219For GPU acceleration and memory tuning, create an Ollama Modelfile:
220
221```
222# Create custom model with optimizations
223FROM deepseek-r1:32b
224PARAMETER num_gpu 35
225PARAMETER num_thread 8
226PARAMETER num_ctx 4096
227```
228
229## What Are the Best Practices for Ollama
230
231### How to Choose the Right Model
232
233Choose models based on your specific needs (see [recommended models](/customization/models#recommended-models) for more options):
234
2351. **Code Generation**:
236
237 - `qwen2.5-coder:7b` - Excellent for code completion
238 - `codellama:13b` - Strong general coding support
239 - `deepseek-coder:6.7b` - Fast and efficient
240
2412. **Chat & Reasoning**:
242
243 - `llama3.1:8b` - Latest Llama with tool support
244 - `mistral:7b` - Fast and versatile
245 - `deepseek-r1:32b` - Advanced reasoning capabilities
246
2473. **Autocomplete**:
248
249 - `qwen2.5-coder:1.5b` - Lightweight and fast
250 - `starcoder2:3b` - Optimized for code completion
251
2524. **Memory Requirements**:
253 - 1.5B-3B models: ~4GB RAM
254 - 7B models: ~8GB RAM
255 - 13B models: ~16GB RAM
256 - 32B models: ~32GB RAM
257
258### How to Optimize Performance
259
260To get the best performance from Ollama:
261
262- Monitor system resources with `ollama ps` to see memory usage
263- Adjust context window size based on available RAM
264- Use appropriate model sizes for your hardware
265- Enable GPU acceleration when available (NVIDIA CUDA or AMD ROCm)
266- Use `ollama logs` to debug performance issues
267
268## How to Troubleshoot Ollama Issues
269
270### Common Configuration Problems
271
272#### "404 model not found, try pulling it first"
273
274This error occurs when the model isn't installed locally:
275
276**Problem**: Using a hub block or config that references a model not yet pulled
277**Solution**:
278
279```bash
280# Check what models you have
281ollama list
282
283# Pull the exact model version needed
284ollama pull model-name:tag # e.g., deepseek-r1:32b
285```
286
287#### Model Tag Mismatches
288
289**Problem**: `ollama pull deepseek-r1` installs `:latest` but hub block expects `:32b`
290**Solution**: Always pull with the exact tag:
291
292```bash
293# Wrong - pulls :latest
294ollama pull deepseek-r1
295
296# Right - pulls specific version
297ollama pull deepseek-r1:32b
298```
299
300#### "Agent mode is not supported"
301
302**Problem**: Model doesn't support tools/function calling
303**Solutions**:
304
3051. Add `capabilities: [tool_use]` to your model config
3062. If still not working, the model may not actually support tools
3073. Switch to a model with confirmed tool support (Llama 3.1, Mistral)
308
309#### Using Hub Blocks in Local Config
310
311**Problem**: Unclear how to use hub models locally
312**Solution**: Create a local agent file:
313
314```yaml
315# ~/.continue/agents/Local.yaml
316name: Local Agent
317version: 0.0.1
318schema: v1
319models:
320 - uses: ollama/model-name
321```
322
323### How to Fix Connection Problems
324
325- Verify Ollama is running: `curl http://localhost:11434`
326- Check service status: `systemctl status ollama` (Linux)
327- Ensure port 11434 is not blocked by firewall
328- For remote connections, set `OLLAMA_HOST=0.0.0.0:11434`
329
330### How to Resolve Performance Issues
331
332- Insufficient RAM: Use smaller models (7B instead of 32B)
333- Model too large: Check available memory with `ollama ps`
334- GPU issues: Verify CUDA/ROCm installation for GPU acceleration
335- Slow generation: Adjust `num_gpu` layers in model configuration
336- Check system diagnostics: `ollama ps` for active models and memory usage
337
338## What Are Example Workflows with Ollama
339
340### How to Use Ollama for Code Generation
341
342```python
343# Example: Generate a FastAPI endpoint
344from fastapi import FastAPI, HTTPException
345from pydantic import BaseModel
346
347app = FastAPI()
348
349class User(BaseModel):
350 name: str
351 email: str
352 age: int
353
354@app.post("/users/")
355async def create_user(user: User):
356 # Continue will help complete this implementation
357 # Use Cmd+I (Mac) or Ctrl+I (Windows/Linux) to generate code
358 pass
359```
360
361### How to Use Ollama for Code Review
362
363Use Continue with Ollama to:
364
365- Analyze code quality
366- Suggest improvements
367- Identify potential bugs
368- Generate documentation
369
370## Conclusion
371
372Ollama with Continue provides a powerful local development environment for AI-assisted coding. You now have complete control over your AI models, ensuring privacy and enabling offline development workflows.
373
374---
375
376_This guide is based on Ollama v0.11.x and Continue v1.1.x. Please check for updates regularly._