运行时流程图
服务启动
sequenceDiagram
participant M as main
participant CLI as cmd.NewCLI
participant S as server.Serve
participant SC as Scheduler
participant G as discover.GPUDevices
participant H as http.Server
M->>CLI: ExecuteContext
CLI->>S: RunServer
S->>S: fixBlobs + prune
S->>S: GenerateRoutes
S->>SC: InitScheduler / Run
S->>G: GPUDevices
S->>S: choose default context
S->>H: Serve(listener)
Chat 请求
flowchart LR
A[JSON request] --> B[bind + validate]
B --> C[parse model ref]
C --> D[GetModel]
D --> E[merge options]
E --> F[Scheduler.getRunner]
F --> G[prompt/template]
G --> H[runner Chat/Completion]
H --> I[thinking/tool/structured parser]
I --> J[NDJSON response]
Agent 请求
flowchart TB
U[user message] --> M[Session.Run]
M --> L[model step]
L --> Q{tool calls?}
Q -- no --> F[finish]
Q -- yes --> A[approval]
A --> X[execute batch]
X --> T[append tool results]
T --> C{over budget?}
C -- no --> L
C -- yes --> S[compact history]
S --> L
模型拉取
flowchart TB
R[model name] --> P[remote manifest]
P --> D{local blob exists?}
D -- yes --> N[next layer]
D -- no --> DL[download chunks]
DL --> V[verify digest/size]
V --> N
N --> Z[write manifest]
Z --> READY[GetModel can resolve]