From 5628b52361802a69debff336c7239c83f60540cd Mon Sep 17 00:00:00 2001 From: buhe Date: Thu, 7 Mar 2024 17:49:52 +0800 Subject: [PATCH] "Update SwiftyNotion package to version 0.1.5, modify add_documents and remove_documents functions in VectorStore.swift to remove unnecessary withTaskGroup usage." --- Package.resolved | 4 ++-- Package.swift | 2 +- Sources/LangChain/vectorstores/VectorStore.swift | 13 +++++-------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Package.resolved b/Package.resolved index 34f8098..5efce18 100644 --- a/Package.resolved +++ b/Package.resolved @@ -266,8 +266,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/buhe/SwiftyNotion", "state" : { - "revision" : "64e053ad708827655589a39dc0dbf897e109219c", - "version" : "0.1.4" + "branch" : "main", + "revision" : "ccfe5600df5e315e48470ca840f682ec446869f8" } }, { diff --git a/Package.swift b/Package.swift index 7e78acc..3074e42 100644 --- a/Package.swift +++ b/Package.swift @@ -26,7 +26,7 @@ let package = Package( .package(url: "https://github.com/juyan/swift-filestore", .upToNextMajor(from: "0.5.0")), .package(url: "https://github.com/buhe/similarity-search-kit", from: "0.0.16"), .package(url: "https://github.com/google/generative-ai-swift", .upToNextMajor(from: "0.4.4")), - .package(url: "https://github.com/buhe/SwiftyNotion", .upToNextMajor(from: "0.1.4")), + .package(url: "https://github.com/buhe/SwiftyNotion", .upToNextMajor(from: "0.1.5")), .package(url: "https://github.com/nmdias/FeedKit", .upToNextMajor(from: "9.1.2")), ], targets: [ diff --git a/Sources/LangChain/vectorstores/VectorStore.swift b/Sources/LangChain/vectorstores/VectorStore.swift index 774bfae..1d60b09 100644 --- a/Sources/LangChain/vectorstores/VectorStore.swift +++ b/Sources/LangChain/vectorstores/VectorStore.swift @@ -24,18 +24,15 @@ public class VectorStore { } func add_documents(documents: [Document]) async { - await withTaskGroup(of: Void.self) { [self] group in - for document in documents { - group.addTask { await self.addText(text: document.page_content, metadata: document.metadata)} - } + for document in documents { + await self.addText(text: document.page_content, metadata: document.metadata) } } + func remove_documents(sha256s: [String]) async { - await withTaskGroup(of: Void.self) { [self] group in - for sha256 in sha256s { - group.addTask { await self.removeText(sha256: sha256)} - } + for sha256 in sha256s { + await self.removeText(sha256: sha256) } } // def add_documents(self, documents: List[Document], **kwargs: Any) -> List[str]: