Skip to content

Commit 4897333

Browse files
authored
bug fixes (#149)
# bug fixes ## ⚙️ Release Notes - fixed: the UserStudyChatView would not properly update its UI - new: added a `--disableFirebase` feature flag - fixed: the app would unnecessarily load the Fog and Local LLM components when launching in user study mode ## 📚 Documentation n/a ## ✅ Testing n/a ### Code of Conduct & Contributing Guidelines By creating and submitting this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).
1 parent 3755963 commit 4897333

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

LLMonFHIR.xcodeproj/xcshareddata/xcschemes/LLMonFHIR.xcscheme

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@
8181
argument = "--useFirebaseEmulator"
8282
isEnabled = "NO">
8383
</CommandLineArgument>
84+
<CommandLineArgument
85+
argument = "--disableFirebase"
86+
isEnabled = "NO">
87+
</CommandLineArgument>
8488
<CommandLineArgument
8589
argument = "--showOnboarding"
8690
isEnabled = "NO">

LLMonFHIR/FHIRInterpretation/UserStudy/UserStudyChatView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct UserStudyChatView: View {
1919

2020
@LocalPreference(.enableTextToSpeech) private var enableTextToSpeechPrefValue
2121

22-
private let model: UserStudyChatViewModel
22+
@State private var model: UserStudyChatViewModel
2323
@State private var viewState: ViewState = .idle
2424

2525
private var enableTextToSpeech: Binding<Bool> {

LLMonFHIR/FHIRInterpretation/UserStudy/UserStudyChatViewModel.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ final class UserStudyChatViewModel: Sendable {
8787
interpretationModule.resourceSummarizer
8888
}
8989

90-
var processingState: ProcessingState = .processingSystemPrompts
90+
private(set) var processingState: ProcessingState = .processingSystemPrompts
9191

9292
/// The current navigation state of the study
9393
private(set) var navigationState: NavigationState = .introduction
@@ -129,24 +129,18 @@ final class UserStudyChatViewModel: Sendable {
129129
inProgressStudy: InProgressStudy,
130130
initialQuestionnaireResponse: ModelsR4.QuestionnaireResponse?,
131131
interpretationModule: FHIRInterpretationModule,
132-
// interpreter: FHIRMultipleResourceInterpreter,
133-
// resourceSummarizer: FHIRResourceSummarizer,
134132
uploader: FirebaseUpload?
135133
) {
136134
self.inProgressStudy = inProgressStudy
137135
self.initialQuestionnaireResponse = initialQuestionnaireResponse
138136
self.interpretationModule = interpretationModule
139-
// self.interpreter = interpreter
140-
// self.resourceSummarizer = resourceSummarizer
141137
self.uploader = uploader
142138
configureMessageLimits()
143139
}
144140

145141
static func unguided(
146142
title: String,
147143
interpretationModule: FHIRInterpretationModule,
148-
// interpreter: FHIRMultipleResourceInterpreter,
149-
// resourceSummarizer: FHIRResourceSummarizer
150144
) -> Self {
151145
let emptyStudy = Study(
152146
id: Study.unguidedStudyId,
@@ -166,8 +160,6 @@ final class UserStudyChatViewModel: Sendable {
166160
),
167161
initialQuestionnaireResponse: nil,
168162
interpretationModule: interpretationModule,
169-
// interpreter: interpreter,
170-
// resourceSummarizer: resourceSummarizer,
171163
uploader: nil
172164
)
173165
}

LLMonFHIR/LLMonFHIRDelegate.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import SpeziLLMOpenAI
2929
final class LLMonFHIRDelegate: SpeziAppDelegate {
3030
override var configuration: Configuration {
3131
Configuration(standard: LLMonFHIRStandard()) {
32-
if let config = AppConfigFile.current().firebaseConfig {
32+
if !FeatureFlags.disableFirebase, let config = AppConfigFile.current().firebaseConfig {
3333
firebaseModules(using: config)
3434
}
3535
let openAIInterceptor = OpenAIRequestInterceptor()
@@ -51,8 +51,13 @@ final class LLMonFHIRDelegate: SpeziAppDelegate {
5151
retryPolicy: .attempts(3), // Automatically perform up to 3 retries on retryable OpenAI API status codes
5252
middlewares: [openAIInterceptor]
5353
))
54-
LLMFogPlatform(configuration: .init(host: "spezillmfog.local", connectionType: .http, authToken: .none))
55-
LLMLocalPlatform()
54+
switch AppConfigFile.current().appLaunchMode {
55+
case .study:
56+
let _ = () // swiftlint:disable:this redundant_discardable_let
57+
case .standalone, .test:
58+
LLMFogPlatform(configuration: .init(host: "spezillmfog.local", connectionType: .http, authToken: .none))
59+
LLMLocalPlatform()
60+
}
5661
}
5762
}
5863
}

LLMonFHIR/SharedContext/FeatureFlags.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ enum FeatureFlags {
2323

2424
/// Whether the app should use a local firebase emulator
2525
static let useFirebaseEmulator = CommandLine.arguments.contains("--useFirebaseEmulator")
26+
27+
/// Whether the app disable its firebase integration.
28+
///
29+
/// - Note: if present, this option will take precedence over ``useFirebaseEmulator``.
30+
static let disableFirebase = CommandLine.arguments.contains("--disableFirebase")
2631
}

0 commit comments

Comments
 (0)