ZachNagengast / similarity-search-kit

🔎 SimilaritySearchKit is a Swift package providing on-device text embeddings and semantic search functionality for iOS and macOS applications.

Home Page:https://discord.gg/2vBQcF3nU5

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gracefully throw exception instead of using fatalError

longseespace opened this issue · comments

Hi. I think as a library, SSK should gracefully throw an exception and let the application handle it instead of crashing the app.

What do you think? @ZachNagengast

fatalError("Failed to generate a test input vector.")

Yes very much agreed.

It would be great to know why this is failing if you have any more debug info.

private func setupDimension() async {
if let testVector = await indexModel.encode(sentence: "Test sentence") {
dimension = testVector.count
} else {
fatalError("Failed to generate a test input vector.")
}
}

In the meantime, this can definitely fail more quietly.

@longseespace this should be addressed in release 0.0.9 https://github.com/ZachNagengast/similarity-search-kit/releases/tag/0.0.9 but definitely lmk if you get anymore info about why the setupDimension is failing sometimes.