Teradata Package for LangChain Function Reference - prepare_response - 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.prepare_response = prepare_response(self, similarity_results, question=None, prompt=None, **kwargs)
DESCRIPTION:
    Prepare a natural language response to the user using the input
    question and similarity_results provided by
    VectorStore.similarity_search() method.
    The response is generated by a language model configured
    in the environment using a pre-configured prompt.
    An optional parameter prompt can be used to specify a customized
    prompt that replaces the internal prompt.
 
PARAMETERS:
    question:
        Required Argument, Optional for batch mode.
        Specifies a string of text for which response
        needs to be performed.
        Types: str
 
    similarity_results:
        Required Argument.
        Specifies the similarity results obtained by similarity_search().
        Types: list
 
    prompt:
        Optional Argument.
        Specifies a customized prompt that replaces the internal prompt.
        Types: str
 
    batch_data:
        Required for batch mode.
        Specifies the table name or teradataml DataFrame to be indexed for batch mode.
        Types: str, teradataml DataFrame
 
    batch_id_column:
        Required for batch mode.
        Specifies the ID column to be indexed for batch mode.
        Types: str
 
    batch_query_column:
        Required for batch mode.
        Specifies the query column to be indexed for batch mode.
        Types: str
 
    temperature:
        Optional Argument.
        Specifies the temperature for tuning the chat_completion_model.
        Types: float, int
        Permitted Values: [0.0, 2.0]
 
RETURNS:
    str.
 
RAISES:
    TypeError, TeradataMlException.
 
EXAMPLES:
    # Load necessary imports.
    >>> from langchain_teradata import TeradataVectorStore
 
    # Create an instance of a TeradataVectorStore.
    >>> vs = TeradataVectorStore.from_texts(name="vs",
                                            texts=["This is a sample text for testing.",
                                                   "Another sample text for the vector store.",
                                                   "Books talk about the positive user reviews."],
                                            embedding="amazon.titan-embed-text-v1",
                                            top_k=10)
 
    # Perform similarity search in the Vector Store for
    # the input question.
    >>> question = 'Are there any reviews about books?'
    >>> response = vs.similarity_search(question=question)
 
    # Example 1: Prepare a natural language response to the user
    #            using the input question and similarity_results
    #            provided by similarity_search().
 
    question='Did any one feel the book is thin?'
    similar_objects_list = response['similar_objects_list']
    >>> vs.prepare_response(question=question,
                            similarity_results=similar_objects_list)
 
    # Example 2: Perform batch similarity search in the Vector Store.
    # Creates a Vector Store.
    # Note this step is not needed if vector store already exists.
    >>> vs = TeradataVectorStore.from_datasets(name="vs",
                                               data = "valid_passages",
                                               data_columns = "passage",
                                               key_columns = "pid",
                                               embedding = "amazon.titan-embed-text-v1",
                                               top_k=10,
                                               search_algorithm="HNSW",
                                               vector_column="VectorIndex")
 
    # Perform batch similarity search in the Vector Store.
    >>> response = vs.similarity_search(batch_data="valid_passages",
                                        batch_id_column="pid",
                                        batch_query_column="passage")
 
    # Get the similarity results.
    from teradatagenai import VSApi
    >>> similar_objects_list = vs.get_batch_result(api_name=VSApi.SimilaritySearch)
 
    # Perform batch prepare response with temperature.
    >>> vs.prepare_response(similarity_results=similar_objects_list,
                            batch_data="valid_passages",
                            batch_id_column="pid",
                            batch_query_column="passage",
                            temperature=0.7)
 
    # Retrieve the batch prepare response.
    >>> similarity_results = vs.get_batch_result(api_name=VSApi.PrepareResponse)