LangChain - Document LoadingYou want to load all '.txt' and '.md' files from 'content' folder using DirectoryLoader. How can you do this?ASet glob='*.txt,*.md' in one DirectoryLoaderBUse two DirectoryLoader instances, one for '*.txt' and one for '*.md', then combine resultsCUse glob='*.(txt|md)' in DirectoryLoaderDDirectoryLoader cannot load multiple extensions at onceCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand glob limitationsDirectoryLoader's glob does not support multiple patterns separated by commas or regex groups.Step 2: Use multiple loaders and combineCreate two loaders with '*.txt' and '*.md' separately, then merge their loaded documents.Final Answer:Use two DirectoryLoader instances, one for '*.txt' and one for '*.md', then combine results -> Option BQuick Check:Multiple extensions need multiple loaders [OK]Quick Trick: Use separate loaders for each file type, then merge [OK]Common Mistakes:Trying comma-separated globUsing regex in globAssuming single loader handles multiple extensions
Master "Document Loading" in LangChain9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More LangChain Quizzes Conversational RAG - Why conversation history improves RAG - Quiz 8hard Conversational RAG - Question reformulation with history - Quiz 4medium Embeddings and Vector Stores - Metadata filtering in vector stores - Quiz 12easy Embeddings and Vector Stores - Metadata filtering in vector stores - Quiz 14medium Embeddings and Vector Stores - Why embeddings capture semantic meaning - Quiz 15hard Embeddings and Vector Stores - Open-source embedding models - Quiz 1easy Embeddings and Vector Stores - Similarity search vs MMR retrieval - Quiz 4medium Embeddings and Vector Stores - Similarity search vs MMR retrieval - Quiz 14medium RAG Chain Construction - Multi-query retrieval for better recall - Quiz 4medium Text Splitting - Semantic chunking strategies - Quiz 13medium