Skip to content

Commit f3d7152

Browse files
authored
style(core): more refs work (#33664)
1 parent dff37f6 commit f3d7152

File tree

6 files changed

+31
-30
lines changed

6 files changed

+31
-30
lines changed

libs/core/langchain_core/document_loaders/base.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BaseLoader(ABC): # noqa: B024
2727
"""Interface for Document Loader.
2828
2929
Implementations should implement the lazy-loading method using generators
30-
to avoid loading all Documents into memory at once.
30+
to avoid loading all documents into memory at once.
3131
3232
`load` is provided just for user convenience and should not be overridden.
3333
"""
@@ -53,9 +53,11 @@ async def aload(self) -> list[Document]:
5353
def load_and_split(
5454
self, text_splitter: TextSplitter | None = None
5555
) -> list[Document]:
56-
"""Load Documents and split into chunks. Chunks are returned as `Document`.
56+
"""Load `Document` and split into chunks. Chunks are returned as `Document`.
5757
58-
Do not override this method. It should be considered to be deprecated!
58+
!!! danger
59+
60+
Do not override this method. It should be considered to be deprecated!
5961
6062
Args:
6163
text_splitter: `TextSplitter` instance to use for splitting documents.
@@ -135,7 +137,7 @@ def lazy_parse(self, blob: Blob) -> Iterator[Document]:
135137
"""
136138

137139
def parse(self, blob: Blob) -> list[Document]:
138-
"""Eagerly parse the blob into a `Document` or `Document` objects.
140+
"""Eagerly parse the blob into a `Document` or list of `Document` objects.
139141
140142
This is a convenience method for interactive development environment.
141143

libs/core/langchain_core/document_loaders/blob_loaders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class BlobLoader(ABC):
2828
def yield_blobs(
2929
self,
3030
) -> Iterable[Blob]:
31-
"""A lazy loader for raw data represented by LangChain's Blob object.
31+
"""A lazy loader for raw data represented by LangChain's `Blob` object.
3232
3333
Returns:
3434
A generator over blobs

libs/core/langchain_core/document_loaders/langsmith.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515

1616
class LangSmithLoader(BaseLoader):
17-
"""Load LangSmith Dataset examples as Documents.
17+
"""Load LangSmith Dataset examples as `Document` objects.
1818
19-
Loads the example inputs as the Document page content and places the entire example
20-
into the Document metadata. This allows you to easily create few-shot example
21-
retrievers from the loaded documents.
19+
Loads the example inputs as the `Document` page content and places the entire
20+
example into the `Document` metadata. This allows you to easily create few-shot
21+
example retrievers from the loaded documents.
2222
23-
??? note "Lazy load"
23+
??? note "Lazy loading example"
2424
2525
```python
2626
from langchain_core.document_loaders import LangSmithLoader
@@ -66,12 +66,11 @@ def __init__(
6666
format_content: Function for converting the content extracted from the example
6767
inputs into a string. Defaults to JSON-encoding the contents.
6868
example_ids: The IDs of the examples to filter by.
69-
as_of: The dataset version tag OR
70-
timestamp to retrieve the examples as of.
71-
Response examples will only be those that were present at the time
72-
of the tagged (or timestamped) version.
69+
as_of: The dataset version tag or timestamp to retrieve the examples as of.
70+
Response examples will only be those that were present at the time of
71+
the tagged (or timestamped) version.
7372
splits: A list of dataset splits, which are
74-
divisions of your dataset such as 'train', 'test', or 'validation'.
73+
divisions of your dataset such as `train`, `test`, or `validation`.
7574
Returns examples only from the specified splits.
7675
inline_s3_urls: Whether to inline S3 URLs.
7776
offset: The offset to start from.

libs/core/langchain_core/documents/base.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Blob(BaseMedia):
5151
help to decouple the development of data loaders from the downstream parsing of
5252
the raw data.
5353
54-
Inspired by: https://developer.mozilla.org/en-US/docs/Web/API/Blob
54+
Inspired by [Mozilla's `Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
5555
5656
Example: Initialize a blob from in-memory data
5757
@@ -103,7 +103,7 @@ class Blob(BaseMedia):
103103
"""
104104

105105
data: bytes | str | None = None
106-
"""Raw data associated with the blob."""
106+
"""Raw data associated with the `Blob`."""
107107
mimetype: str | None = None
108108
"""MimeType not to be confused with a file extension."""
109109
encoding: str = "utf-8"
@@ -123,7 +123,7 @@ class Blob(BaseMedia):
123123
def source(self) -> str | None:
124124
"""The source location of the blob as string if known otherwise none.
125125
126-
If a path is associated with the blob, it will default to the path location.
126+
If a path is associated with the `Blob`, it will default to the path location.
127127
128128
Unless explicitly set via a metadata field called `"source"`, in which
129129
case that value will be used instead.
@@ -211,13 +211,13 @@ def from_path(
211211
Args:
212212
path: Path-like object to file to be read
213213
encoding: Encoding to use if decoding the bytes into a string
214-
mime_type: If provided, will be set as the mime-type of the data
215-
guess_type: If `True`, the mimetype will be guessed from the file extension,
216-
if a mime-type was not provided
217-
metadata: Metadata to associate with the blob
214+
mime_type: If provided, will be set as the MIME type of the data
215+
guess_type: If `True`, the MIME type will be guessed from the file
216+
extension, if a mime-type was not provided
217+
metadata: Metadata to associate with the `Blob`
218218
219219
Returns:
220-
Blob instance
220+
`Blob` instance
221221
"""
222222
if mime_type is None and guess_type:
223223
mimetype = mimetypes.guess_type(path)[0] if guess_type else None
@@ -243,17 +243,17 @@ def from_data(
243243
path: str | None = None,
244244
metadata: dict | None = None,
245245
) -> Blob:
246-
"""Initialize the blob from in-memory data.
246+
"""Initialize the `Blob` from in-memory data.
247247
248248
Args:
249-
data: The in-memory data associated with the blob
249+
data: The in-memory data associated with the `Blob`
250250
encoding: Encoding to use if decoding the bytes into a string
251-
mime_type: If provided, will be set as the mime-type of the data
251+
mime_type: If provided, will be set as the MIME type of the data
252252
path: If provided, will be set as the source from which the data came
253-
metadata: Metadata to associate with the blob
253+
metadata: Metadata to associate with the `Blob`
254254
255255
Returns:
256-
Blob instance
256+
`Blob` instance
257257
"""
258258
return cls(
259259
data=data,

libs/core/langchain_core/load/dump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def default(obj: Any) -> Any:
1717
obj: The object to serialize to json if it is a Serializable object.
1818
1919
Returns:
20-
A json serializable object or a SerializedNotImplemented object.
20+
A JSON serializable object or a SerializedNotImplemented object.
2121
"""
2222
if isinstance(obj, Serializable):
2323
return obj.to_json()

libs/core/langchain_core/load/serializable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def to_json(self) -> SerializedConstructor | SerializedNotImplemented:
194194
ValueError: If the class has deprecated attributes.
195195
196196
Returns:
197-
A json serializable object or a `SerializedNotImplemented` object.
197+
A JSON serializable object or a `SerializedNotImplemented` object.
198198
"""
199199
if not self.is_lc_serializable():
200200
return self.to_json_not_implemented()

0 commit comments

Comments
 (0)