Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added remove_texts on base, elasticsearch, pgvector vectorsearch #525

Merged
merged 8 commits into from
Mar 25, 2024
Merged

Conversation

gregogalante
Copy link
Contributor

No description provided.

@gregogalante
Copy link
Contributor Author

@andreibondarev I have a little trouble understanding the problem with pgvector remove_texts. Can you check what the result value on tests?

@andreibondarev
Copy link
Collaborator

@andreibondarev I have a little trouble understanding the problem with pgvector remove_texts. Can you check what the result value on tests?

Hmmm... is it because we're adding other records to pgvector before this remove_texts spec is executed? Odd.

expect(ids.length).to eq(2)

result = subject.remove_texts(ids: ids)
expect(result.size).to eq(2)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1) Langchain::Vectorsearch::Pgvector#remove_texts removes texts
     Failure/Error: expect(result.size).to eq(2)

       expected: 2
            got: 8

       (compared using ==)
     # ./spec/langchain/vectorsearch/pgvector_spec.rb:127:in `block (3 levels) in <top (required)>'
     # ./spec/support/vcr.rb:22:in `block (3 levels) in <top (required)>'
     # ./vendor/bundle/ruby/3.2.0/gems/vcr-6.2.0/lib/vcr.rb:274:in `turned_off'
     # ./spec/support/vcr.rb:22:in `block (2 levels) in <top (required)>'

Finished in 4.16 seconds (files took 2.4 seconds to load)
426 examples, 1 failure, 3 pending

Failed examples:

rspec ./spec/langchain/vectorsearch/pgvector_spec.rb:121 # Langchain::Vectorsearch::Pgvector#remove_texts removes texts

Perhaps the result object is stale somehow? Can we try using:

subject.db.count

to see if it returns accurate count?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andreibondarev I don't have a local pg vector database to test it. Can you try to run only remove_texts test to check length?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gregogalante Turns out that result is the actual number of elements deleted:

        result = subject.remove_texts(ids: ids)
        expect(result.size).to eq(2)

But when you call result.size it's the same as calling 2.size which is the number of bytes that Integer represent.

@andreibondarev
Copy link
Collaborator

@gregogalante I cherry-picked some of your commits out to focus on this PR on just the Pgvector.

@andreibondarev andreibondarev merged commit 86b7faf into patterns-ai-core:main Mar 25, 2024
5 checks passed
@andreibondarev andreibondarev linked an issue Mar 25, 2024 that may be closed by this pull request
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add remove_texts methods to all Langchain::Vectorsearch::* classes
2 participants