langchain-google-genai 2.0.3__tar.gz → 2.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of langchain-google-genai might be problematic. Click here for more details.
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/PKG-INFO +2 -3
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/README.md +0 -1
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/_image_utils.py +15 -21
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/chat_models.py +0 -32
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/pyproject.toml +2 -2
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/LICENSE +0 -0
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/__init__.py +0 -0
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/_common.py +0 -0
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/_enums.py +0 -0
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/_function_utils.py +0 -0
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/_genai_extension.py +0 -0
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/embeddings.py +0 -0
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/genai_aqa.py +0 -0
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/google_vector_store.py +0 -0
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/llms.py +0 -0
- {langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: langchain-google-genai
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.4
|
|
4
4
|
Summary: An integration package connecting Google's genai package and LangChain
|
|
5
5
|
Home-page: https://github.com/langchain-ai/langchain-google
|
|
6
6
|
License: MIT
|
|
@@ -13,7 +13,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
14
|
Provides-Extra: images
|
|
15
15
|
Requires-Dist: google-generativeai (>=0.8.0,<0.9.0)
|
|
16
|
-
Requires-Dist: langchain-core (>=0.3.
|
|
16
|
+
Requires-Dist: langchain-core (>=0.3.15,<0.4)
|
|
17
17
|
Requires-Dist: pillow (>=10.1.0,<11.0.0) ; extra == "images"
|
|
18
18
|
Requires-Dist: pydantic (>=2,<3)
|
|
19
19
|
Project-URL: Repository, https://github.com/langchain-ai/langchain-google
|
|
@@ -82,7 +82,6 @@ The value of `image_url` can be any of the following:
|
|
|
82
82
|
|
|
83
83
|
- A public image URL
|
|
84
84
|
- An accessible gcs file (e.g., "gcs://path/to/file.png")
|
|
85
|
-
- A local file path
|
|
86
85
|
- A base64 encoded image (e.g., `data:image/png;base64,abcd124`)
|
|
87
86
|
- A PIL image
|
|
88
87
|
|
{langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/_image_utils.py
RENAMED
|
@@ -25,7 +25,6 @@ class ImageBytesLoader:
|
|
|
25
25
|
|
|
26
26
|
Currently supported:
|
|
27
27
|
- B64 Encoded image string
|
|
28
|
-
- Local file path
|
|
29
28
|
- URL
|
|
30
29
|
"""
|
|
31
30
|
|
|
@@ -35,7 +34,6 @@ class ImageBytesLoader:
|
|
|
35
34
|
Args:
|
|
36
35
|
image_string: Can be either:
|
|
37
36
|
- B64 Encoded image string
|
|
38
|
-
- Local file path
|
|
39
37
|
- URL
|
|
40
38
|
|
|
41
39
|
Returns:
|
|
@@ -51,12 +49,17 @@ class ImageBytesLoader:
|
|
|
51
49
|
return self._bytes_from_url(image_string)
|
|
52
50
|
|
|
53
51
|
if route == Route.LOCAL_FILE:
|
|
52
|
+
raise ValueError(
|
|
53
|
+
"Loading from local files is no longer supported for security reasons. "
|
|
54
|
+
"Please pass in images as Google Cloud Storage URI, "
|
|
55
|
+
"b64 encoded image string (data:image/...), or valid image url."
|
|
56
|
+
)
|
|
54
57
|
return self._bytes_from_file(image_string)
|
|
55
58
|
|
|
56
59
|
raise ValueError(
|
|
57
60
|
"Image string must be one of: Google Cloud Storage URI, "
|
|
58
|
-
"b64 encoded image string (data:image/...), valid image url
|
|
59
|
-
f"
|
|
61
|
+
"b64 encoded image string (data:image/...), or valid image url."
|
|
62
|
+
f"Instead got '{image_string}'."
|
|
60
63
|
)
|
|
61
64
|
|
|
62
65
|
def load_part(self, image_string: str) -> Part:
|
|
@@ -65,7 +68,6 @@ class ImageBytesLoader:
|
|
|
65
68
|
Args:
|
|
66
69
|
image_string: Can be either:
|
|
67
70
|
- B64 Encoded image string
|
|
68
|
-
- Local file path
|
|
69
71
|
- URL
|
|
70
72
|
"""
|
|
71
73
|
route = self._route(image_string)
|
|
@@ -77,7 +79,12 @@ class ImageBytesLoader:
|
|
|
77
79
|
bytes_ = self._bytes_from_url(image_string)
|
|
78
80
|
|
|
79
81
|
if route == Route.LOCAL_FILE:
|
|
80
|
-
|
|
82
|
+
msg = (
|
|
83
|
+
"Loading from local files is no longer supported for security reasons. "
|
|
84
|
+
"Please specify images as Google Cloud Storage URI, "
|
|
85
|
+
"b64 encoded image string (data:image/...), or valid image url."
|
|
86
|
+
)
|
|
87
|
+
raise ValueError(msg)
|
|
81
88
|
|
|
82
89
|
inline_data: Dict[str, Any] = {"data": bytes_}
|
|
83
90
|
mime_type, _ = mimetypes.guess_type(image_string)
|
|
@@ -98,8 +105,8 @@ class ImageBytesLoader:
|
|
|
98
105
|
|
|
99
106
|
raise ValueError(
|
|
100
107
|
"Image string must be one of: "
|
|
101
|
-
"b64 encoded image string (data:image/...)
|
|
102
|
-
f"
|
|
108
|
+
"b64 encoded image string (data:image/...) or valid image url."
|
|
109
|
+
f" Instead got '{image_string}'."
|
|
103
110
|
)
|
|
104
111
|
|
|
105
112
|
def _bytes_from_b64(self, base64_image: str) -> bytes:
|
|
@@ -121,19 +128,6 @@ class ImageBytesLoader:
|
|
|
121
128
|
|
|
122
129
|
raise ValueError(f"Error in b64 encoded image. Must follow pattern: {pattern}")
|
|
123
130
|
|
|
124
|
-
def _bytes_from_file(self, file_path: str) -> bytes:
|
|
125
|
-
"""Gets image bytes from a local file path.
|
|
126
|
-
|
|
127
|
-
Args:
|
|
128
|
-
file_path: Existing file path.
|
|
129
|
-
|
|
130
|
-
Returns:
|
|
131
|
-
Image bytes
|
|
132
|
-
"""
|
|
133
|
-
with open(file_path, "rb") as image_file:
|
|
134
|
-
image_bytes = image_file.read()
|
|
135
|
-
return image_bytes
|
|
136
|
-
|
|
137
131
|
def _bytes_from_url(self, url: str) -> bytes:
|
|
138
132
|
"""Gets image bytes from a public url.
|
|
139
133
|
|
{langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/chat_models.py
RENAMED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
|
-
import base64
|
|
5
4
|
import json
|
|
6
5
|
import logging
|
|
7
|
-
import os
|
|
8
6
|
import uuid
|
|
9
7
|
import warnings
|
|
10
8
|
from io import BytesIO
|
|
@@ -30,7 +28,6 @@ import google.api_core
|
|
|
30
28
|
|
|
31
29
|
# TODO: remove ignore once the google package is published with types
|
|
32
30
|
import proto # type: ignore[import]
|
|
33
|
-
import requests
|
|
34
31
|
from google.ai.generativelanguage_v1beta import (
|
|
35
32
|
GenerativeServiceAsyncClient as v1betaGenerativeServiceAsyncClient,
|
|
36
33
|
)
|
|
@@ -288,35 +285,6 @@ def _load_image_from_gcs(path: str, project: Optional[str] = None) -> Image:
|
|
|
288
285
|
return PIL.Image.open(BytesIO(img_bytes))
|
|
289
286
|
|
|
290
287
|
|
|
291
|
-
def _url_to_pil(image_source: str) -> Image:
|
|
292
|
-
if PIL is None:
|
|
293
|
-
raise ImportError(
|
|
294
|
-
"PIL is required to load images. Please install it "
|
|
295
|
-
"with `pip install pillow`"
|
|
296
|
-
)
|
|
297
|
-
try:
|
|
298
|
-
if isinstance(image_source, IMAGE_TYPES):
|
|
299
|
-
return image_source # type: ignore[return-value]
|
|
300
|
-
elif _is_url(image_source):
|
|
301
|
-
if image_source.startswith("gs://"):
|
|
302
|
-
return _load_image_from_gcs(image_source)
|
|
303
|
-
response = requests.get(image_source)
|
|
304
|
-
response.raise_for_status()
|
|
305
|
-
return PIL.Image.open(BytesIO(response.content))
|
|
306
|
-
elif _is_b64(image_source):
|
|
307
|
-
_, encoded = image_source.split(",", 1)
|
|
308
|
-
data = base64.b64decode(encoded)
|
|
309
|
-
return PIL.Image.open(BytesIO(data))
|
|
310
|
-
elif os.path.exists(image_source):
|
|
311
|
-
return PIL.Image.open(image_source)
|
|
312
|
-
else:
|
|
313
|
-
raise ValueError(
|
|
314
|
-
"The provided string is not a valid URL, base64, or file path."
|
|
315
|
-
)
|
|
316
|
-
except Exception as e:
|
|
317
|
-
raise ValueError(f"Unable to process the provided image source: {e}")
|
|
318
|
-
|
|
319
|
-
|
|
320
288
|
def _convert_to_parts(
|
|
321
289
|
raw_content: Union[str, Sequence[Union[str, dict]]],
|
|
322
290
|
) -> List[Part]:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "langchain-google-genai"
|
|
3
|
-
version = "2.0.
|
|
3
|
+
version = "2.0.4"
|
|
4
4
|
description = "An integration package connecting Google's genai package and LangChain"
|
|
5
5
|
authors = []
|
|
6
6
|
readme = "README.md"
|
|
@@ -12,7 +12,7 @@ license = "MIT"
|
|
|
12
12
|
|
|
13
13
|
[tool.poetry.dependencies]
|
|
14
14
|
python = ">=3.9,<4.0"
|
|
15
|
-
langchain-core = ">=0.3.
|
|
15
|
+
langchain-core = ">=0.3.15,<0.4"
|
|
16
16
|
google-generativeai = "^0.8.0"
|
|
17
17
|
pillow = { version = "^10.1.0", optional = true }
|
|
18
18
|
pydantic = ">=2,<3"
|
|
File without changes
|
{langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/__init__.py
RENAMED
|
File without changes
|
{langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/_common.py
RENAMED
|
File without changes
|
{langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/_enums.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/embeddings.py
RENAMED
|
File without changes
|
{langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/genai_aqa.py
RENAMED
|
File without changes
|
|
File without changes
|
{langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/llms.py
RENAMED
|
File without changes
|
{langchain_google_genai-2.0.3 → langchain_google_genai-2.0.4}/langchain_google_genai/py.typed
RENAMED
|
File without changes
|