Class ConversationalRetrievalChain

java.lang.Object
dev.langchain4j.chain.ConversationalRetrievalChain
All Implemented Interfaces:
Chain<String,String>

public class ConversationalRetrievalChain extends Object implements Chain<String,String>
A chain for conversing with a specified ChatLanguageModel based on the information retrieved by a specified ContentRetriever. Includes a default ChatMemory (a message window with maximum 10 messages), which can be overridden. You can fully customize RAG behavior by providing an instance of a RetrievalAugmentor, such as DefaultRetrievalAugmentor, or your own custom implementation.
Chains are not going to be developed further, it is recommended to use AiServices instead.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConversationalRetrievalChain(dev.langchain4j.model.chat.ChatLanguageModel chatLanguageModel, dev.langchain4j.memory.ChatMemory chatMemory, dev.langchain4j.model.input.PromptTemplate promptTemplate, dev.langchain4j.retriever.Retriever<dev.langchain4j.data.segment.TextSegment> retriever)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Please use another constructor with a new ContentRetriever instead.
    ConversationalRetrievalChain(dev.langchain4j.model.chat.ChatLanguageModel chatLanguageModel, dev.langchain4j.memory.ChatMemory chatMemory, dev.langchain4j.rag.content.retriever.ContentRetriever contentRetriever)
     
    ConversationalRetrievalChain(dev.langchain4j.model.chat.ChatLanguageModel chatLanguageModel, dev.langchain4j.memory.ChatMemory chatMemory, dev.langchain4j.rag.RetrievalAugmentor retrievalAugmentor)
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    execute(String query)
    Execute the chain step.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConversationalRetrievalChain

      public ConversationalRetrievalChain(dev.langchain4j.model.chat.ChatLanguageModel chatLanguageModel, dev.langchain4j.memory.ChatMemory chatMemory, dev.langchain4j.rag.content.retriever.ContentRetriever contentRetriever)
    • ConversationalRetrievalChain

      public ConversationalRetrievalChain(dev.langchain4j.model.chat.ChatLanguageModel chatLanguageModel, dev.langchain4j.memory.ChatMemory chatMemory, dev.langchain4j.rag.RetrievalAugmentor retrievalAugmentor)
    • ConversationalRetrievalChain

      @Deprecated(forRemoval=true) public ConversationalRetrievalChain(dev.langchain4j.model.chat.ChatLanguageModel chatLanguageModel, dev.langchain4j.memory.ChatMemory chatMemory, dev.langchain4j.model.input.PromptTemplate promptTemplate, dev.langchain4j.retriever.Retriever<dev.langchain4j.data.segment.TextSegment> retriever)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Please use another constructor with a new ContentRetriever instead.
  • Method Details