From 923ce84aa7f8f8b0ad16dc91e7f88d4eaefe5257 Mon Sep 17 00:00:00 2001 From: ccurme Date: Wed, 4 Sep 2024 17:10:15 -0400 Subject: [PATCH] robocorp[major]: upgrade pydantic (#26062) --- .../robocorp/langchain_robocorp/_common.py | 6 ++--- .../robocorp/langchain_robocorp/toolkits.py | 7 ++--- libs/partners/robocorp/poetry.lock | 14 +++++----- libs/partners/robocorp/pyproject.toml | 3 ++- .../robocorp/scripts/check_pydantic.sh | 27 ------------------- 5 files changed, 15 insertions(+), 42 deletions(-) delete mode 100755 libs/partners/robocorp/scripts/check_pydantic.sh diff --git a/libs/partners/robocorp/langchain_robocorp/_common.py b/libs/partners/robocorp/langchain_robocorp/_common.py index 6db05d1b5c224..3ff0b4af2292f 100644 --- a/libs/partners/robocorp/langchain_robocorp/_common.py +++ b/libs/partners/robocorp/langchain_robocorp/_common.py @@ -2,13 +2,13 @@ from dataclasses import dataclass from typing import Any, Dict, List, Set, Tuple, Union, cast -from langchain_core.pydantic_v1 import ( +from langchain_core.utils.json_schema import dereference_refs +from langchain_core.utils.pydantic import is_basemodel_instance +from pydantic import ( BaseModel, Field, create_model, ) -from langchain_core.utils.json_schema import dereference_refs -from langchain_core.utils.pydantic import is_basemodel_instance @dataclass(frozen=True) diff --git a/libs/partners/robocorp/langchain_robocorp/toolkits.py b/libs/partners/robocorp/langchain_robocorp/toolkits.py index aaf1863cfaf63..3e9f9dfbfbfe0 100644 --- a/libs/partners/robocorp/langchain_robocorp/toolkits.py +++ b/libs/partners/robocorp/langchain_robocorp/toolkits.py @@ -13,11 +13,11 @@ from langchain_core.language_models.chat_models import BaseChatModel from langchain_core.output_parsers import StrOutputParser from langchain_core.prompts import PromptTemplate -from langchain_core.pydantic_v1 import BaseModel, Field, PrivateAttr, create_model from langchain_core.runnables import Runnable, RunnablePassthrough from langchain_core.tools import BaseTool, StructuredTool, Tool from langchain_core.tracers.context import _tracing_v2_is_enabled from langsmith import Client +from pydantic import BaseModel, ConfigDict, Field, PrivateAttr, create_model from langchain_robocorp._common import ( get_param_fields, @@ -110,8 +110,9 @@ class ActionServerToolkit(BaseModel): """Enable reporting Langsmith trace to Action Server runs""" _run_details: dict = PrivateAttr({}) - class Config: - arbitrary_types_allowed = True + model_config = ConfigDict( + arbitrary_types_allowed=True, + ) def get_tools( self, diff --git a/libs/partners/robocorp/poetry.lock b/libs/partners/robocorp/poetry.lock index f12c3192e344c..315f706a0c1de 100644 --- a/libs/partners/robocorp/poetry.lock +++ b/libs/partners/robocorp/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "annotated-types" @@ -11,9 +11,6 @@ files = [ {file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"}, ] -[package.dependencies] -typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""} - [[package]] name = "certifi" version = "2024.7.4" @@ -229,10 +226,10 @@ files = [ [[package]] name = "langchain-core" -version = "0.2.24" +version = "0.2.38" description = "Building applications with LLMs through composability" optional = false -python-versions = ">=3.8.1,<4.0" +python-versions = ">=3.9,<4.0" files = [] develop = true @@ -246,6 +243,7 @@ pydantic = [ ] PyYAML = ">=5.3" tenacity = "^8.1.0,!=8.4.0" +typing-extensions = ">=4.7" [package.source] type = "directory" @@ -870,5 +868,5 @@ watchmedo = ["PyYAML (>=3.10)"] [metadata] lock-version = "2.0" -python-versions = ">=3.8.1,<4.0" -content-hash = "6b4489fb9ed4fe0871e64ef8ad93a9122a801824811cfeeebb6a42f3d666d50e" +python-versions = ">=3.9,<4.0" +content-hash = "a684f0e24648e9106bbb7d79554a71fca47235b61961159872a5d72267406aab" diff --git a/libs/partners/robocorp/pyproject.toml b/libs/partners/robocorp/pyproject.toml index d10b336be27ad..6cf85e16b834e 100644 --- a/libs/partners/robocorp/pyproject.toml +++ b/libs/partners/robocorp/pyproject.toml @@ -18,10 +18,11 @@ disallow_untyped_defs = "True" "Source Code" = "https://github.com/langchain-ai/langchain/tree/master/libs/partners/robocorp" [tool.poetry.dependencies] -python = ">=3.8.1,<4.0" +python = ">=3.9,<4.0" langchain-core = ">=0.2.24,<0.3" requests = "^2.31.0" types-requests = "^2.31.0.6" +pydantic = ">=2,<3" [tool.ruff.lint] select = [ "E", "F", "I", "T201",] diff --git a/libs/partners/robocorp/scripts/check_pydantic.sh b/libs/partners/robocorp/scripts/check_pydantic.sh deleted file mode 100755 index 06b5bb81ae236..0000000000000 --- a/libs/partners/robocorp/scripts/check_pydantic.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# -# This script searches for lines starting with "import pydantic" or "from pydantic" -# in tracked files within a Git repository. -# -# Usage: ./scripts/check_pydantic.sh /path/to/repository - -# Check if a path argument is provided -if [ $# -ne 1 ]; then - echo "Usage: $0 /path/to/repository" - exit 1 -fi - -repository_path="$1" - -# Search for lines matching the pattern within the specified repository -result=$(git -C "$repository_path" grep -E '^import pydantic|^from pydantic') - -# Check if any matching lines were found -if [ -n "$result" ]; then - echo "ERROR: The following lines need to be updated:" - echo "$result" - echo "Please replace the code with an import from langchain_core.pydantic_v1." - echo "For example, replace 'from pydantic import BaseModel'" - echo "with 'from langchain_core.pydantic_v1 import BaseModel'" - exit 1 -fi