Skip to content

Commit

Permalink
core[patch]: Sort Config attributes (#25127)
Browse files Browse the repository at this point in the history
This PR does an aesthetic sort of the config object attributes. This
will make it a bit easier to go back and forth between pydantic v1 and
pydantic v2 on the 0.3.x branch
  • Loading branch information
eyurtsev authored Aug 7, 2024
1 parent 46a4771 commit 4d28c70
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ class _VectorStoreExampleSelector(BaseExampleSelector, BaseModel, ABC):
"""Extra arguments passed to similarity_search function of the vectorstore."""

class Config:
"""Configuration for this pydantic object."""

extra = Extra.forbid
arbitrary_types_allowed = True
extra = Extra.forbid

@staticmethod
def _example_to_text(
Expand Down
2 changes: 0 additions & 2 deletions libs/core/langchain_core/language_models/chat_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ def raise_deprecation(cls, values: Dict) -> Dict:
return values

class Config:
"""Configuration for this pydantic object."""

arbitrary_types_allowed = True

# --- Runnable methods ---
Expand Down
2 changes: 0 additions & 2 deletions libs/core/langchain_core/language_models/llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,6 @@ class BaseLLM(BaseLanguageModel[str], ABC):
"""[DEPRECATED]"""

class Config:
"""Configuration for this pydantic object."""

arbitrary_types_allowed = True

@root_validator(pre=True)
Expand Down
2 changes: 0 additions & 2 deletions libs/core/langchain_core/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ def clear(self) -> None:
""" # noqa: E501

class Config:
"""Configuration for this pydantic object."""

arbitrary_types_allowed = True

@property
Expand Down
2 changes: 0 additions & 2 deletions libs/core/langchain_core/prompts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ def is_lc_serializable(cls) -> bool:
return True

class Config:
"""Configuration for this pydantic object."""

arbitrary_types_allowed = True

@property
Expand Down
12 changes: 3 additions & 9 deletions libs/core/langchain_core/prompts/few_shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ class _FewShotPromptTemplateMixin(BaseModel):
Either this or examples should be provided."""

class Config:
"""Configuration for this pydantic object."""

extra = Extra.forbid
arbitrary_types_allowed = True
extra = Extra.forbid

@root_validator(pre=True)
def check_examples_and_selector(cls, values: Dict) -> Dict:
Expand Down Expand Up @@ -161,10 +159,8 @@ def template_is_valid(cls, values: Dict) -> Dict:
return values

class Config:
"""Configuration for this pydantic object."""

extra = Extra.forbid
arbitrary_types_allowed = True
extra = Extra.forbid

def format(self, **kwargs: Any) -> str:
"""Format the prompt with inputs generating a string.
Expand Down Expand Up @@ -370,10 +366,8 @@ def is_lc_serializable(cls) -> bool:
return False

class Config:
"""Configuration for this pydantic object."""

extra = Extra.forbid
arbitrary_types_allowed = True
extra = Extra.forbid

def format_messages(self, **kwargs: Any) -> List[BaseMessage]:
"""Format kwargs into a list of messages.
Expand Down
4 changes: 1 addition & 3 deletions libs/core/langchain_core/prompts/few_shot_with_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ def template_is_valid(cls, values: Dict) -> Dict:
return values

class Config:
"""Configuration for this pydantic object."""

extra = Extra.forbid
arbitrary_types_allowed = True
extra = Extra.forbid

def _get_examples(self, **kwargs: Any) -> List[dict]:
if self.examples is not None:
Expand Down
2 changes: 0 additions & 2 deletions libs/core/langchain_core/retrievers.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ def _get_relevant_documents(self, query: str) -> List[Document]:
""" # noqa: E501

class Config:
"""Configuration for this pydantic object."""

arbitrary_types_allowed = True

_new_arg_supported: bool = False
Expand Down
2 changes: 0 additions & 2 deletions libs/core/langchain_core/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,6 @@ def __init__(self, **kwargs: Any) -> None:
super().__init__(**kwargs)

class Config(Serializable.Config):
"""Configuration for this pydantic object."""

arbitrary_types_allowed = True

@property
Expand Down
2 changes: 0 additions & 2 deletions libs/core/langchain_core/vectorstores/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,8 +1208,6 @@ class VectorStoreRetriever(BaseRetriever):
)

class Config:
"""Configuration for this pydantic object."""

arbitrary_types_allowed = True

@root_validator(pre=True)
Expand Down

0 comments on commit 4d28c70

Please sign in to comment.