Skip to content

Ollama

Cline

一款在本地运行大语言模型的工具,简化模型部署和使用。

Official Site
01

概述

Ollama 是一款开源的本地 LLM 运行工具,让在个人电脑上运行大语言模型变得简单。其核心理念是简化模型部署:一条命令即可下载并运行模型。Ollama 支持 Llama 3、Mistral、Phi-3、Gemma、Qwen 等开源模型。它提供 REST API 和命令行界面,便于集成到应用中。Ollama 自动处理 GPU 检测、内存管理、模型优化等复杂任务。支持 macOS、Linux 和 Windows。

Core features: open source, autonomous multi-file editing, terminal + browser access, model-agnostic, MCP integration.

02

安装

Ollama 支持 macOS、Linux 和 Windows。安装过程简单:下载安装包并运行。安装后环境会自动配置,无需额外设置。

bash
# Install from the VS Code Marketplace
# 1. Open VS Code -> Extensions (Cmd/Ctrl+Shift+X)
# 2. Search for "Cline" -> install the official extension
# 3. Reload VS Code
# 4. Click the Cline icon in the sidebar
# 5. Pick an API provider and paste your API key

# Or install via command line
code --install-extension saoudrizwan.claude-dev

# Prerequisites
node --version    # Node.js recommended (for MCP servers / browser tool)
# An API key from Anthropic / OpenAI / OpenRouter / etc.

The extension ID is saoudrizwan.claude-dev (Cline was previously named Claude Dev).

03

运行模型

运行模型非常简单,使用 ollama run 命令。首次运行会自动下载模型。下载后模型存储在本地,后续运行无需重新下载。支持交互式对话和一次性查询。

bash
# Open the Cline panel
# Click the Cline icon in the VS Code sidebar
# Or: Cmd/Ctrl+Shift+P -> "Cline: Open In New Tab"

# Example task
"Add input validation to the login form and update the tests"

# Cline will then:
# 1. Read the relevant files
# 2. Propose file edits -> you Approve / Reject each one
# 3. Propose terminal commands (e.g. npm test) -> you Approve / Reject
# 4. Iterate until the task is done

# Checkpoints: use the Checkpoints panel to rewind to a prior state

Approve each action the first few times to understand Cline's behavior; switch on auto-approve once you trust the workflow.

04

模型库

Ollama 提供丰富的模型库,包括 Llama、Mistral、Phi、Gemma、Qwen、DeepSeek 等。模型有不同大小(7B、13B、70B 等),可根据硬件选择。还提供嵌入模型、视觉模型等。

bash
# 1. Add an MCP server (e.g. filesystem) via Settings -> MCP Servers
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path"]
    }
  }
}

# 2. Enable the browser tool
# Settings -> Enable Browser Tool (requires Puppeteer deps)

# 3. Auto-approve rules (Settings -> Auto-Approve)
# Examples: git status, npm test, npm run lint

# 4. Custom modes (Settings -> Modes)
# e.g. a "Review" mode that only reads files and comments

MCP servers run locally, so tool data stays on your machine—ideal for privacy-sensitive workflows.

05

自定义模型

Ollama 支持自定义模型。通过 Modelfile 定义模型,可以导入 GGUF 格式模型、设置参数、自定义系统提示词等。支持从 Hugging Face 导入模型。

bash
# .clinerules (project root) - Cline reads this on every task
# Project conventions
- Use TypeScript strict mode
- Prefer functional style; avoid 'any'
- All public functions need JSDoc
- Run 'npm test' before finishing

# Switch the API provider / model in settings
# Cline panel -> Settings (gear icon) -> API Provider -> pick one:
#   Anthropic / OpenAI / OpenRouter / Bedrock / Vertex / Ollama / LM Studio

# Context management
# - Open files are included automatically
# - Use @filename to add a file to context
# - Use @folder to include a whole directory

Pin a cheaper model for auto-approve loops and a stronger model for planning to control costs.

06

API

Ollama 默认在 11434 端口提供 REST API。API 兼容 OpenAI 格式,可轻松集成到应用中。支持生成、聊天、嵌入等端点。提供流式响应。

bash
# Cost control tips
# - Use OpenRouter to route to cheaper models for simple tasks
# - Use Ollama for fully free, offline operation
ollama pull deepseek-coder
# Then in Cline: API Provider -> Ollama

# Privacy: choose "Ollama" or "LM Studio" as the provider
# No code is sent to any cloud service

# Supported providers (Settings -> API Provider):
# Anthropic, OpenAI, OpenRouter, AWS Bedrock, Google Vertex,
# Gemini, Ollama, LM Studio

Cline is open source (github.com/cline/cline), so you can audit the code path and self-host the extension.

Ready to try Ollama?

Visit the official site for the latest version and full documentation.

Visit Ollama