From 9af7659aec023b1d91e79feb27251106c2d99b47 Mon Sep 17 00:00:00 2001 From: Philipp Zagar Date: Sun, 25 Feb 2024 22:55:04 -0800 Subject: [PATCH] Small changes --- .../FHIRGetResourceLLMFunction.swift | 2 +- .../FHIRMultipleResourceInterpreter.swift | 2 +- .../Helpers/FHIRStore+Interpretation.swift | 23 +++++-------- .../Resources/Localizable.xcstrings | 2 +- Tests/UITests/TestApp/ExampleModule.swift | 2 +- Tests/UITests/TestApp/PromptSettings.swift | 2 +- .../UITests.xcodeproj/TestApp.xctestplan | 4 +-- .../UITests/UITests.xcodeproj/project.pbxproj | 14 ++++---- .../xcshareddata/swiftpm/Package.resolved | 32 ++++++++++++------- 9 files changed, 43 insertions(+), 40 deletions(-) diff --git a/Sources/SpeziFHIRLLM/FHIRInterpretation/MultipleResources/FHIRGetResourceLLMFunction.swift b/Sources/SpeziFHIRLLM/FHIRInterpretation/MultipleResources/FHIRGetResourceLLMFunction.swift index 012026b..67c17dd 100644 --- a/Sources/SpeziFHIRLLM/FHIRInterpretation/MultipleResources/FHIRGetResourceLLMFunction.swift +++ b/Sources/SpeziFHIRLLM/FHIRInterpretation/MultipleResources/FHIRGetResourceLLMFunction.swift @@ -12,7 +12,7 @@ import SpeziLLMOpenAI struct FHIRGetResourceLLMFunction: LLMFunction { - static let logger = Logger(subsystem: "edu.stanford.spezi.fhir", category: "SpeziFHIRInterpretation") + static let logger = Logger(subsystem: "edu.stanford.spezi.fhir", category: "SpeziFHIRLLM") static let name = "get_resources" static let description = String(localized: "FUNCTION_DESCRIPTION") diff --git a/Sources/SpeziFHIRLLM/FHIRInterpretation/MultipleResources/FHIRMultipleResourceInterpreter.swift b/Sources/SpeziFHIRLLM/FHIRInterpretation/MultipleResources/FHIRMultipleResourceInterpreter.swift index b637c16..91585fa 100644 --- a/Sources/SpeziFHIRLLM/FHIRInterpretation/MultipleResources/FHIRMultipleResourceInterpreter.swift +++ b/Sources/SpeziFHIRLLM/FHIRInterpretation/MultipleResources/FHIRMultipleResourceInterpreter.swift @@ -25,7 +25,7 @@ private enum FHIRMultipleResourceInterpreterConstants { /// Used to interpret multiple FHIR resources via a chat-based interface with an LLM. @Observable public class FHIRMultipleResourceInterpreter { - static let logger = Logger(subsystem: "edu.stanford.spezi.fhir", category: "SpeziFHIRInterpretation") + static let logger = Logger(subsystem: "edu.stanford.spezi.fhir", category: "SpeziFHIRLLM") private let localStorage: LocalStorage private let llmRunner: LLMRunner diff --git a/Sources/SpeziFHIRLLM/Helpers/FHIRStore+Interpretation.swift b/Sources/SpeziFHIRLLM/Helpers/FHIRStore+Interpretation.swift index 0ee78d1..ea248a1 100644 --- a/Sources/SpeziFHIRLLM/Helpers/FHIRStore+Interpretation.swift +++ b/Sources/SpeziFHIRLLM/Helpers/FHIRStore+Interpretation.swift @@ -111,21 +111,14 @@ extension FHIRStore { /// /// - Tip: We use an array as the order indicates the sorting, oldest resources come first, newest one last public var allResourcesFunctionCallIdentifier: [String] { - let relevantResources: [FHIRResource] - - if llmRelevantResources.count > 100 /*resourceLimit*/ { - relevantResources = llmRelevantResources - .lazy - .filter { - $0.date != nil - } - .sorted { - $0.date ?? .distantPast < $1.date ?? .distantPast - } - .suffix(100 /*resourceLimit*/) - } else { - relevantResources = llmRelevantResources - } + let relevantResources: [FHIRResource] = llmRelevantResources + .lazy + .filter { + $0.date != nil + } + .sorted { + $0.date ?? .distantPast < $1.date ?? .distantPast + } return Array(Set(relevantResources.removingDuplicates().map { $0.functionCallIdentifier })) } diff --git a/Sources/SpeziFHIRLLM/Resources/Localizable.xcstrings b/Sources/SpeziFHIRLLM/Resources/Localizable.xcstrings index 717ac79..3a33da1 100644 --- a/Sources/SpeziFHIRLLM/Resources/Localizable.xcstrings +++ b/Sources/SpeziFHIRLLM/Resources/Localizable.xcstrings @@ -420,7 +420,7 @@ } }, "Interpretation Prompt" : { - "comment" : "Title of the interpretation prompt.\nTitle of the multiple resources interpretation prompt.", + "comment" : "Title of the multiple resources interpretation prompt.\nTitle of the interpretation prompt.", "localizations" : { "de" : { "stringUnit" : { diff --git a/Tests/UITests/TestApp/ExampleModule.swift b/Tests/UITests/TestApp/ExampleModule.swift index 5531290..632107d 100644 --- a/Tests/UITests/TestApp/ExampleModule.swift +++ b/Tests/UITests/TestApp/ExampleModule.swift @@ -7,7 +7,7 @@ // import Spezi -import SpeziFHIRInterpretation +import SpeziFHIRLLM import SpeziLLM import SpeziLocalStorage diff --git a/Tests/UITests/TestApp/PromptSettings.swift b/Tests/UITests/TestApp/PromptSettings.swift index f6a77af..5cfbab0 100644 --- a/Tests/UITests/TestApp/PromptSettings.swift +++ b/Tests/UITests/TestApp/PromptSettings.swift @@ -6,7 +6,7 @@ // SPDX-License-Identifier: MIT // -import SpeziFHIRInterpretation +import SpeziFHIRLLM import SwiftUI diff --git a/Tests/UITests/UITests.xcodeproj/TestApp.xctestplan b/Tests/UITests/UITests.xcodeproj/TestApp.xctestplan index 098de68..db1eb44 100644 --- a/Tests/UITests/UITests.xcodeproj/TestApp.xctestplan +++ b/Tests/UITests/UITests.xcodeproj/TestApp.xctestplan @@ -23,8 +23,8 @@ }, { "containerPath" : "container:..\/..", - "identifier" : "SpeziFHIRInterpretation", - "name" : "SpeziFHIRInterpretation" + "identifier" : "SpeziFHIRLLM", + "name" : "SpeziFHIRLLM" }, { "containerPath" : "container:..\/..", diff --git a/Tests/UITests/UITests.xcodeproj/project.pbxproj b/Tests/UITests/UITests.xcodeproj/project.pbxproj index 0678f2e..7bdee5e 100644 --- a/Tests/UITests/UITests.xcodeproj/project.pbxproj +++ b/Tests/UITests/UITests.xcodeproj/project.pbxproj @@ -11,7 +11,6 @@ 2F34D1502B0CF42F009300C1 /* PromptSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F34D14F2B0CF42F009300C1 /* PromptSettings.swift */; }; 2F34D1522B0CF59A009300C1 /* MockPatientSelection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F34D1512B0CF59A009300C1 /* MockPatientSelection.swift */; }; 2F34D1542B0D833F009300C1 /* ExampleModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F34D1532B0D833F009300C1 /* ExampleModule.swift */; }; - 2F35E9D62B015EB200CB89FF /* SpeziFHIRInterpretation in Frameworks */ = {isa = PBXBuildFile; productRef = 2F35E9D52B015EB200CB89FF /* SpeziFHIRInterpretation */; }; 2F36AD33299DB72400B1077C /* FHIRMockDataStorageProviderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F36AD32299DB72400B1077C /* FHIRMockDataStorageProviderTests.swift */; }; 2F6D139A28F5F386007C25D6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2F6D139928F5F386007C25D6 /* Assets.xcassets */; }; 2FA7382C290ADFAA007ACEB9 /* TestApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FA7382B290ADFAA007ACEB9 /* TestApp.swift */; }; @@ -19,6 +18,7 @@ 2FBD9AFB2B01E4A800237A04 /* SpeziFHIRHealthKit in Frameworks */ = {isa = PBXBuildFile; productRef = 2FBD9AFA2B01E4A800237A04 /* SpeziFHIRHealthKit */; }; 2FD021DD299E0F2900E5B91B /* TestAppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FD021DC299E0F2900E5B91B /* TestAppDelegate.swift */; }; 2FF6813F2A849F77002897C6 /* SpeziFHIR in Frameworks */ = {isa = PBXBuildFile; productRef = 2FF6813E2A849F77002897C6 /* SpeziFHIR */; }; + 97FFAD502B8C6CEA00F64722 /* SpeziFHIRLLM in Frameworks */ = {isa = PBXBuildFile; productRef = 97FFAD4F2B8C6CEA00F64722 /* SpeziFHIRLLM */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -52,9 +52,9 @@ buildActionMask = 2147483647; files = ( 2FBD9AFB2B01E4A800237A04 /* SpeziFHIRHealthKit in Frameworks */, + 97FFAD502B8C6CEA00F64722 /* SpeziFHIRLLM in Frameworks */, 2FF6813F2A849F77002897C6 /* SpeziFHIR in Frameworks */, 2FBD9AF92B01E4A000237A04 /* SpeziFHIRMockPatients in Frameworks */, - 2F35E9D62B015EB200CB89FF /* SpeziFHIRInterpretation in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -137,9 +137,9 @@ name = TestApp; packageProductDependencies = ( 2FF6813E2A849F77002897C6 /* SpeziFHIR */, - 2F35E9D52B015EB200CB89FF /* SpeziFHIRInterpretation */, 2FBD9AF82B01E4A000237A04 /* SpeziFHIRMockPatients */, 2FBD9AFA2B01E4A800237A04 /* SpeziFHIRHealthKit */, + 97FFAD4F2B8C6CEA00F64722 /* SpeziFHIRLLM */, ); productName = Example; productReference = 2F6D139228F5F384007C25D6 /* TestApp.app */; @@ -534,10 +534,6 @@ /* End XCConfigurationList section */ /* Begin XCSwiftPackageProductDependency section */ - 2F35E9D52B015EB200CB89FF /* SpeziFHIRInterpretation */ = { - isa = XCSwiftPackageProductDependency; - productName = SpeziFHIRInterpretation; - }; 2FBD9AF82B01E4A000237A04 /* SpeziFHIRMockPatients */ = { isa = XCSwiftPackageProductDependency; productName = SpeziFHIRMockPatients; @@ -550,6 +546,10 @@ isa = XCSwiftPackageProductDependency; productName = SpeziFHIR; }; + 97FFAD4F2B8C6CEA00F64722 /* SpeziFHIRLLM */ = { + isa = XCSwiftPackageProductDependency; + productName = SpeziFHIRLLM; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = 2F6D138A28F5F384007C25D6 /* Project object */; diff --git a/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 8568563..6f5caf0 100644 --- a/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,7 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/MacPaw/OpenAI", "state" : { - "revision" : "35afc9a6ee127b8f22a85a31aec2036a987478af" + "revision" : "35afc9a6ee127b8f22a85a31aec2036a987478af", + "version" : "0.2.6" } }, { @@ -49,8 +50,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/StanfordSpezi/Spezi", "state" : { - "revision" : "c4bf0e99de40acfdd2baf0fa02769f06a4c3f0eb", - "version" : "1.1.0" + "revision" : "0ced3efbc2af9513c07ac913ad762c773a00a6c8", + "version" : "1.2.1" } }, { @@ -58,8 +59,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/StanfordSpezi/SpeziChat.git", "state" : { - "revision" : "ea5e21b4f42d99a5549dd7a7033e2a3efeb5fd36", - "version" : "0.1.5" + "revision" : "eae5c15b211f18e09aa98de63ce119629320afeb", + "version" : "0.1.8" } }, { @@ -67,8 +68,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/StanfordSpezi/SpeziFoundation", "state" : { - "revision" : "d1e6d4cddcf236038d21a73d671806d8ba51b01c", - "version" : "1.0.1" + "revision" : "0346857e2f1d6fd4b1d950d271be6c82df97107f", + "version" : "1.0.2" } }, { @@ -76,8 +77,17 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/StanfordSpezi/SpeziHealthKit.git", "state" : { - "revision" : "d882734a4ed31fce1bffd7b9977e2669080f21de", - "version" : "0.5.0" + "revision" : "b40695ffa4d1c9d58c5a0ee277640c2343fb5516", + "version" : "0.5.1" + } + }, + { + "identity" : "spezillm", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordSpezi/SpeziLLM.git", + "state" : { + "revision" : "6892c5dfe258371b6f3287f02b8fec57a611ba70", + "version" : "0.7.0" } }, { @@ -130,8 +140,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/StanfordBDHG/XCTRuntimeAssertions", "state" : { - "revision" : "bb2a287c2544aa846e53670d1ece35e5949567be", - "version" : "1.0.0" + "revision" : "51da3403f128b120705571ce61e0fe190f8889e6", + "version" : "1.0.1" } } ],