mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-24 03:52:10 +00:00
core: Add ruff rules D (docstring) (#29406)
This ensures that the code is properly documented: https://docs.astral.sh/ruff/rules/#pydocstyle-d Related to #21983
This commit is contained in:
committed by
GitHub
parent
64df60e690
commit
88b4233fa1
@@ -1,4 +1,6 @@
|
||||
"""**Output** classes are used to represent the output of a language model call
|
||||
"""Output classes.
|
||||
|
||||
**Output** classes are used to represent the output of a language model call
|
||||
and the output of a chat.
|
||||
|
||||
The top container for information is the `LLMResult` object. `LLMResult` is used by
|
||||
|
@@ -1,3 +1,5 @@
|
||||
"""Chat generation output classes."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Literal, Union
|
||||
@@ -71,15 +73,11 @@ class ChatGeneration(Generation):
|
||||
raise ValueError(msg) from e
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def get_lc_namespace(cls) -> list[str]:
|
||||
"""Get the namespace of the langchain object."""
|
||||
return ["langchain", "schema", "output"]
|
||||
|
||||
|
||||
class ChatGenerationChunk(ChatGeneration):
|
||||
"""ChatGeneration chunk, which can be concatenated with other
|
||||
ChatGeneration chunks.
|
||||
"""ChatGeneration chunk.
|
||||
|
||||
ChatGeneration chunks can be concatenated with other ChatGeneration chunks.
|
||||
"""
|
||||
|
||||
message: BaseMessageChunk
|
||||
@@ -88,14 +86,15 @@ class ChatGenerationChunk(ChatGeneration):
|
||||
type: Literal["ChatGenerationChunk"] = "ChatGenerationChunk" # type: ignore[assignment]
|
||||
"""Type is used exclusively for serialization purposes."""
|
||||
|
||||
@classmethod
|
||||
def get_lc_namespace(cls) -> list[str]:
|
||||
"""Get the namespace of the langchain object."""
|
||||
return ["langchain", "schema", "output"]
|
||||
|
||||
def __add__(
|
||||
self, other: Union[ChatGenerationChunk, list[ChatGenerationChunk]]
|
||||
) -> ChatGenerationChunk:
|
||||
"""Concatenate two ChatGenerationChunks.
|
||||
|
||||
Args:
|
||||
other: The other ChatGenerationChunk or list of ChatGenerationChunks to
|
||||
concatenate.
|
||||
"""
|
||||
if isinstance(other, ChatGenerationChunk):
|
||||
generation_info = merge_dicts(
|
||||
self.generation_info or {},
|
||||
|
@@ -1,3 +1,5 @@
|
||||
"""Chat result schema."""
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
@@ -1,3 +1,5 @@
|
||||
"""Generation output schema."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Literal, Optional
|
||||
@@ -41,19 +43,18 @@ class Generation(Serializable):
|
||||
|
||||
@classmethod
|
||||
def get_lc_namespace(cls) -> list[str]:
|
||||
"""Get the namespace of the langchain object."""
|
||||
"""Get the namespace of the langchain object.
|
||||
|
||||
Default namespace is ["langchain", "schema", "output"].
|
||||
"""
|
||||
return ["langchain", "schema", "output"]
|
||||
|
||||
|
||||
class GenerationChunk(Generation):
|
||||
"""Generation chunk, which can be concatenated with other Generation chunks."""
|
||||
|
||||
@classmethod
|
||||
def get_lc_namespace(cls) -> list[str]:
|
||||
"""Get the namespace of the langchain object."""
|
||||
return ["langchain", "schema", "output"]
|
||||
|
||||
def __add__(self, other: GenerationChunk) -> GenerationChunk:
|
||||
"""Concatenate two GenerationChunks."""
|
||||
if isinstance(other, GenerationChunk):
|
||||
generation_info = merge_dicts(
|
||||
self.generation_info or {},
|
||||
|
@@ -1,3 +1,5 @@
|
||||
"""LLMResult class."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from copy import deepcopy
|
||||
|
@@ -1,3 +1,5 @@
|
||||
"""RunInfo class."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from uuid import UUID
|
||||
|
Reference in New Issue
Block a user