Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prompty[major]: upgrade pydantic #26056

Merged
merged 7 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading