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

Fix for updating record on pinecone #479

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

ddyy
Copy link

@ddyy ddyy commented Feb 23, 2024

When updating a record with pinecone db, I receive this error:

NoMethodError: undefined method `empty?' for nil:NilClass (NoMethodError)

  inputs["setMetadata"] = set_metadata unless set_metadata.empty?
                                                          ^^^^^^^

/ruby-3.2.2/gems/pinecone-0.1.71/lib/pinecone/vector.rb:51:in update' /ruby-3.2.2/gems/langchainrb-0.8.2/lib/langchain/vectorsearch/pinecone.rb:91:in block in update_texts'

This PR fixes the missing metadata by setting it the same way in update_data as it's set in add_data

@@ -93,7 +93,7 @@ def update_texts(texts:, ids:, namespace: "", metadata: nil)
namespace: namespace,
id: ids[i].to_s,
values: llm.embed(text: text).embedding,
set_metadata: metadata
set_metadata: metadata || {content: text}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we optionally pass metadata if it's set? Otherwise not even pass this parameter. Would that work for your usecase?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, that works for me, it's not required for my use case, but I followed the format in add_texts in case it was needed. The metadata is only convenient to identify the vector entries when browsing from pinecone db directly, but is not functionally necessary.

@andreibondarev
Copy link
Collaborator

@ddyy Specs are broken.

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.

None yet

2 participants