Teradata Package for LangChain Function Reference - add_documents - Teradata® Package for LangChain - Look here for syntax, methods and examples for the functions included in the Teradata langchain-teradata package.

Teradata® Package for LangChain Function Reference

Deployment
VantageCloud
Edition
Enterprise
Product
Teradata® Package for LangChain
Release Number
20.00.00.01
Published
December 2025
ft:locale
en-US
ft:lastEdition
2025-12-19
dita:id
Langchain-Teradata_FxRef_Lake
Product Category
Teradata Vantage
libs.teradata.langchain_teradata.TeradataVectorStore.add_documents = add_documents(self, documents, **kwargs)
DESCRIPTION:
    Adds documents to an existing file-based Vector Store.
    Creates a new Vector Store in case it does not exists.
    If the input is PDF file(s) or file path(s), a file-based vector store is created.
    If the input is LangChain Document object(s), a content-based vector store
    is created.
 
PARAMETERS:
    documents:
        Required Argument.
        Specifies the dataset of document files or LangChain Document objects to be added.
        For input files:
            A directory path or wildcard pattern can be specified.
            The files are processed internally, converted to chunks, and 
            stored in a database table.
        For input LangChain Document objects:
            A list of Document objects can be specified.
            The Document objects are processed internally and the chunks
            are stored in a database table.
        Notes:
            * Only PDF format is currently supported for files.
            * Multiple document files can be supplied.
            * Fully qualified file names should be specified.
            * Input can be either file(s)/file path(s) or LangChain Document objects.
              A combination of file(s)/file path(s) and LangChain Document objects
              is not supported as input.
        Examples:
            Example 1: Multiple files specified within a list
            >>> documents = ['file1.pdf', 'file2.pdf']
            Example 2: Path to the directory containing PDF files 
            >>> documents = "/path/to/pdfs"
            Example 3: Path to directory containing PDF files as a wildcard string
            >>> documents = "/path/to/pdfs/*.pdf"
            Example 4: Path to directory containing PDF files and subdirectories of PDF files
            >>> documents = "/path/to/pdfs/**/*.pdf"
 
            Example 5: List of LangChain Document objects
            >>> from langchain_core.documents import Document
            >>> documents = [Document(page_content="This is a test document", id="doc1"),
                             Document(page_content="This is another test document", id="doc2")]
        Types: str, list, LangChain Document object
 
    name:
        Optional Argument.
        Specifies the name of the vector store.
        Type: str
 
    object_names:
        Optional Argument.
        Specifies the table name to store file content splits.
        Notes:
            * Applicable only for file-based inputs.
            * Only one table name should be specified.
        Type: str
 
    target_database:
        Optional Argument.
        Specifies the database name where the vector store and file content
        splits are created/stored.
        Note:
            If not specified, uses the current database.
        Type: str
 
    data_columns:
        Optional Argument.
        Specifies the column name(s) to store the content splits.
        Notes:
            * Applicable only for file-based inputs.
        Type: str
 
    update_style:
        Optional Argument.
        Specifies the style to be used for alter operation of the data
        from the vector store when "search_algorithm" is KMEANS/HNSW.
        Default Value: MINOR
        Permitted Values: MINOR, MAJOR
        Types: str
 
    metadata_operation:
        Optional Argument.
        Specifies the operation to be performed on metadata columns
        during update.
        - ADD -  add new metadata columns
        - DELETE - remove existing metadata columns
        - MODIFY - change the description of the existing metadata columns
 
        Note:
            * Applicable to all store types except the METADATA-BASED store type.
        Default Value: ADD
        Permitted Values: ADD, DELETE, MODIFY
        Types: str
 
    description:
        Optional Argument.
        Specifies the description of the vector store.
        Types: str
 
    vector_column:
        Optional Argument.
        Specifies the name of the column to be used for storing
        the embeddings.
        Default Value: vector_index
        Types: str
 
    metadata_columns:
        Optional Argument.
        Specifies the list of input column names to be used for metadata.
        These columns just get accumulated in the vector store.
        Types: list[str]
 
    metadata_descriptions:
        Optional Argument.
        Specifies the deescriptions of the metadata columns. One value for each metadata column.
        Note:
            Applicable to all store types except metadata-based store type.
        Types: list[str]
 
    use_simd:
        Optional Argument.
        Specifies whether to use SIMD for faster processing.
        Types: bool
 
    embedding_datatype:
        Optional Argument.
        Specifies the data type of the embeddings to be used.
        Default Value: VECTOR32
        Permitted Values: VECTOR32, VECTOR64
        Types: str
 
    embeddings_dims:
        Required for NVIDIA NIM, Optional otherwise.
        Specifies the number of dimensions to be used for generating the embeddings.
        The value depends on the "embeddings".
        Note:
            * Default dimesions is set to 1024 for embedding-based vector store.
        Default Value:
            For AWS:
                * amazon.titan-embed-text-v1: 1536
                * amazon.titan-embed-image-v1: 1024
                * amazon.titan-embed-text-v2:0: 1024
            For Azure:
                * text-embedding-ada-002: 1536
                * text-embedding-3-small: 1536
                * text-embedding-3-large: 3072
        Permitted Values:
            *For AWS:
                * amazon.titan-embed-text-v1: 1536
                * amazon.titan-embed-image-v1: [256, 384, 1024]
                * amazon.titan-embed-text-v2:0: [256, 512, 1024]
            *For Azure:
                * text-embedding-ada-002: 1536 only
                * text-embedding-3-small: 1 <= dims <= 1536
                * text-embedding-3-large: 1 <= dims <= 3072
        Types: str
 
    chat_completion_max_tokens:
        Required for NVIDIA NIM, Optional otherwise.
        Specifies the maximum number of tokens to be generated by the
        "chat_completion_model".
        Default Value: 16384
        Permitted Values: [1, 16384]
        Types: int
 
    model_urls:
        Optional Argument.
        Specifies the URL and models to be used for embedding, chat completion
        and guardrails.
        Note:
            * Refer to the ModelUrlParams class for more details.
        Types: ModelUrlParams
 
    chunk_size:
        Optional Argument.
        Specifies the number of characters in each chunk to be used while
        splitting the input file.
        Note:
            Applicable only for 'file-based' vector stores.
        Default Value: 512
        Types: int
 
    optimized_chunking:
        Optional Argument.
        Specifies whether an optimized splitting mechanism supplied by
        Teradata should be used. The documents are parsed internally in an
        intelligent fashion based on file structure and chunks are dynamically
        created based on section layout.
        Notes:
            * The "chunk_size" field is not applicable when
              "optimized_chunking" is set to True.
            * Applicable only for 'file-based' vector stores.
        Types: bool
 
    header_height:
        Optional Argument.
        Specifies the height (in points) of the header section of a PDF
        document to be trimmed before processing the main content.
        This is useful for removing unwanted header information
        from each page of the PDF. Recommended value is 55.
        Note:
            * Applicable only for 'file-based' vector stores.
        Types: int
 
    footer_height:
        Optional Argument.
        Specifies the height (in points) of the footer section of a PDF
        document to be trimmed before processing the main content.
        This is useful for removing unwanted footer information from
        each page of the PDF. Recommended value is 55.
        Note:
            * Applicable only for 'file-based' vector stores.
        Types: int
 
    chunk_overlap:
        Optional Argument.
        Specifies the number of overlapping characters between two consecutive chunks
        to be used during the splitting of the input file.
        Note:
            * Applicable only for 'file-based' vector stores.
        Default Value: 150
        Types: int
 
    overwrite_object:
        Optional Argument.
        Specifies whether to overwrite the existing object with
        the same name in the database.
        Note:
            * Applicable only for 'file-based' vector stores.
        Types: bool
 
    ingest_params:
        Optional Argument.
        Specifies the parameters to be used for document ingestion for NIM.
        Notes:
            * Applicable only for NVIDIA NIM endpoint.
            * Applicable only for 'file-based' vector stores.
            * Refer to the IngestParams class for more details.
        Types: IngestParams
 
    embedding:
        Required for NVIDIA NIM, Optional otherwise.
        Specifies the embeddings model to be used for generating the
        embeddings.
        Default Value:
            For AWS: amazon.titan-embed-text-v2:0
            For Azure: text-embedding-3-small
        Permitted Values:
            For AWS:
                * amazon.titan-embed-text-v1
                * amazon.titan-embed-image-v1
                * amazon.titan-embed-text-v2:0
            For Azure:
                * text-embedding-ada-002
                * text-embedding-3-small
                * text-embedding-3-large
        Types: str, TeradataAI, LangChain Embeddings
 
    chat_completion_model:
        Required for NVIDIA NIM, Optional otherwise.
        Specifies the name of the chat completion model to be used for
        generating text responses.
        Default Value:
            For AWS: anthropic.claude-3-haiku-20240307-v1:0
            For Azure: gpt-35-turbo-16k
        Permitted Values:
            *For AWS:
                * anthropic.claude-3-haiku-20240307-v1:0
                * anthropic.claude-instant-v1
                * anthropic.claude-3-5-sonnet-20240620-v1:0
            *For Azure:
                * gpt-35-turbo-16k
        Types: str, TeradataAI, LangChain BaseChatModel
 
