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

Don't create a gcs storage client on every interaction with blobs #594

Open
david-gang opened this issue Nov 7, 2024 · 0 comments
Open

Comments

@david-gang
Copy link

The following code creates a client per function call at https://github.com/langchain-ai/langchain-google/blob/main/libs/vertexai/langchain_google_vertexai/_image_utils.py

 def _blob_from_gcs(self, gcs_uri: str) -> storage.Blob:
        """Gets image Blob from a Google Cloud Storage uri.

        Args:
            gcs_uri: Valid gcs uri.

        Raises:
            ValueError if there are more than one blob matching the uri.

        Returns:
            storage.Blob
        """

        gcs_client = storage.Client(project=self._project)
        blob = storage.Blob.from_string(gcs_uri, gcs_client)
        blob.reload(client=gcs_client)
        return blob

It would make more sense to make client as a property of ImageBytesLoader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant