The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Fix incorrect code blocks in documentation (#9060)
Eugene Yurtsev67ca1875603b
diff --git a/libs/langchain/langchain/document_loaders/blob_loaders/file_system.py b/libs/langchain/langchain/document_loaders/blob_loaders/file_system.pyindex f4d7ec4ce9..aecc1d62f1 100644--- a/libs/langchain/langchain/document_loaders/blob_loaders/file_system.py+++ b/libs/langchain/langchain/document_loaders/blob_loaders/file_system.py@@ -74,26 +74,23 @@ class FileSystemBlobLoader(BlobLoader):Examples:- ... code-block:: python+ .. code-block:: python- # Recursively load all text files in a directory.- loader = FileSystemBlobLoader("/path/to/directory", glob="**/*.txt")+ # Recursively load all text files in a directory.+ loader = FileSystemBlobLoader("/path/to/directory", glob="**/*.txt")- # Recursively load all files in a directory, except for py or pyc files.- loader = FileSystemBlobLoader(- "/path/to/directory",- glob="**/*.txt",- exclude=["**/*.py", "**/*.pyc"]- )-- # Recursively load all non-hidden files in a directory.- loader = FileSystemBlobLoader("/path/to/directory", glob="**/[!.]*")-- # Load all files in a directory without recursion.- loader = FileSystemBlobLoader("/path/to/directory", glob="*")+ # Recursively load all non-hidden files in a directory.+ loader = FileSystemBlobLoader("/path/to/directory", glob="**/[!.]*")- # Load all files in a directory without recursion.+ # Load all files in a directory without recursion.+ loader = FileSystemBlobLoader("/path/to/directory", glob="*")+ # Recursively load all files in a directory, except for py or pyc files.+ loader = FileSystemBlobLoader(+ "/path/to/directory",+ glob="**/*.txt",+ exclude=["**/*.py", "**/*.pyc"]+ )"""if isinstance(path, Path):_path = pathdiff --git a/libs/langchain/langchain/document_loaders/generic.py b/libs/langchain/langchain/document_loaders/generic.pyindex 0625507b27..7dbfc6e1e6 100644--- a/libs/langchain/langchain/document_loaders/generic.py+++ b/libs/langchain/langchain/document_loaders/generic.py@@ -22,7 +22,7 @@ class GenericLoader(BaseLoader):Examples:- .. code-block:: python+ .. code-block:: pythonfrom langchain.document_loaders import GenericLoaderfrom langchain.document_loaders.blob_loaders import FileSystemBlobLoader@@ -39,7 +39,7 @@ class GenericLoader(BaseLoader):Example instantiations to change which files are loaded:- ... code-block:: python+ .. code-block:: python# Recursively load all text files in a directory.loader = GenericLoader.from_filesystem("/path/to/dir", glob="**/*.txt")@@ -52,7 +52,7 @@ class GenericLoader(BaseLoader):Example instantiations to change which parser is used:- ... code-block:: python+ .. code-block:: pythonfrom langchain.document_loaders.parsers.pdf import PyPDFParserdiff --git a/libs/langchain/langchain/document_loaders/parsers/language/language_parser.py b/libs/langchain/langchain/document_loaders/parsers/language/language_parser.pyindex 3b3928cd68..12a11380c8 100644--- a/libs/langchain/langchain/document_loaders/parsers/language/language_parser.py+++ b/libs/langchain/langchain/document_loaders/parsers/language/language_parser.py@@ -35,7 +35,7 @@ class LanguageParser(BaseBlobParser):Examples:- .. code-block:: python+ .. code-block:: pythonfrom langchain.text_splitter.Languagefrom langchain.document_loaders.generic import GenericLoader@@ -51,7 +51,7 @@ class LanguageParser(BaseBlobParser):Example instantiations to manually select the language:- ... code-block:: python+ .. code-block:: pythonfrom langchain.text_splitter import Language@@ -64,7 +64,7 @@ class LanguageParser(BaseBlobParser):Example instantiations to set number of lines threshold:- ... code-block:: python+ .. code-block:: pythonloader = GenericLoader.from_filesystem("./code",diff --git a/libs/langchain/langchain/retrievers/parent_document_retriever.py b/libs/langchain/langchain/retrievers/parent_document_retriever.pyindex ce69067134..f427b1f7b4 100644--- a/libs/langchain/langchain/retrievers/parent_document_retriever.py+++ b/libs/langchain/langchain/retrievers/parent_document_retriever.py@@ -30,31 +30,32 @@ class ParentDocumentRetriever(BaseRetriever):chunk.Examples:- ... code-block:: python-- # Imports- from langchain.vectorstores import Chroma- from langchain.embeddings import OpenAIEmbeddings- from langchain.text_splitter import RecursiveCharacterTextSplitter- from langchain.storage import InMemoryStore-- # This text splitter is used to create the parent documents- parent_splitter = RecursiveCharacterTextSplitter(chunk_size=2000)- # This text splitter is used to create the child documents- # It should create documents smaller than the parent- child_splitter = RecursiveCharacterTextSplitter(chunk_size=400)- # The vectorstore to use to index the child chunks- vectorstore = Chroma(embedding_function=OpenAIEmbeddings())- # The storage layer for the parent documents- store = InMemoryStore()-- # Initialize the retriever- retriever = ParentDocumentRetriever(- vectorstore=vectorstore,- docstore=store,- child_splitter=child_splitter,- parent_splitter=parent_splitter,- )++ .. code-block:: python++ # Imports+ from langchain.vectorstores import Chroma+ from langchain.embeddings import OpenAIEmbeddings+ from langchain.text_splitter import RecursiveCharacterTextSplitter+ from langchain.storage import InMemoryStore++ # This text splitter is used to create the parent documents+ parent_splitter = RecursiveCharacterTextSplitter(chunk_size=2000)+ # This text splitter is used to create the child documents+ # It should create documents smaller than the parent+ child_splitter = RecursiveCharacterTextSplitter(chunk_size=400)+ # The vectorstore to use to index the child chunks+ vectorstore = Chroma(embedding_function=OpenAIEmbeddings())+ # The storage layer for the parent documents+ store = InMemoryStore()++ # Initialize the retriever+ retriever = ParentDocumentRetriever(+ vectorstore=vectorstore,+ docstore=store,+ child_splitter=child_splitter,+ parent_splitter=parent_splitter,+ )"""vectorstore: VectorStorediff --git a/libs/langchain/langchain/storage/in_memory.py b/libs/langchain/langchain/storage/in_memory.pyindex 906d08e853..3350f75f4d 100644--- a/libs/langchain/langchain/storage/in_memory.py+++ b/libs/langchain/langchain/storage/in_memory.py@@ -16,7 +16,8 @@ class InMemoryStore(BaseStore[str, Any]):the key-value pairs.Examples:- ... code-block:: python++ .. code-block:: pythonfrom langchain.storage import InMemoryStorediff --git a/libs/langchain/langchain/tools/base.py b/libs/langchain/langchain/tools/base.pyindex f8607d5144..732940bd06 100644--- a/libs/langchain/langchain/tools/base.py+++ b/libs/langchain/langchain/tools/base.py@@ -663,7 +663,9 @@ class StructuredTool(BaseTool):The toolExamples:- ... code-block:: python++ .. code-block:: python+def add(a: int, b: int) -> int:\"\"\"Add two numbers\"\"\"return a + b