Skip to content

Commit

Permalink
adapt to new versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Leon Nissen committed Dec 12, 2024
1 parent d5fe1fd commit 088e5da
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
5 changes: 4 additions & 1 deletion HealthGPT/HealthGPT/HealthDataInterpreter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ class HealthDataInterpreter: DefaultInitializable, Module, EnvironmentAccessible
///
/// - Parameter schema: the LLMSchema to use
@MainActor
func prepareLLM(with schema: any LLMSchema) async {
func prepareLLM(with schema: any LLMSchema) async throws {
let llm = llmRunner(with: schema)
systemPrompt = await generateSystemPrompt()
llm.context.append(systemMessage: systemPrompt)
if let localLLM = llm as? LLMLocalSession {
try await localLLM.setup()
}
self.llm = llm
}

Expand Down
17 changes: 11 additions & 6 deletions HealthGPT/HealthGPT/HealthGPTView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,17 @@ struct HealthGPTView: View {
Text(errorMessage)
}
.task {
if FeatureFlags.mockMode {
await healthDataInterpreter.prepareLLM(with: LLMMockSchema())
} else if FeatureFlags.localLLM || llmSource == .local {
await healthDataInterpreter.prepareLLM(with: LLMLocalSchema(model: .llama3_8B_4bit))
} else {
await healthDataInterpreter.prepareLLM(with: LLMOpenAISchema(parameters: .init(modelType: openAIModel)))
do {
if FeatureFlags.mockMode {
try await healthDataInterpreter.prepareLLM(with: LLMMockSchema())
} else if FeatureFlags.localLLM || llmSource == .local {
try await healthDataInterpreter.prepareLLM(with: LLMLocalSchema(model: .llama3_8B_4bit))
} else {
try await healthDataInterpreter.prepareLLM(with: LLMOpenAISchema(parameters: .init(modelType: openAIModel)))
}
} catch {
showErrorAlert = true
errorMessage = "Error querying LLM: \(error.localizedDescription)"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion HealthGPT/HealthGPT/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ struct SettingsView: View {
) { model in
Task {
openAIModel = model
await healthDataInterpreter.prepareLLM(with: LLMOpenAISchema(parameters: .init(modelType: model)))
try? await healthDataInterpreter.prepareLLM(with: LLMOpenAISchema(parameters: .init(modelType: model)))
path.removeLast()
}
}
Expand Down
2 changes: 2 additions & 0 deletions HealthGPT/Supporting Files/HealthGPT.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<array/>
<key>com.apple.developer.healthkit.background-delivery</key>
<true/>
<key>com.apple.developer.kernel.increased-memory-limit</key>
<true/>
</dict>
</plist>

0 comments on commit 088e5da

Please sign in to comment.