mana-swift-llm/Sources/ManaLLM/NoOpBackend.swift
till fd376bbdce L-1+L-2+L-3: mana-swift-llm Initial — lift aus memoro-native
Neues Swift-Package mit lokalen LLM-Backends für alle nativen mana-
e.V.-Apps. Lift der bisher Memoro-eigenen Files in
`memoro-native/Sources/Core/AI/` plus zwei neue Layer:
ManaSharedModels (App-Group-Container-Helper) und ManaLLM-Facade.

Library-Products:
- ManaLLM — Backend-Abstraktion (FoundationModels, Gemma 4 E2B/E4B,
  NoOp), Router mit Priority-Liste, High-Level-Facade
  `ManaLLM.summarize/generate/classify` mit fast/creative/deep Level.
- ManaLLMShared — App-Group `group.ev.mana.models` Container,
  HF_HUB_CACHE-Setup, Legacy-Fallback wenn Group fehlt.

Lift-Anpassungen ggü. memoro:
- public-Marker auf protocol + types + actors
- generischer `generate(prompt:instructions:maxTokens:)` zu
  LLMBackend-Protocol hinzu; `summarize` als Default-Impl auf
  Basis von generate
- AppleFMBackend behält optimierten @Generable-Summary-Path
- GemmaBackend nutzt ManaSharedModels.effectiveCacheURL() statt
  eigenen Application-Support-Pfad; allowsCellular kommt jetzt
  als Initializer-Param statt App-Settings-Lookup
- LLMRouter: Memoro-spezifische User-Pref-Store-Logic durch
  Priority-Liste-API ersetzt
- LLMLog-Subsystem `ev.mana.llm` statt App-eigenes `Log.ai`

Build: `swift build` clean (76s, MLX-Toolchain-Resolution beim
ersten Lauf). 4/4 Parser-Tests grün.

Doku: ../mana/docs/MANA_LLM.md (Plattform-SOT), CLAUDE.md
(Konventionen + Lift-Tabelle).

Folge: L-4 Memoro auf ManaLLM umstellen, L-5 pageta-Pilot.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 22:55:32 +02:00

37 lines
962 B
Swift

import Foundation
/// Fallback-Backend ohne LLM. Returnt immer `nil` aus `generate`
/// und `summarize` der Aufrufer (`LLMRouter` oder Apps direkt)
/// fängt das und nutzt eine eigene Heuristik (erste Sätze,
/// statisches Template, ...).
///
/// Existiert als 1st-class-Type, damit Settings einen deterministischen
/// Picker-Eintrag haben können und das Routing nicht in Optional-
/// Logik versinkt.
public actor NoOpBackend: LLMBackend {
public let identifier: LLMBackendID = .noOp
public init() {}
public func availability() async -> LLMAvailability {
.available
}
public func prepare(
onProgress: @Sendable @escaping (LLMPrepareUpdate) -> Void
) async throws {
onProgress(LLMPrepareUpdate(stage: .ready, fractionCompleted: 1.0))
}
public func generate(
prompt _: String,
instructions _: String?,
maxTokens _: Int
) async -> String? {
nil
}
public func summarize(transcript _: String) async -> LLMSummary? {
nil
}
}