-
-
Notifications
You must be signed in to change notification settings - Fork 426
Expand file tree
/
Copy pathVectorStore.swift
More file actions
20 lines (16 loc) · 637 Bytes
/
VectorStore.swift
File metadata and controls
20 lines (16 loc) · 637 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import Foundation
public protocol VectorStore {
func add(_ documents: [EmbeddedDocument]) async throws
func set(_ documents: [EmbeddedDocument]) async throws
func clear() async throws
func searchWithDistance(embeddings: [Float], count: Int) async throws
-> [(document: Document, distance: Float)]
}
public extension VectorStore {
func search(embeddings: [Float], count: Int) async throws -> [Document] {
try await searchWithDistance(embeddings: embeddings, count: count).map { $0.document }
}
func add(_ document: EmbeddedDocument) async throws {
try await add([document])
}
}