mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-09 13:00:34 +00:00
Fix incorrect code blocks in documentation (#9060)
Fixes incorrect code block syntax in doc strings.
This commit is contained in:
parent
46f3428cb3
commit
67ca187560
@ -74,26 +74,23 @@ class FileSystemBlobLoader(BlobLoader):
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
... code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
# Recursively load all text files in a directory.
|
# Recursively load all text files in a directory.
|
||||||
loader = FileSystemBlobLoader("/path/to/directory", glob="**/*.txt")
|
loader = FileSystemBlobLoader("/path/to/directory", glob="**/*.txt")
|
||||||
|
|
||||||
# Recursively load all files in a directory, except for py or pyc files.
|
# Recursively load all non-hidden files in a directory.
|
||||||
loader = FileSystemBlobLoader(
|
loader = FileSystemBlobLoader("/path/to/directory", glob="**/[!.]*")
|
||||||
"/path/to/directory",
|
|
||||||
glob="**/*.txt",
|
|
||||||
exclude=["**/*.py", "**/*.pyc"]
|
|
||||||
)
|
|
||||||
|
|
||||||
# Recursively load all non-hidden files in a directory.
|
# Load all files in a directory without recursion.
|
||||||
loader = FileSystemBlobLoader("/path/to/directory", glob="**/[!.]*")
|
loader = FileSystemBlobLoader("/path/to/directory", glob="*")
|
||||||
|
|
||||||
# Load all files in a directory without recursion.
|
|
||||||
loader = FileSystemBlobLoader("/path/to/directory", glob="*")
|
|
||||||
|
|
||||||
# Load all files in a directory without recursion.
|
|
||||||
|
|
||||||
|
# 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):
|
if isinstance(path, Path):
|
||||||
_path = path
|
_path = path
|
||||||
|
@ -22,7 +22,7 @@ class GenericLoader(BaseLoader):
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from langchain.document_loaders import GenericLoader
|
from langchain.document_loaders import GenericLoader
|
||||||
from langchain.document_loaders.blob_loaders import FileSystemBlobLoader
|
from langchain.document_loaders.blob_loaders import FileSystemBlobLoader
|
||||||
@ -39,7 +39,7 @@ class GenericLoader(BaseLoader):
|
|||||||
|
|
||||||
Example instantiations to change which files are loaded:
|
Example instantiations to change which files are loaded:
|
||||||
|
|
||||||
... code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
# Recursively load all text files in a directory.
|
# Recursively load all text files in a directory.
|
||||||
loader = GenericLoader.from_filesystem("/path/to/dir", glob="**/*.txt")
|
loader = GenericLoader.from_filesystem("/path/to/dir", glob="**/*.txt")
|
||||||
@ -52,7 +52,7 @@ class GenericLoader(BaseLoader):
|
|||||||
|
|
||||||
Example instantiations to change which parser is used:
|
Example instantiations to change which parser is used:
|
||||||
|
|
||||||
... code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from langchain.document_loaders.parsers.pdf import PyPDFParser
|
from langchain.document_loaders.parsers.pdf import PyPDFParser
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class LanguageParser(BaseBlobParser):
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from langchain.text_splitter.Language
|
from langchain.text_splitter.Language
|
||||||
from langchain.document_loaders.generic import GenericLoader
|
from langchain.document_loaders.generic import GenericLoader
|
||||||
@ -51,7 +51,7 @@ class LanguageParser(BaseBlobParser):
|
|||||||
|
|
||||||
Example instantiations to manually select the language:
|
Example instantiations to manually select the language:
|
||||||
|
|
||||||
... code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from langchain.text_splitter import Language
|
from langchain.text_splitter import Language
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ class LanguageParser(BaseBlobParser):
|
|||||||
|
|
||||||
Example instantiations to set number of lines threshold:
|
Example instantiations to set number of lines threshold:
|
||||||
|
|
||||||
... code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
loader = GenericLoader.from_filesystem(
|
loader = GenericLoader.from_filesystem(
|
||||||
"./code",
|
"./code",
|
||||||
|
@ -30,31 +30,32 @@ class ParentDocumentRetriever(BaseRetriever):
|
|||||||
chunk.
|
chunk.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
... code-block:: python
|
|
||||||
|
|
||||||
# Imports
|
.. code-block:: python
|
||||||
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
|
# Imports
|
||||||
parent_splitter = RecursiveCharacterTextSplitter(chunk_size=2000)
|
from langchain.vectorstores import Chroma
|
||||||
# This text splitter is used to create the child documents
|
from langchain.embeddings import OpenAIEmbeddings
|
||||||
# It should create documents smaller than the parent
|
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
||||||
child_splitter = RecursiveCharacterTextSplitter(chunk_size=400)
|
from langchain.storage import InMemoryStore
|
||||||
# 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
|
# This text splitter is used to create the parent documents
|
||||||
retriever = ParentDocumentRetriever(
|
parent_splitter = RecursiveCharacterTextSplitter(chunk_size=2000)
|
||||||
vectorstore=vectorstore,
|
# This text splitter is used to create the child documents
|
||||||
docstore=store,
|
# It should create documents smaller than the parent
|
||||||
child_splitter=child_splitter,
|
child_splitter = RecursiveCharacterTextSplitter(chunk_size=400)
|
||||||
parent_splitter=parent_splitter,
|
# 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: VectorStore
|
vectorstore: VectorStore
|
||||||
|
@ -16,7 +16,8 @@ class InMemoryStore(BaseStore[str, Any]):
|
|||||||
the key-value pairs.
|
the key-value pairs.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
... code-block:: python
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
from langchain.storage import InMemoryStore
|
from langchain.storage import InMemoryStore
|
||||||
|
|
||||||
|
@ -663,7 +663,9 @@ class StructuredTool(BaseTool):
|
|||||||
The tool
|
The tool
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
... code-block:: python
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
def add(a: int, b: int) -> int:
|
def add(a: int, b: int) -> int:
|
||||||
\"\"\"Add two numbers\"\"\"
|
\"\"\"Add two numbers\"\"\"
|
||||||
return a + b
|
return a + b
|
||||||
|
Loading…
Reference in New Issue
Block a user