@@ -5,17 +5,30 @@ public final class SegmentsManager {
55 public init (
66 kanaKanjiConverter: KanaKanjiConverter ,
77 applicationDirectoryURL: URL ,
8- containerURL: URL ?
8+ containerURL: URL ? ,
9+ context: Context = Context ( )
910 ) {
1011 self . kanaKanjiConverter = kanaKanjiConverter
1112 self . applicationDirectoryURL = applicationDirectoryURL
1213 self . containerURL = containerURL
14+ self . context = context
15+ }
16+
17+ /// テストなどの設定注入のための型。外部には設定を露出させない。
18+ public struct Context {
19+ public init ( ) { }
20+ init ( useZenzai: Bool ) {
21+ self . useZenzai = useZenzai
22+ }
23+
24+ var useZenzai : Bool = true
1325 }
1426
1527 public weak var delegate : ( any SegmentManagerDelegate ) ?
1628 private var kanaKanjiConverter : KanaKanjiConverter
1729 private let applicationDirectoryURL : URL
1830 private let containerURL : URL ?
31+ private let context : Context
1932
2033 private var composingText : ComposingText = ComposingText ( )
2134
@@ -121,7 +134,10 @@ public final class SegmentsManager {
121134 }
122135
123136 private func zenzaiMode( leftSideContext: String ? , requestRichCandidates: Bool ) -> ConvertRequestOptions . ZenzaiMode {
124- . on(
137+ if !self . context. useZenzai {
138+ return . off
139+ }
140+ return . on(
125141 weight: Bundle . main. bundleURL. appendingPathComponent ( " Contents/Resources/ggml-model-Q5_K_M.gguf " , isDirectory: false ) ,
126142 inferenceLimit: Config . ZenzaiInferenceLimit ( ) . value,
127143 requestRichCandidates: requestRichCandidates,
0 commit comments