Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
philippzagar committed Feb 26, 2024
1 parent f4c8729 commit 9af7659
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 8 additions & 15 deletions Sources/SpeziFHIRLLM/Helpers/FHIRStore+Interpretation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }))
}

Check warning on line 124 in Sources/SpeziFHIRLLM/Helpers/FHIRStore+Interpretation.swift

View check run for this annotation

Codecov / codecov/patch

Sources/SpeziFHIRLLM/Helpers/FHIRStore+Interpretation.swift#L113-L124

Added lines #L113 - L124 were not covered by tests
Expand Down
2 changes: 1 addition & 1 deletion Sources/SpeziFHIRLLM/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -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" : {
Expand Down
2 changes: 1 addition & 1 deletion Tests/UITests/TestApp/ExampleModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import Spezi
import SpeziFHIRInterpretation
import SpeziFHIRLLM
import SpeziLLM
import SpeziLocalStorage

Expand Down
2 changes: 1 addition & 1 deletion Tests/UITests/TestApp/PromptSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// SPDX-License-Identifier: MIT
//

import SpeziFHIRInterpretation
import SpeziFHIRLLM
import SwiftUI


Expand Down
4 changes: 2 additions & 2 deletions Tests/UITests/UITests.xcodeproj/TestApp.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
},
{
"containerPath" : "container:..\/..",
"identifier" : "SpeziFHIRInterpretation",
"name" : "SpeziFHIRInterpretation"
"identifier" : "SpeziFHIRLLM",
"name" : "SpeziFHIRLLM"
},
{
"containerPath" : "container:..\/..",
Expand Down
14 changes: 7 additions & 7 deletions Tests/UITests/UITests.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
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 */; };
2FBD9AF92B01E4A000237A04 /* SpeziFHIRMockPatients in Frameworks */ = {isa = PBXBuildFile; productRef = 2FBD9AF82B01E4A000237A04 /* SpeziFHIRMockPatients */; };
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 */
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -137,9 +137,9 @@
name = TestApp;
packageProductDependencies = (
2FF6813E2A849F77002897C6 /* SpeziFHIR */,
2F35E9D52B015EB200CB89FF /* SpeziFHIRInterpretation */,
2FBD9AF82B01E4A000237A04 /* SpeziFHIRMockPatients */,
2FBD9AFA2B01E4A800237A04 /* SpeziFHIRHealthKit */,
97FFAD4F2B8C6CEA00F64722 /* SpeziFHIRLLM */,
);
productName = Example;
productReference = 2F6D139228F5F384007C25D6 /* TestApp.app */;
Expand Down Expand Up @@ -534,10 +534,6 @@
/* End XCConfigurationList section */

/* Begin XCSwiftPackageProductDependency section */
2F35E9D52B015EB200CB89FF /* SpeziFHIRInterpretation */ = {
isa = XCSwiftPackageProductDependency;
productName = SpeziFHIRInterpretation;
};
2FBD9AF82B01E4A000237A04 /* SpeziFHIRMockPatients */ = {
isa = XCSwiftPackageProductDependency;
productName = SpeziFHIRMockPatients;
Expand All @@ -550,6 +546,10 @@
isa = XCSwiftPackageProductDependency;
productName = SpeziFHIR;
};
97FFAD4F2B8C6CEA00F64722 /* SpeziFHIRLLM */ = {
isa = XCSwiftPackageProductDependency;
productName = SpeziFHIRLLM;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 2F6D138A28F5F384007C25D6 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/MacPaw/OpenAI",
"state" : {
"revision" : "35afc9a6ee127b8f22a85a31aec2036a987478af"
"revision" : "35afc9a6ee127b8f22a85a31aec2036a987478af",
"version" : "0.2.6"
}
},
{
Expand All @@ -49,35 +50,44 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/Spezi",
"state" : {
"revision" : "c4bf0e99de40acfdd2baf0fa02769f06a4c3f0eb",
"version" : "1.1.0"
"revision" : "0ced3efbc2af9513c07ac913ad762c773a00a6c8",
"version" : "1.2.1"
}
},
{
"identity" : "spezichat",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziChat.git",
"state" : {
"revision" : "ea5e21b4f42d99a5549dd7a7033e2a3efeb5fd36",
"version" : "0.1.5"
"revision" : "eae5c15b211f18e09aa98de63ce119629320afeb",
"version" : "0.1.8"
}
},
{
"identity" : "spezifoundation",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziFoundation",
"state" : {
"revision" : "d1e6d4cddcf236038d21a73d671806d8ba51b01c",
"version" : "1.0.1"
"revision" : "0346857e2f1d6fd4b1d950d271be6c82df97107f",
"version" : "1.0.2"
}
},
{
"identity" : "spezihealthkit",
"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"
}
},
{
Expand Down Expand Up @@ -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"
}
}
],
Expand Down

0 comments on commit 9af7659

Please sign in to comment.