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

samples: Jupyter Notebook "#Try-inserting-the-documents-into-the-vector-table" is incompatible with the actual code and fails #137

Open
odeke-em opened this issue Feb 3, 2025 · 1 comment
Assignees
Labels
api: spanner Issues related to the googleapis/langchain-google-spanner-python API. samples Issues that are directly related to samples.

Comments

@odeke-em
Copy link
Contributor

odeke-em commented Feb 3, 2025

While trying to get end-to-end samples working alright, I encountered the section "#Try-inserting-the-documents-into-the-vector-table" when fails when given

def netflix_from_gcs():
    return read_csv_from_gcs(
        "cloud-samples-data", "langchain/netflix_titles_compute_embeddings.csv"
    )

def intialize_embedding_service(vector_store, documents):
    docs_to_load = documents[:100]
    print("docs_to_load[0]", docs_to_load[0])
                
    # ! Uncomment the following line to load all 8,800+ documents to the
    # database vector table with calling the embedding service.
    # docs_to_load = documents
    ids = [str(uuid.uuid4()) for i in range(len(docs_to_load))]
    vector_store.add_documents(docs_to_load, ids, batch_size=500)

with

docs_to_load[0] ['show_id', 'type', 'title', 'director', 'cast', 'country', 'date_added', 'release_year', 'rating', 'duration', 'listed_in', 'description']
Traceback (most recent call last):
  File "/Users/emmanuelodeke/go/src/github.com/googleapis/langchain-google-spanner-python/samples/search_knn.py", line 170, in <module>
    main()
  File "/Users/emmanuelodeke/go/src/github.com/googleapis/langchain-google-spanner-python/samples/search_knn.py", line 80, in main
    run_kNN_vector_store()
  File "/Users/emmanuelodeke/go/src/github.com/googleapis/langchain-google-spanner-python/samples/search_knn.py", line 136, in run_kNN_vector_store
    intialize_embedding_service(vector_store, documents)
  File "/Users/emmanuelodeke/go/src/github.com/googleapis/langchain-google-spanner-python/samples/search_knn.py", line 91, in intialize_embedding_service
    vector_store.add_documents(docs_to_load, ids, batch_size=500)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/langchain_google_spanner/vector_store.py", line 923, in add_documents
    texts = [doc.page_content for doc in documents]
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/langchain_google_spanner/vector_store.py", line 923, in <listcomp>
    texts = [doc.page_content for doc in documents]
AttributeError: 'list' object has no attribute 'page_content'
@product-auto-label product-auto-label bot added api: spanner Issues related to the googleapis/langchain-google-spanner-python API. samples Issues that are directly related to samples. labels Feb 3, 2025
@odeke-em
Copy link
Contributor Author

odeke-em commented Feb 3, 2025

Kindly cc-ing @averikitsch @gauravpurohit06

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/langchain-google-spanner-python API. samples Issues that are directly related to samples.
Projects
None yet
Development

No branches or pull requests

2 participants