langflow-ai / langflow

Langflow is a low-code app builder for RAG and multi-agent AI applications. It’s Python-based and agnostic to any model, API, or database.
http://www.langflow.org
MIT License
27.01k stars 3.57k forks source link

Qdrant vectorisation from Word document error building component #2753

Closed peter-boucher closed 1 month ago

peter-boucher commented 1 month ago

Bug Description

TypeError: VectorStore.from_documents() missing 1 required positional argument:
                             'embedding'

image

Reproduction

Pre requisite: Qdrant container running locally using docker

services:
  qdrant:
    image: qdrant/qdrant:latest
    restart: always
    container_name: qdrant
    ports:
      - 6333:6333
      - 6334:6334
    expose:
      - 6333
      - 6334
      - 6335
    volumes:
      - ./qdrant_data:/qdrant_data
  1. Using the Vector Store RAG template as a base, create a new project.
  2. Remove the 'OpenAI Embeddings' Components from both flows and replace with 'Azure OpenAI Embeddings'
  3. Complete the 'Azure OpenAI Embeddings' components with your Azure OpenAI Studio deployment endpoint
  4. Replace the AstraDB component in both flows with 'Qdrant' vector store
  5. Complete the Qdrant component with the collection name, leave other settings as default for a locally running instance
  6. In the ingestion flow (bottom centre canvas) select a .docx file as your file input in the File Data component
  7. Click run on the File Data Component Observe the error: "Error building component Qdrant: VectorStore.from_documents() missing 1 required positional argument: 'embedding'"

Expected behavior

Successful build of the embedding flow

Who can help?

No response

Operating System

MacOS Sonoma 14.5 (23F79)

Langflow Version

1.0.7

Python Version

dosubot[bot] commented 1 month ago

Hello, @peter-boucher! I'm here to help you with any bugs, questions, or contributions you have. Let's work together to resolve the issue you're experiencing.

To resolve the TypeError: VectorStore.from_documents() missing 1 required positional argument: 'embedding' error, ensure that the embedding argument is correctly provided when calling the Qdrant.from_documents method. Here’s how you can do it:

  1. Ensure embedding is Provided: When you call the build method for the Qdrant component, make sure the embedding parameter is included. For example:

    qdrant_component = QdrantComponent()
    vector_store = qdrant_component.build(
        embedding=my_embedding,  # Ensure this is provided
        collection_name="my_collection",
        inputs=my_documents,  # Ensure this is provided
        api_key="my_api_key",
        # other parameters as needed
    )
  2. Generate the embedding Parameter: The embedding parameter should be an instance of the AzureOpenAIEmbeddings class. Here’s how you can generate it:

    from langchain_community.embeddings import AzureOpenAIEmbeddings
    
    azure_embedding = AzureOpenAIEmbeddings(
        azure_endpoint="your_azure_endpoint",
        azure_deployment="your_azure_deployment",
        api_version="your_api_version",
        api_key="your_api_key"
    )
  3. Pass the embedding Parameter: Use the generated azure_embedding when building the Qdrant component:

    qdrant_component = QdrantComponent()
    vector_store = qdrant_component.build(
        embedding=azure_embedding,
        collection_name="my_collection",
        inputs=my_documents,
        api_key="my_api_key",
        # other parameters as needed
    )

Ensure that my_documents is a valid list of Record or Document objects. This should resolve the error and allow the embedding flow to build successfully [1][2][3].

To continue talking to Dosu, mention @dosu.

carlosrcoelho commented 1 month ago

Hey @peter-boucher

Please make sure before you run your flow, click on ⚠️ to update the required components, and then try to run your flow.

Please let me know if it works.

carlosrcoelho commented 1 month ago

Hi @peter-boucher

Do you need any assistance with this case? If not, please let us know if this issue can be closed.

peter-boucher commented 1 month ago

Hi @peter-boucher

Do you need any assistance with this case? If not, please let us know if this issue can be closed.

Thanks @carlosrcoelho I was able to diagnose this was an issue with the embedding model Azure OpenIA Embeddings that caused an exception in the Vector DB module for Qdrand. I have the same issue with other vectorDBs.

Closing this, I'll check my embedding-ada-002 deployment and open a new issue if needed.