Skip to content

Commit

Permalink
prompty[major]: upgrade pydantic (#26056)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccurme authored Sep 4, 2024
1 parent 6e85350 commit c5d4dfe
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 81 deletions.
56 changes: 8 additions & 48 deletions libs/partners/prompty/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion libs/partners/prompty/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ license = "MIT"
"Release Notes" = "https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain-prompty%3D%3D0%22&expanded=true"

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
python = ">=3.9,<4.0"
langchain-core = "^0.2.36"
pyyaml = "^6.0.1"
types-pyyaml = "^6.0.12.20240311"
pydantic = ">=2,<3"

[tool.poetry.group.test]
optional = true
Expand Down
27 changes: 0 additions & 27 deletions libs/partners/prompty/scripts/check_pydantic.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from langchain_core.callbacks import AsyncCallbackHandler, BaseCallbackHandler
from langchain_core.messages import BaseMessage
from langchain_core.pydantic_v1 import BaseModel
from pydantic import BaseModel


class BaseFakeCallbackHandler(BaseModel):
Expand Down Expand Up @@ -259,7 +259,8 @@ def on_retriever_error(
) -> Any:
self.on_retriever_error_common()

def __deepcopy__(self, memo: dict) -> "FakeCallbackHandler":
# Overriding since BaseModel has __deepcopy__ method as well
def __deepcopy__(self, memo: dict) -> "FakeCallbackHandler": # type: ignore
return self


Expand Down Expand Up @@ -391,5 +392,6 @@ async def on_text(
) -> None:
self.on_text_common()

def __deepcopy__(self, memo: dict) -> "FakeAsyncCallbackHandler":
# Overriding since BaseModel has __deepcopy__ method as well
def __deepcopy__(self, memo: dict) -> "FakeAsyncCallbackHandler": # type: ignore
return self
2 changes: 1 addition & 1 deletion libs/partners/prompty/tests/unit_tests/fake_chat_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def _call(
run_manager: Optional[CallbackManagerForLLMRun] = None,
**kwargs: Any,
) -> str:
return json.dumps([message.dict() for message in messages])
return json.dumps([message.model_dump() for message in messages])

async def _agenerate(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from langchain.tools import tool
from langchain_core.language_models import FakeListLLM
from langchain_core.messages import AIMessage, HumanMessage
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_core.utils.function_calling import convert_to_openai_function
from pydantic import BaseModel, Field

import langchain_prompty

Expand Down

0 comments on commit c5d4dfe

Please sign in to comment.