From 137fced74f5a3a2136830d5f8737878c3bb5cae1 Mon Sep 17 00:00:00 2001 From: Leonid Kuligin Date: Mon, 26 Feb 2024 20:08:50 +0100 Subject: [PATCH 1/2] relese 0.0.6 (#32) --- libs/vertexai/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/vertexai/pyproject.toml b/libs/vertexai/pyproject.toml index 701397d2..ff0f6976 100644 --- a/libs/vertexai/pyproject.toml +++ b/libs/vertexai/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langchain-google-vertexai" -version = "0.0.6rc0" +version = "0.0.6" description = "An integration package connecting GoogleVertexAI and LangChain" authors = [] readme = "README.md" From 6421180677305a8548d70f23c6c0679b0de4eca5 Mon Sep 17 00:00:00 2001 From: Holt Skinner <13262395+holtskinner@users.noreply.github.com> Date: Tue, 27 Feb 2024 00:08:46 -0600 Subject: [PATCH 2/2] Fixed Spelling Error in `_bytes_from_gsc()` (#35) - Also simplified Blob Retrieval code --- .../langchain_google_vertexai/_image_utils.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/libs/vertexai/langchain_google_vertexai/_image_utils.py b/libs/vertexai/langchain_google_vertexai/_image_utils.py index 754fd4b3..06fb3e9e 100644 --- a/libs/vertexai/langchain_google_vertexai/_image_utils.py +++ b/libs/vertexai/langchain_google_vertexai/_image_utils.py @@ -46,7 +46,7 @@ def load_bytes(self, image_string: str) -> bytes: """ if image_string.startswith("gs://"): - return self._bytes_from_gsc(image_string) + return self._bytes_from_gcs(image_string) if image_string.startswith("data:image/"): return self._bytes_from_b64(image_string) @@ -115,8 +115,8 @@ def _bytes_from_url(self, url: str) -> bytes: return response.content - def _bytes_from_gsc(self, gcs_uri: str) -> bytes: - """Gets image bytes from a google cloud storage uri. + def _bytes_from_gcs(self, gcs_uri: str) -> bytes: + """Gets image bytes from a Google Cloud Storage uri. Args: gcs_uri: Valid gcs uri. @@ -129,15 +129,7 @@ def _bytes_from_gsc(self, gcs_uri: str) -> bytes: """ gcs_client = storage.Client(project=self._project) - - pieces = gcs_uri.split("/") - - blobs = list(gcs_client.list_blobs(pieces[2], prefix="/".join(pieces[3:]))) - - if len(blobs) > 1: - raise ValueError(f"Found more than one candidate for {gcs_uri}!") - - return blobs[0].download_as_bytes() + return storage.Blob.from_string(gcs_uri, gcs_client).download_as_bytes() def _is_url(self, url_string: str) -> bool: """Checks if a url is valid.