Skip to content

Commit

Permalink
Remove redundant extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnuravi committed Apr 4, 2024
1 parent dbec660 commit 9a30837
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 52 deletions.
54 changes: 2 additions & 52 deletions HealthGPT/HealthGPT/HealthGPTView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ struct HealthGPTView: View {
var body: some View {
NavigationStack {
if let llm = healthDataInterpreter.llm {
let contextBinding = Binding { llm.context.chatEntity } set: { llm.context = $0.llmContextEntity }
let contextBinding = Binding { llm.context.chat } set: { llm.context.chat = $0 }

ChatView(contextBinding, exportFormat: .text)
.speak(llm.context.chatEntity, muted: !textToSpeech)
.speak(llm.context.chat, muted: !textToSpeech)
.speechToolbarButton(muted: !$textToSpeech)
.viewStateAlert(state: llm.state)
.navigationTitle("WELCOME_TITLE")
Expand Down Expand Up @@ -113,53 +113,3 @@ struct HealthGPTView: View {
}
}
}

extension Array where Element == LLMContextEntity {
var chatEntity: [ChatEntity] {
self.map { llmContextEntity in
let role: ChatEntity.Role

switch llmContextEntity.role {
case .user:
role = .user
case .assistant:
role = .assistant
case .system, .tool:
role = .hidden(type: .unknown)
}

return ChatEntity(
role: role,
content: llmContextEntity.content,
complete: llmContextEntity.complete,
id: llmContextEntity.id,
date: llmContextEntity.date
)
}
}
}

extension Array where Element == ChatEntity {
var llmContextEntity: [LLMContextEntity] {
self.map { chatEntity in
let role: LLMContextEntity.Role

switch chatEntity.role {
case .user:
role = .user
case .assistant:
role = .assistant()
case .hidden:
role = .system
}

return LLMContextEntity(
role: role,
content: chatEntity.content,
complete: chatEntity.complete,
id: chatEntity.id,
date: chatEntity.date
)
}
}
}
1 change: 1 addition & 0 deletions HealthGPT/Onboarding/LLMSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import SpeziLLMOpenAI


enum LLMSource: String, CaseIterable, Identifiable, Codable {
Expand Down

0 comments on commit 9a30837

Please sign in to comment.