forked from github/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatModelPicker.swift
More file actions
60 lines (55 loc) · 1.85 KB
/
Copy pathChatModelPicker.swift
File metadata and controls
60 lines (55 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import Persist
import SharedUIComponents
import SwiftUI
struct ChatModelPicker: View {
let selectedModel: LLMModel?
let copilotModels: [LLMModel]
let byokModels: [LLMModel]
let isBYOKFFEnabled: Bool
let currentCache: ScopeCache
@StateObject private var fontScaleManager = FontScaleManager.shared
@State private var currentEffort: String?
private var fontScale: Double {
fontScaleManager.currentScale
}
var body: some View {
ModelPickerButton(
selectedModel: selectedModel,
copilotModels: copilotModels,
byokModels: byokModels,
isBYOKFFEnabled: isBYOKFFEnabled,
currentCache: currentCache,
fontScale: fontScale,
currentEffort: currentEffort
)
.fixedSize(horizontal: false, vertical: true)
.onAppear {
currentEffort = computeEffort(for: selectedModel)
}
.onChange(of: selectedModel) { model in
currentEffort = computeEffort(for: model)
}
.onReceive(
NotificationCenter.default.publisher(
for: .gitHubCopilotModelsDidChange
)
) { _ in
currentEffort = computeEffort(for: selectedModel)
}
.onReceive(
NotificationCenter.default.publisher(
for: .gitHubCopilotSelectedReasoningEffortDidChange
)
) { _ in
currentEffort = computeEffort(for: selectedModel)
}
}
private func computeEffort(for model: LLMModel?) -> String? {
guard let model,
model.supportsReasoningEffortLevel,
!model.isAutoModel else { return nil }
let effort = AppState.shared.effectiveReasoningEffort(for: model)
guard let e = effort, e.lowercased() != "none" else { return nil }
return e
}
}