feat(ai): add AIRuntime actor skeleton + TokenChunk
按 W2 plan Task 5 落地推理串行化骨架:
- TokenChunk: Sendable struct (text + decodeRate tok/s)
- AIRuntime: actor 单例
- Status: notReady / loading / ready / error(msg)
- prepare() async throws: 幂等加载,失败回滚 status
- generate(prompt:maxTokens:) -> AsyncThrowingStream: 流式输出
跨 actor 边界用 snapshot 模式捕获 self.status/llmSession
- lastDecodeRate: 给 UI 顶部条 / Live Activity 取
- AIRuntimeError: LocalizedError, 三种 case
WIP: Build will fail until Task 6 lands LLMSession (intentional).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
6
体己/AI/TokenChunk.swift
Normal file
6
体己/AI/TokenChunk.swift
Normal file
@@ -0,0 +1,6 @@
|
||||
import Foundation
|
||||
|
||||
struct TokenChunk: Sendable {
|
||||
let text: String
|
||||
let decodeRate: Double // tokens / second, 估算值
|
||||
}
|
||||
Reference in New Issue
Block a user