Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ollama Main 源码拆解

基于工作区中的 ollama-main 源码快照,参考 refs/dg-ai-notes 对 Pi-Agent 的拆解方式,按“是什么、怎么做、为什么这样做”的顺序,系统阅读 Ollama 的 Go 运行时。

在线阅读:https://hanqing.github.io/ollama-main-notes/

内容范围

本书重点解释以下主线:

CLI / App
   ↓
Gin HTTP API + OpenAI/Anthropic middleware
   ↓
模型名解析 → Manifest/Blob → Model 元数据
   ↓
Scheduler → runnerRef → llama-server / MLX runner
   ↓
GPU 探测、上下文预算、流式 NDJSON/SSE 响应

另外单独拆解了 agent/ 中的 Agent Loop、工具审批、Skills、工具结果截断与上下文压缩,以及 cloud passthrough 和跨平台 App。

本地预览

需要 Python 3.9+:

python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
mkdocs serve

构建:

mkdocs build --strict

版本说明

文档针对 ollama-main 工作区快照编写。该快照没有携带可用的 Git 提交信息,go.mod 声明 Go 1.26.0,因此正文中的行号是快照证据,源码链接默认指向 Ollama upstream 的 main 分支;若上游继续演进,应以符号名和调用关系为准重新核对。

许可证

文档采用 CC BY-SA 4.0。Ollama 源码和依赖的许可证仍以其各自仓库为准。

About

Ollama main source deep-dive in Chinese, built with MkDocs Material

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors