langchain.js
    Preparing search index...

    Module @langchain/classic - v1.0.1

    @langchain/classic

    This package contains functionality from LangChain v0.x that has been moved out of the main langchain package as part of the v1.0 release. It exists to provide backward compatibility for existing applications while the core langchain package focuses on the essential building blocks for modern agent development.

    Use @langchain/classic if you:

    • Have existing code that uses legacy chains (e.g., LLMChain, ConversationalRetrievalQAChain, RetrievalQAChain)
    • Use the indexing API
    • Depend on functionality from @langchain/community that was previously re-exported from langchain
    • Are maintaining an existing application and not yet ready to migrate to the new createAgent API

    For new projects, use langchain v1.0 instead. The new APIs provide:

    • createAgent: A cleaner, more powerful way to build agents with middleware support
    • Better performance: Optimized for modern agent workflows
    • Focused API surface: Less complexity, easier to learn
    • Active development: New features and improvements will focus on v1.0 APIs

    See the LangChain v1.0 release notes for more information.

    npm install @langchain/classic
    

    This package requires @langchain/core as a peer dependency:

    npm install @langchain/core
    

    All chain implementations from v0.x, including:

    • LLMChain - Basic chain for calling an LLM with a prompt template
    • ConversationalRetrievalQAChain - Chain for conversational question-answering over documents
    • RetrievalQAChain - Chain for question-answering over documents without conversation memory
    • StuffDocumentsChain - Chain for stuffing documents into a prompt
    • MapReduceDocumentsChain - Chain for map-reduce operations over documents
    • RefineDocumentsChain - Chain for iterative refinement over documents
    • And many more...

    The RecordManager and related indexing functionality for managing document updates in vector stores.

    Re-exports from @langchain/community that were previously available in the main langchain package.

    Various utilities and abstractions that have been replaced by better alternatives in v1.0.

    If you're upgrading to langchain v1.0 but want to keep using legacy functionality:

    1. Install @langchain/classic:

      npm install @langchain/classic
      
    2. Update your imports:

      // Before (v0.x)
      import { LLMChain } from "langchain/chains";
      import { ConversationalRetrievalQAChain } from "langchain/chains";

      // After (v1.0)
      import { LLMChain } from "@langchain/classic/chains";
      import { ConversationalRetrievalQAChain } from "@langchain/classic/chains";

      Or if you imported from the root:

      // Before (v0.x)
      import { LLMChain } from "langchain";

      // After (v1.0)
      import { LLMChain } from "@langchain/classic";

    For new development, we recommend using createAgent instead of legacy chains.

    Example migration from LLMChain:

    // Before (using LLMChain)
    import { LLMChain } from "@langchain/classic/chains";
    import { ChatOpenAI } from "@langchain/openai";
    import { PromptTemplate } from "@langchain/core/prompts";

    const model = new ChatOpenAI({ model: "gpt-4" });
    const prompt = PromptTemplate.fromTemplate(
    "What is a good name for a company that makes {product}?"
    );
    const chain = new LLMChain({ llm: model, prompt });
    const result = await chain.call({ product: "colorful socks" });

    // After (using createAgent)
    import { createAgent } from "langchain";

    const agent = createAgent({
    model: "openai:gpt-4",
    systemPrompt: "You are a creative assistant that helps name companies.",
    });

    const result = await agent.invoke({
    messages: [
    {
    role: "user",
    content: "What is a good name for a company that makes colorful socks?",
    },
    ],
    });

    For more complex migrations, see the migration guide.

    @langchain/classic will receive:

    • Bug fixes: Critical bugs will be fixed
    • Security updates: Security vulnerabilities will be patched
    • No new features: New functionality will focus on langchain v1.0 APIs

    This package is in maintenance mode. For new features and active development, use langchain v1.0.

    import { LLMChain } from "@langchain/classic/chains";
    import { ChatOpenAI } from "@langchain/openai";
    import { PromptTemplate } from "@langchain/core/prompts";

    const model = new ChatOpenAI({ model: "gpt-4" });

    const prompt = PromptTemplate.fromTemplate(
    "Tell me a {adjective} joke about {content}."
    );

    const chain = new LLMChain({ llm: model, prompt });

    const result = await chain.call({
    adjective: "funny",
    content: "chickens",
    });

    console.log(result.text);
    import { ConversationalRetrievalQAChain } from "@langchain/classic/chains";
    import { ChatOpenAI } from "@langchain/openai";
    import { OpenAIEmbeddings } from "@langchain/openai";
    import { MemoryVectorStore } from "langchain/vectorstores/memory";

    // Create vector store with documents
    const vectorStore = await MemoryVectorStore.fromTexts(
    ["Document 1 text...", "Document 2 text..."],
    [{ id: 1 }, { id: 2 }],
    new OpenAIEmbeddings()
    );

    // Create chain
    const model = new ChatOpenAI({ model: "gpt-4" });
    const chain = ConversationalRetrievalQAChain.fromLLM(
    model,
    vectorStore.asRetriever()
    );

    // Use chain
    const result = await chain.call({
    question: "What is in the documents?",
    chat_history: [],
    });

    console.log(result.text);

    For bug reports and issues, please open an issue on GitHub.

    For questions and discussions, join our Discord community.

    This package is licensed under the MIT License. See the LICENSE file for details.

    Modules

    agents
    agents/format_scratchpad/log
    agents/format_scratchpad/log_to_message
    agents/format_scratchpad/openai_functions
    agents/format_scratchpad/openai_tools
    agents/format_scratchpad/xml
    agents/load
    agents/openai/output_parser
    agents/react/output_parser
    agents/toolkits
    agents/toolkits/sql
    agents/xml/output_parser
    cache/file_system
    callbacks
    chains
    chains/combine_documents
    chains/combine_documents/reduce
    chains/graph_qa/cypher
    chains/history_aware_retriever
    chains/load
    chains/openai_functions
    chains/query_constructor
    chains/query_constructor/ir
    chains/retrieval
    chains/sql_db
    chat_models/universal
    document
    document_loaders/base
    document_loaders/fs/buffer
    document_loaders/fs/directory
    document_loaders/fs/json
    document_loaders/fs/multi_file
    document_loaders/fs/text
    document_transformers/openai_functions
    embeddings/cache_backed
    embeddings/fake
    evaluation
    experimental/autogpt
    experimental/babyagi
    experimental/chains/violation_of_expectations
    experimental/generative_agents
    experimental/masking
    experimental/openai_assistant
    experimental/openai_files
    experimental/plan_and_execute
    experimental/prompts/custom_format
    experimental/prompts/handlebars
    hub
    hub/node
    index
    indexes
    load
    load/serializable
    memory
    memory/chat_memory
    output_parsers
    output_parsers/expression
    retrievers/contextual_compression
    retrievers/document_compressors
    retrievers/document_compressors/chain_extract
    retrievers/document_compressors/embeddings_filter
    retrievers/ensemble
    retrievers/hyde
    retrievers/matryoshka_retriever
    retrievers/multi_query
    retrievers/multi_vector
    retrievers/parent_document
    retrievers/score_threshold
    retrievers/self_query
    retrievers/self_query/functional
    retrievers/time_weighted
    schema/prompt_template
    schema/query_constructor
    smith
    sql_db
    storage/encoder_backed
    storage/file_system
    storage/in_memory
    stores/doc/base
    stores/doc/in_memory
    stores/file/in_memory
    stores/file/node
    stores/message/in_memory
    text_splitter
    tools
    tools/chain
    tools/render
    tools/retriever
    tools/sql
    tools/webbrowser
    util/document
    util/math
    util/time
    vectorstores/memory