RETURNS:
    None
 
RAISES:
    None
 
EXAMPLES:
    # Create an instance of an 'file-based' vector store by passing path
    # to a PDF file in "documents".
    >>> from langchain_teradata import TeradataVectorStore
    >>> import teradatagenai
    >>> import os
    >>> base_dir = os.path.dirname(teradatagenai.__file__)
    >>> file = os.path.join(base_dir, 'example-data', 'SQL_Fundamentals.pdf')
    >>> vs_instance = TeradataVectorStore.from_documents(name = "vs_example_1",
                                                         documents = file,
                                                         embedding = "amazon.titan-embed-text-v1")
    >>> Set credentials for AWS Bedrock 
    >>> os.environ["AWS_DEFAULT_REGION"] = "<your_region>"
    >>> os.environ["AWS_ACCESS_KEY_ID"] = "<your_access_key_id>"
    >>> os.environ["AWS_SECRET_ACCESS_KEY"] = "<your_secret_access_key>"
 
    # Example 1: Add "LLM_handbook.pdf" to an existing'file-based' vector store.
    >>> file = os.path.join(base_dir, 'example-data', 'LLM_handbook.pdf')
    >>> vs_instance.add_documents(documents=file)
 
    # Example 2: Create a content-based vector store by passing a list of 
    #            LangChain Document objects in "documents" and a Langchain 
    #            BedrockEmbeddings object in "embedding".
    # Initialize the required imports.
    >>> from langchain_aws import BedrockEmbeddings
    >>> from langchain_core.documents import Document
 
    # Initialize the BedrockEmbeddings object and the Document object.
    >>> llm_bedrock = BedrockEmbeddings(model_id="amazon.titan-embed-text-v1")
    >>> doc_lc = [Document(page_content="This is a test document.", id="doc1"),
    >>>           Document(page_content="This is another document.", id="doc2")]
 
    # Create the 'content-based' vector store instance.
    >>> vs_instance = TeradataVectorStore.from_documents(name="vs_example_3",
                                                         documents=doc_lc,
                                                         embedding=llm_bedrock)
    # Add more LangChain Document objects to the existing 'content-based' vector store.
    >>> doc_lc2 = [Document(page_content="This is a new document.", id="doc3"),
    >>>           Document(page_content="This is another new document.", id="doc4")]
    >>> vs_instance.add_documents(documents=doc_lc2)
 
    # Example 3: Create a new 'content-based' vector store by passing a list of
    #            LangChain Document objects in "documents" and a Langchain
    #            BedrockEmbeddings object in "embedding".
    # Initialize the required imports.
    >>> from langchain_aws import BedrockEmbeddings
    >>> from langchain_core.documents import Document
    # Initialize the BedrockEmbeddings object and the Document object.
    >>> llm_bedrock = BedrockEmbeddings(model_id="amazon.titan-embed-text-v1")
    >>> doc_lc = [Document(page_content="This is a test document.", id="doc1"),
    >>>           Document(page_content="This is another document.", id="doc2")]
    # Create the 'content-based' vector store instance.
    >>> vs_instance = TeradataVectorStore()
    >>> vs_instance.add_documents(name="vs_example_4",
                                        documents=doc_lc,
                                        embedding=llm_bedrock)