langchain-google-genai 1.0.8__tar.gz → 1.0.9__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-1.0.8 → langchain_google_genai-1.0.9}/PKG-INFO +2 -2
- {langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/_function_utils.py +12 -6
- {langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/chat_models.py +35 -4
- {langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/pyproject.toml +2 -2
- {langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/LICENSE +0 -0
- {langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/README.md +0 -0
- {langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/__init__.py +0 -0
- {langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/_common.py +0 -0
- {langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/_enums.py +0 -0
- {langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/_genai_extension.py +0 -0
- {langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/_image_utils.py +0 -0
- {langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/embeddings.py +0 -0
- {langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/genai_aqa.py +0 -0
- {langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/google_vector_store.py +0 -0
- {langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/llms.py +0 -0
- {langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/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: 1.0.
|
|
3
|
+
Version: 1.0.9
|
|
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.7.0,<0.8.0)
|
|
16
|
-
Requires-Dist: langchain-core (>=0.2.
|
|
16
|
+
Requires-Dist: langchain-core (>=0.2.32,<0.3)
|
|
17
17
|
Requires-Dist: pillow (>=10.1.0,<11.0.0) ; extra == "images"
|
|
18
18
|
Project-URL: Repository, https://github.com/langchain-ai/langchain-google
|
|
19
19
|
Project-URL: Source Code, https://github.com/langchain-ai/langchain-google/tree/main/libs/genai
|
|
@@ -116,11 +116,13 @@ def _format_json_schema_to_gapic(schema: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
116
116
|
return converted_schema
|
|
117
117
|
|
|
118
118
|
|
|
119
|
-
def _dict_to_gapic_schema(schema: Dict[str, Any]) -> gapic.Schema:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
def _dict_to_gapic_schema(schema: Dict[str, Any]) -> Optional[gapic.Schema]:
|
|
120
|
+
if schema:
|
|
121
|
+
dereferenced_schema = dereference_refs(schema)
|
|
122
|
+
formatted_schema = _format_json_schema_to_gapic(dereferenced_schema)
|
|
123
|
+
json_schema = json.dumps(formatted_schema)
|
|
124
|
+
return gapic.Schema.from_json(json_schema)
|
|
125
|
+
return None
|
|
124
126
|
|
|
125
127
|
|
|
126
128
|
def _format_dict_to_function_declaration(
|
|
@@ -196,7 +198,11 @@ def _format_to_gapic_function_declaration(
|
|
|
196
198
|
function = cast(dict, tool)
|
|
197
199
|
function["parameters"] = {}
|
|
198
200
|
else:
|
|
199
|
-
|
|
201
|
+
if "parameters" in tool and tool["parameters"].get("properties"):
|
|
202
|
+
function = convert_to_openai_tool(cast(dict, tool))["function"]
|
|
203
|
+
else:
|
|
204
|
+
function = cast(dict, tool)
|
|
205
|
+
function["parameters"] = {}
|
|
200
206
|
return _format_dict_to_function_declaration(cast(FunctionDescription, function))
|
|
201
207
|
elif callable(tool):
|
|
202
208
|
return _format_base_tool_to_function_declaration(callable_as_lc_tool()(tool))
|
{langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/chat_models.py
RENAMED
|
@@ -32,8 +32,10 @@ import google.api_core
|
|
|
32
32
|
import proto # type: ignore[import]
|
|
33
33
|
import requests
|
|
34
34
|
from google.ai.generativelanguage_v1beta.types import (
|
|
35
|
+
Blob,
|
|
35
36
|
Candidate,
|
|
36
37
|
Content,
|
|
38
|
+
FileData,
|
|
37
39
|
FunctionCall,
|
|
38
40
|
FunctionResponse,
|
|
39
41
|
GenerateContentRequest,
|
|
@@ -42,6 +44,7 @@ from google.ai.generativelanguage_v1beta.types import (
|
|
|
42
44
|
Part,
|
|
43
45
|
SafetySetting,
|
|
44
46
|
ToolConfig,
|
|
47
|
+
VideoMetadata,
|
|
45
48
|
)
|
|
46
49
|
from google.generativeai.types import Tool as GoogleTool # type: ignore[import]
|
|
47
50
|
from google.generativeai.types.content_types import ( # type: ignore[import]
|
|
@@ -75,6 +78,7 @@ from langchain_core.outputs import ChatGeneration, ChatGenerationChunk, ChatResu
|
|
|
75
78
|
from langchain_core.pydantic_v1 import BaseModel, Field, SecretStr, root_validator
|
|
76
79
|
from langchain_core.runnables import Runnable, RunnablePassthrough
|
|
77
80
|
from langchain_core.utils import get_from_dict_or_env
|
|
81
|
+
from langchain_core.utils.pydantic import is_basemodel_subclass
|
|
78
82
|
from tenacity import (
|
|
79
83
|
before_sleep_log,
|
|
80
84
|
retry,
|
|
@@ -324,8 +328,35 @@ def _convert_to_parts(
|
|
|
324
328
|
)
|
|
325
329
|
img_url = img_url["url"]
|
|
326
330
|
parts.append(image_loader.load_part(img_url))
|
|
331
|
+
# Handle media type like LangChain.js
|
|
332
|
+
# https://github.com/langchain-ai/langchainjs/blob/e536593e2585f1dd7b0afc187de4d07cb40689ba/libs/langchain-google-common/src/utils/gemini.ts#L93-L106
|
|
333
|
+
elif part["type"] == "media":
|
|
334
|
+
if "mime_type" not in part:
|
|
335
|
+
raise ValueError(f"Missing mime_type in media part: {part}")
|
|
336
|
+
mime_type = part["mime_type"]
|
|
337
|
+
media_part = Part()
|
|
338
|
+
|
|
339
|
+
if "data" in part:
|
|
340
|
+
media_part.inline_data = Blob(
|
|
341
|
+
data=part["data"], mime_type=mime_type
|
|
342
|
+
)
|
|
343
|
+
elif "file_uri" in part:
|
|
344
|
+
media_part.file_data = FileData(
|
|
345
|
+
file_uri=part["file_uri"], mime_type=mime_type
|
|
346
|
+
)
|
|
347
|
+
else:
|
|
348
|
+
raise ValueError(
|
|
349
|
+
f"Media part must have either data or file_uri: {part}"
|
|
350
|
+
)
|
|
351
|
+
if "video_metadata" in part:
|
|
352
|
+
metadata = VideoMetadata(part["video_metadata"])
|
|
353
|
+
media_part.video_metadata = metadata
|
|
354
|
+
parts.append(media_part)
|
|
327
355
|
else:
|
|
328
|
-
raise ValueError(
|
|
356
|
+
raise ValueError(
|
|
357
|
+
f"Unrecognized message part type: {part['type']}. Only text, "
|
|
358
|
+
f"image_url, and media types are supported."
|
|
359
|
+
)
|
|
329
360
|
else:
|
|
330
361
|
# Yolo
|
|
331
362
|
logger.warning(
|
|
@@ -784,8 +815,8 @@ class ChatGoogleGenerativeAI(_BaseGoogleGenerativeAI, BaseChatModel):
|
|
|
784
815
|
|
|
785
816
|
""" # noqa: E501
|
|
786
817
|
|
|
787
|
-
client: Any = None #: :meta private:
|
|
788
|
-
async_client: Any = None #: :meta private:
|
|
818
|
+
client: Any = Field(default=None, exclude=True) #: :meta private:
|
|
819
|
+
async_client: Any = Field(default=None, exclude=True) #: :meta private:
|
|
789
820
|
google_api_key: Optional[SecretStr] = Field(default=None, alias="api_key")
|
|
790
821
|
"""Google AI API key.
|
|
791
822
|
|
|
@@ -1153,7 +1184,7 @@ class ChatGoogleGenerativeAI(_BaseGoogleGenerativeAI, BaseChatModel):
|
|
|
1153
1184
|
) -> Runnable[LanguageModelInput, Union[Dict, BaseModel]]:
|
|
1154
1185
|
if kwargs:
|
|
1155
1186
|
raise ValueError(f"Received unsupported arguments {kwargs}")
|
|
1156
|
-
if isinstance(schema, type) and
|
|
1187
|
+
if isinstance(schema, type) and is_basemodel_subclass(schema):
|
|
1157
1188
|
parser: OutputParserLike = PydanticToolsParser(
|
|
1158
1189
|
tools=[schema], first_tool_only=True
|
|
1159
1190
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "langchain-google-genai"
|
|
3
|
-
version = "1.0.
|
|
3
|
+
version = "1.0.9"
|
|
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.2.
|
|
15
|
+
langchain-core = ">=0.2.32,<0.3"
|
|
16
16
|
google-generativeai = "^0.7.0"
|
|
17
17
|
pillow = { version = "^10.1.0", optional = true }
|
|
18
18
|
|
|
File without changes
|
|
File without changes
|
{langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/__init__.py
RENAMED
|
File without changes
|
{langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/_common.py
RENAMED
|
File without changes
|
{langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/_enums.py
RENAMED
|
File without changes
|
|
File without changes
|
{langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/_image_utils.py
RENAMED
|
File without changes
|
{langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/embeddings.py
RENAMED
|
File without changes
|
{langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/genai_aqa.py
RENAMED
|
File without changes
|
|
File without changes
|
{langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/llms.py
RENAMED
|
File without changes
|
{langchain_google_genai-1.0.8 → langchain_google_genai-1.0.9}/langchain_google_genai/py.typed
RENAMED
|
File without changes
|