From 9a3083708f4eacfc7e3ea6c3a3ca7d46fa80f52f Mon Sep 17 00:00:00 2001 From: Vishnu Ravi Date: Thu, 4 Apr 2024 14:30:43 -0400 Subject: [PATCH] Remove redundant extensions --- HealthGPT/HealthGPT/HealthGPTView.swift | 54 +------------------------ HealthGPT/Onboarding/LLMSource.swift | 1 + 2 files changed, 3 insertions(+), 52 deletions(-) diff --git a/HealthGPT/HealthGPT/HealthGPTView.swift b/HealthGPT/HealthGPT/HealthGPTView.swift index b8020cb..1f6dda0 100644 --- a/HealthGPT/HealthGPT/HealthGPTView.swift +++ b/HealthGPT/HealthGPT/HealthGPTView.swift @@ -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") @@ -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 - ) - } - } -} diff --git a/HealthGPT/Onboarding/LLMSource.swift b/HealthGPT/Onboarding/LLMSource.swift index 0347059..535b24b 100644 --- a/HealthGPT/Onboarding/LLMSource.swift +++ b/HealthGPT/Onboarding/LLMSource.swift @@ -7,6 +7,7 @@ // import Foundation +import SpeziLLMOpenAI enum LLMSource: String, CaseIterable, Identifiable, Codable {