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

PGVector#update_texts #248

Merged
merged 7 commits into from
Jul 14, 2023

Conversation

dcluna
Copy link
Contributor

@dcluna dcluna commented Jul 11, 2023

This commit implements (tentative) pgvector support for upsert functionality, which as far as I can understand is all that is required to make it work correctly with the Rails integration.

This is open to discussion and modification - please let me know if there's anything to improve here.

@dcluna dcluna force-pushed the update-texts-pgvector branch from dce4c06 to 3df05fc Compare July 11, 2023 14:45
upsert_texts(texts: texts, ids: ids)
end

def update_texts(texts:, ids:)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you please annotate this method as well?

@andreibondarev
Copy link
Collaborator

@dcluna Please run standardrb --fix and commit. Thank you for your contribution here!

@dcluna dcluna force-pushed the update-texts-pgvector branch from 73f4b01 to 7d409a3 Compare July 11, 2023 22:27
Copy link
Contributor Author

@dcluna dcluna left a comment

Choose a reason for hiding this comment

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

@andreibondarev Please take a look at this comment - had to write a corner case for when ids are not required in add_texts, but if this is not necessary I'd prefer to have the original API using the same method for both add/update operations.

@@ -47,7 +47,44 @@
it "adds texts" do
command = subject.add_texts(texts: ["Hello World", "Hello World"])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way this was written suggests that ids are optional in this method - however, from the usage I could find (for instance, https://github.com/andreibondarev/langchainrb/blob/7d409a378ab300f4641a71b74d25e5cd9593122f/lib/langchain/active_record/hooks.rb#L52-L55) it seems like this is not the case.

I'd be more than happy to enforce the existence of texts/ids in tandem, but not sure if there is an (upcoming?) use case that relies on this API.

@dcluna
Copy link
Contributor Author

dcluna commented Jul 12, 2023

@andreibondarev Also, not sure if CI did not trigger due to me force-pushing the branch or if it's actually manually triggered by you - in any case, could you please make it run so this PR can be merged?

@dcluna dcluna requested a review from andreibondarev July 12, 2023 02:22
@andreibondarev
Copy link
Collaborator

@dcluna No, at least at add_texts() the IDs are not required because if you don't pass IDs they should be created automatically.

@andreibondarev andreibondarev merged commit c8ff7d4 into patterns-ai-core:main Jul 14, 2023
@dcluna dcluna deleted the update-texts-pgvector branch July 14, 2023 01:58
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.

2 participants