Skip to content

Commit

Permalink
"Update SwiftyNotion package to version 0.1.5, modify add_documents a…
Browse files Browse the repository at this point in the history
…nd remove_documents functions in VectorStore.swift to remove unnecessary withTaskGroup usage."
  • Loading branch information
buhe committed Mar 7, 2024
1 parent 5f8ce91 commit 5628b52
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/buhe/SwiftyNotion",
"state" : {
"revision" : "64e053ad708827655589a39dc0dbf897e109219c",
"version" : "0.1.4"
"branch" : "main",
"revision" : "ccfe5600df5e315e48470ca840f682ec446869f8"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
13 changes: 5 additions & 8 deletions Sources/LangChain/vectorstores/VectorStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit 5628b52

Please sign in to comment.