core[patch]: Sort Config attributes (#25127)

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
This commit is contained in:
Eugene Yurtsev
2024-08-06 22:53:50 -04:00
committed by GitHub
parent 46a47710b0
commit 4d28c70000
10 changed files with 5 additions and 29 deletions

View File

@@ -100,8 +100,6 @@ class BasePromptTemplate(
return True
class Config:
"""Configuration for this pydantic object."""
arbitrary_types_allowed = True
@property

View File

@@ -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:
@@ -161,10 +159,8 @@ class FewShotPromptTemplate(_FewShotPromptTemplateMixin, StringPromptTemplate):
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.
@@ -370,10 +366,8 @@ class FewShotChatMessagePromptTemplate(
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.

View File

@@ -86,10 +86,8 @@ class FewShotPromptWithTemplates(StringPromptTemplate):
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: