From 484e90896fc7afe452c9cfac49b46797574bea6a Mon Sep 17 00:00:00 2001 From: Leonid Kuligin Date: Mon, 19 Feb 2024 13:11:49 +0100 Subject: [PATCH] Move VertexAI from preview and bump the SDK version --- .../langchain_google_vertexai/_enums.py | 2 +- .../langchain_google_vertexai/chat_models.py | 14 ++++++------- .../functions_utils.py | 6 ++++-- .../langchain_google_vertexai/llms.py | 8 +++---- libs/vertexai/poetry.lock | 21 +++++++++---------- libs/vertexai/pyproject.toml | 4 ++-- .../tests/unit_tests/test_chat_models.py | 4 ++-- 7 files changed, 30 insertions(+), 29 deletions(-) diff --git a/libs/vertexai/langchain_google_vertexai/_enums.py b/libs/vertexai/langchain_google_vertexai/_enums.py index 00a2abaa..860140eb 100644 --- a/libs/vertexai/langchain_google_vertexai/_enums.py +++ b/libs/vertexai/langchain_google_vertexai/_enums.py @@ -1,4 +1,4 @@ -from vertexai.preview.generative_models import ( # type: ignore +from vertexai.generative_models import ( # type: ignore HarmBlockThreshold, HarmCategory, ) diff --git a/libs/vertexai/langchain_google_vertexai/chat_models.py b/libs/vertexai/langchain_google_vertexai/chat_models.py index 096f1800..62613078 100644 --- a/libs/vertexai/langchain_google_vertexai/chat_models.py +++ b/libs/vertexai/langchain_google_vertexai/chat_models.py @@ -31,6 +31,13 @@ ) from langchain_core.outputs import ChatGeneration, ChatGenerationChunk, ChatResult from langchain_core.pydantic_v1 import root_validator +from vertexai.generative_models import ( # type: ignore + Candidate, + Content, + GenerativeModel, + Image, + Part, +) from vertexai.language_models import ( # type: ignore ChatMessage, ChatModel, @@ -39,13 +46,6 @@ CodeChatSession, InputOutputTextPair, ) -from vertexai.preview.generative_models import ( # type: ignore - Candidate, - Content, - GenerativeModel, - Image, - Part, -) from vertexai.preview.language_models import ( # type: ignore ChatModel as PreviewChatModel, ) diff --git a/libs/vertexai/langchain_google_vertexai/functions_utils.py b/libs/vertexai/langchain_google_vertexai/functions_utils.py index 1ae43dff..1524d671 100644 --- a/libs/vertexai/langchain_google_vertexai/functions_utils.py +++ b/libs/vertexai/langchain_google_vertexai/functions_utils.py @@ -8,10 +8,12 @@ from langchain_core.tools import BaseTool from langchain_core.utils.function_calling import FunctionDescription from langchain_core.utils.json_schema import dereference_refs -from vertexai.preview.generative_models import ( # type: ignore +from vertexai.generative_models import ( # type: ignore FunctionDeclaration, ) -from vertexai.preview.generative_models import Tool as VertexTool +from vertexai.generative_models import ( + Tool as VertexTool, +) def _format_pydantic_to_vertex_function( diff --git a/libs/vertexai/langchain_google_vertexai/llms.py b/libs/vertexai/langchain_google_vertexai/llms.py index 9b3099b4..3844c649 100644 --- a/libs/vertexai/langchain_google_vertexai/llms.py +++ b/libs/vertexai/langchain_google_vertexai/llms.py @@ -19,6 +19,10 @@ from langchain_core.language_models.llms import BaseLLM from langchain_core.outputs import Generation, GenerationChunk, LLMResult from langchain_core.pydantic_v1 import BaseModel, Field, root_validator +from vertexai.generative_models import ( # type: ignore[import-untyped] + GenerativeModel, + Image, +) from vertexai.language_models import ( # type: ignore[import-untyped] CodeGenerationModel, TextGenerationModel, @@ -26,10 +30,6 @@ from vertexai.language_models._language_models import ( # type: ignore[import-untyped] TextGenerationResponse, ) -from vertexai.preview.generative_models import ( # type: ignore[import-untyped] - GenerativeModel, - Image, -) from vertexai.preview.language_models import ( # type: ignore[import-untyped] ChatModel as PreviewChatModel, ) diff --git a/libs/vertexai/poetry.lock b/libs/vertexai/poetry.lock index 3c4fcc45..bcca2bc2 100644 --- a/libs/vertexai/poetry.lock +++ b/libs/vertexai/poetry.lock @@ -126,13 +126,13 @@ typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""} [[package]] name = "anyio" -version = "4.2.0" +version = "4.3.0" description = "High level compatibility layer for multiple asynchronous event loop implementations" optional = false python-versions = ">=3.8" files = [ - {file = "anyio-4.2.0-py3-none-any.whl", hash = "sha256:745843b39e829e108e518c489b31dc757de7d2131d53fac32bd8df268227bfee"}, - {file = "anyio-4.2.0.tar.gz", hash = "sha256:e1875bb4b4e2de1669f4bc7869b6d3f54231cdced71605e6e64c9be77e3be50f"}, + {file = "anyio-4.3.0-py3-none-any.whl", hash = "sha256:048e05d0f6caeed70d731f3db756d35dcc1f35747c8c403364a8332c630441b8"}, + {file = "anyio-4.3.0.tar.gz", hash = "sha256:f75253795a87df48568485fd18cdd2a3fa5c4f7c5be8e5e36637733fce06fed6"}, ] [package.dependencies] @@ -1739,7 +1739,6 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -2064,13 +2063,13 @@ files = [ [[package]] name = "types-requests" -version = "2.31.0.20240125" +version = "2.31.0.20240218" description = "Typing stubs for requests" optional = false python-versions = ">=3.8" files = [ - {file = "types-requests-2.31.0.20240125.tar.gz", hash = "sha256:03a28ce1d7cd54199148e043b2079cdded22d6795d19a2c2a6791a4b2b5e2eb5"}, - {file = "types_requests-2.31.0.20240125-py3-none-any.whl", hash = "sha256:9592a9a4cb92d6d75d9b491a41477272b710e021011a2a3061157e2fb1f1a5d1"}, + {file = "types-requests-2.31.0.20240218.tar.gz", hash = "sha256:f1721dba8385958f504a5386240b92de4734e047a08a40751c1654d1ac3349c5"}, + {file = "types_requests-2.31.0.20240218-py3-none-any.whl", hash = "sha256:a82807ec6ddce8f00fe0e949da6d6bc1fbf1715420218a9640d695f70a9e5a9b"}, ] [package.dependencies] @@ -2115,13 +2114,13 @@ files = [ [[package]] name = "urllib3" -version = "2.2.0" +version = "2.2.1" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.8" files = [ - {file = "urllib3-2.2.0-py3-none-any.whl", hash = "sha256:ce3711610ddce217e6d113a2732fafad960a03fd0318c91faa79481e35c11224"}, - {file = "urllib3-2.2.0.tar.gz", hash = "sha256:051d961ad0c62a94e50ecf1af379c3aba230c66c710493493560c0c223c49f20"}, + {file = "urllib3-2.2.1-py3-none-any.whl", hash = "sha256:450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d"}, + {file = "urllib3-2.2.1.tar.gz", hash = "sha256:d0570876c61ab9e520d776c38acbbb5b05a776d3f9ff98a5c8fd5162a444cf19"}, ] [package.extras] @@ -2277,4 +2276,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<4.0" -content-hash = "7dcee1d0db430e0a051dd8a919c0cb9706ba8e6e486345916a08770c7afa6ce4" +content-hash = "6e678decd64dda094cf9290e22bd2ded77d3d2be60d06455ff2d4d434f264509" diff --git a/libs/vertexai/pyproject.toml b/libs/vertexai/pyproject.toml index 402a4e4c..e8464a5d 100644 --- a/libs/vertexai/pyproject.toml +++ b/libs/vertexai/pyproject.toml @@ -12,8 +12,8 @@ license = "MIT" [tool.poetry.dependencies] python = ">=3.8.1,<4.0" -langchain-core = ">=0.1.7,<0.2" -google-cloud-aiplatform = "^1.39.0" +langchain-core = ">=0.1.23,<0.2" +google-cloud-aiplatform = "^1.42.1" google-cloud-storage = "^2.14.0" types-requests = "^2.31.0" types-protobuf = "^4.24.0.4" diff --git a/libs/vertexai/tests/unit_tests/test_chat_models.py b/libs/vertexai/tests/unit_tests/test_chat_models.py index 7e22af52..6cd5064b 100644 --- a/libs/vertexai/tests/unit_tests/test_chat_models.py +++ b/libs/vertexai/tests/unit_tests/test_chat_models.py @@ -19,10 +19,10 @@ HumanMessage, SystemMessage, ) -from vertexai.language_models import ChatMessage, InputOutputTextPair # type: ignore -from vertexai.preview.generative_models import ( # type: ignore +from vertexai.generative_models import ( # type: ignore Candidate, ) +from vertexai.language_models import ChatMessage, InputOutputTextPair # type: ignore from langchain_google_vertexai.chat_models import ( ChatVertexAI,