MediaPipeTasksRetrieval Framework Reference

SemanticRetriever

class SemanticRetriever : NSObject

Performs on-device semantic search, vector storage, and query retrieval across text, images, and audio.

  • Creates a new SemanticRetriever instance from the given options/components.

    Declaration

    Swift

    class func create(fromComponents components: SemanticRetrieverOptions) throws -> SemanticRetriever
  • Initializes a new SemanticRetriever instance.

    Declaration

    Swift

    init(components: SemanticRetrieverOptions) throws
  • Inserts a text document with metadata into the vector store.

    Declaration

    Swift

    func insertDocument(withId recordId: String, text: String, metadata: [String : String]) throws
  • Inserts an image file with metadata into the vector store.

    Declaration

    Swift

    func insertImage(withId recordId: String, filePath: String, metadata: [String : String]) throws
  • Inserts an audio file with metadata into the vector store.

    Declaration

    Swift

    func insertAudio(withId recordId: String, filePath: String, metadata: [String : String]) throws
  • Inserts multi-modal content parts with metadata into the vector store.

    Declaration

    Swift

    func insertContent(withId recordId: String, parts: [TaskPart], metadata: [String : String]) throws
  • Retrieves the top-K nearest records matching the query string and optional metadata filter.

    Declaration

    Swift

    func retrieve(withText queryText: String, topK: Int, metadataFilter: [String : String]?) throws -> [RetrievalResult]
  • Retrieves the top-K nearest records matching the multi-modal query parts.

    Declaration

    Swift

    func retrieve(withParts queryParts: [TaskPart], topK: Int, metadataFilter: [String : String]?) throws -> [RetrievalResult]
  • Deletes records from the vector store matching the given IDs.

    Declaration

    Swift

    func delete(withIds ids: [String]) throws
  • Deletes records matching the metadata filter.

    Declaration

    Swift

    func delete(withMetadataFilter metadataFilter: [String : String]) throws
  • Deletes all records from the vector store.

    Declaration

    Swift

    func deleteAllRecords() throws
  • Returns all unique top-level record identifiers in the vector store.

    Declaration

    Swift

    func getAllRecordIds() throws -> [String]