-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow user to select local LLM during onboarding
- Loading branch information
1 parent
b46cc73
commit dad7ab8
Showing
10 changed files
with
168 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// This source file is part of the Stanford HealthGPT project | ||
// | ||
// SPDX-FileCopyrightText: 2024 Stanford University & Project Contributors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
enum LLMSource: String, CaseIterable, Identifiable, Codable { | ||
case local | ||
case openai | ||
|
||
var id: String { | ||
self.rawValue | ||
} | ||
|
||
var localizedDescription: LocalizedStringResource { | ||
switch self { | ||
case .local: | ||
LocalizedStringResource("LOCAL_LLM_LABEL") | ||
case .openai: | ||
LocalizedStringResource("OPENAI_LLM_LABEL") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// This source file is part of the Stanford HealthGPT project | ||
// | ||
// SPDX-FileCopyrightText: 2024 Stanford University & Project Contributors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import SpeziOnboarding | ||
import SwiftUI | ||
|
||
struct LLMSourceSelection: View { | ||
@Environment(OnboardingNavigationPath.self) private var onboardingNavigationPath | ||
@AppStorage(StorageKeys.llmSource) private var llmSource = StorageKeys.Defaults.llmSource | ||
|
||
var body: some View { | ||
OnboardingView( | ||
contentView: { | ||
VStack { | ||
OnboardingTitleView( | ||
title: "LLM_SOURCE_SELECTION_TITLE", | ||
subtitle: "LLM_SOURCE_SELECTION_SUBTITLE" | ||
) | ||
Spacer() | ||
sourceSelector | ||
Spacer() | ||
} | ||
}, | ||
actionView: { | ||
OnboardingActionsView( | ||
"LLM_SOURCE_SELECTION_BUTTON" | ||
) { | ||
if llmSource == .local { | ||
onboardingNavigationPath.append(customView: LLMLocalDownload()) | ||
} else { | ||
onboardingNavigationPath.append(customView: OpenAIAPIKey()) | ||
} | ||
} | ||
} | ||
) | ||
} | ||
|
||
private var sourceSelector: some View { | ||
Picker("", selection: $llmSource) { | ||
ForEach(LLMSource.allCases) { source in | ||
Text(source.localizedDescription) | ||
.tag(source) | ||
} | ||
} | ||
.pickerStyle(.inline) | ||
} | ||
} | ||
|
||
#Preview { | ||
LLMSourceSelection() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters