A generative AI engineer is building a multi-turn customer support bot using LangChain on Databricks. The bot must: (1) ground all answers strictly in internal company documentation stored in a Databricks Vector Search index, (2) maintain context across multiple conversation turns so users can ask follow-up questions like 'Tell me more about the second option you mentioned', and (3) return responses as concise plain text. Which combination of LangChain chain components is REQUIRED to fulfill all three requirements?
Show answer & explanation
Correct answer: B
WHY B is correct: All three requirements map to specific LangChain components. (1) Grounding in documentation requires a VectorStoreRetriever — it queries the Databricks Vector Search index with the current user question and returns relevant document chunks as context. (2) Multi-turn awareness requires injecting prior conversation turns into the prompt — this is achieved with ChatPromptTemplate that includes a MessagesPlaceholder slot for chat history (populated by a memory component or passed explicitly). (3) Plain text output requires StrOutputParser. The ChatModel (rather than a base LLM) is appropriate for conversational use cases because it accepts structured message types (system/human/AI).
WHY NOT A: A basic PromptTemplate + LLM + StrOutputParser chain has no retriever — it cannot ground answers in company documentation at all. LangChain LLMs do NOT automatically store state; memory must be explicitly configured. This option fails requirements 1 and 2.
WHY NOT C: MapReduceDocumentsChain is designed for processing a large set of documents by mapping over chunks and reducing to a final summary. It is not a conversational chain and does not manage multi-turn history. It would be used for document summarization, not real-time multi-turn QA.
WHY NOT D: Memory accumulates conversation history but does NOT provide access to the documentation vector store. If the user asks about a policy not yet discussed in the conversation, the memory-only chain cannot answer correctly. Retrieval is required for grounded answers — memory alone is insufficient.
WHY NOT E: A PromptTemplate + Retriever + LLM without history management fails requirement 2. A follow-up question like 'Tell me more about the second option you mentioned' requires context from the previous AI response to be meaningful. Without history, the model treats each turn as a fresh, independent question.