From b79a9584336da9b3e520efde6abdeaf893edf3e0 Mon Sep 17 00:00:00 2001 From: Gregorio Galante Date: Sun, 3 Mar 2024 17:58:40 +0100 Subject: [PATCH] Added remove_texts method on qvrant vectorsearch --- lib/langchain/vectorsearch/qdrant.rb | 10 ++++++++++ spec/langchain/vectorsearch/qdrant_spec.rb | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/langchain/vectorsearch/qdrant.rb b/lib/langchain/vectorsearch/qdrant.rb index b9b260343..7b6482e91 100644 --- a/lib/langchain/vectorsearch/qdrant.rb +++ b/lib/langchain/vectorsearch/qdrant.rb @@ -64,6 +64,16 @@ def update_texts(texts:, ids:) add_texts(texts: texts, ids: ids) end + # Remove a list of texts from the index + # @param ids [Array] The ids to remove + # @return [Hash] The response from the server + def remove_texts(ids:) + client.points.delete( + collection_name: index_name, + points: ids + ) + end + # Get the default schema # @return [Hash] The response from the server def get_default_schema diff --git a/spec/langchain/vectorsearch/qdrant_spec.rb b/spec/langchain/vectorsearch/qdrant_spec.rb index 522ffa632..68e25965d 100644 --- a/spec/langchain/vectorsearch/qdrant_spec.rb +++ b/spec/langchain/vectorsearch/qdrant_spec.rb @@ -101,6 +101,16 @@ end end + describe "remove_texts" do + before do + allow(subject.client).to receive_message_chain(:points, :delete).and_return(true) + end + + it "removes texts" do + expect(subject.remove_texts(ids: [1])).to eq(true) + end + end + describe "#similarity_search_by_vector" do before do allow(subject.client).to receive_message_chain(:points, :search).and_return(