langchain-google-genai 2.0.11__tar.gz → 2.1.0__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.11 → langchain_google_genai-2.1.0}/PKG-INFO +2 -2
- {langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/chat_models.py +46 -8
- {langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/pyproject.toml +3 -3
- {langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/LICENSE +0 -0
- {langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/README.md +0 -0
- {langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/__init__.py +0 -0
- {langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/_common.py +0 -0
- {langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/_enums.py +0 -0
- {langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/_function_utils.py +0 -0
- {langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/_genai_extension.py +0 -0
- {langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/_image_utils.py +0 -0
- {langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/embeddings.py +0 -0
- {langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/genai_aqa.py +0 -0
- {langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/google_vector_store.py +0 -0
- {langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/llms.py +0 -0
- {langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/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.1.0
|
|
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
|
Requires-Dist: filetype (>=1.2.0,<2.0.0)
|
|
15
15
|
Requires-Dist: google-ai-generativelanguage (>=0.6.16,<0.7.0)
|
|
16
|
-
Requires-Dist: langchain-core (>=0.3.
|
|
16
|
+
Requires-Dist: langchain-core (>=0.3.43,<0.4.0)
|
|
17
17
|
Requires-Dist: pydantic (>=2,<3)
|
|
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
|
{langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/chat_models.py
RENAMED
|
@@ -67,7 +67,7 @@ from langchain_core.messages.ai import UsageMetadata
|
|
|
67
67
|
from langchain_core.messages.tool import invalid_tool_call, tool_call, tool_call_chunk
|
|
68
68
|
from langchain_core.output_parsers.base import OutputParserLike
|
|
69
69
|
from langchain_core.output_parsers.openai_tools import (
|
|
70
|
-
|
|
70
|
+
JsonOutputKeyToolsParser,
|
|
71
71
|
PydanticToolsParser,
|
|
72
72
|
parse_tool_calls,
|
|
73
73
|
)
|
|
@@ -89,7 +89,7 @@ from tenacity import (
|
|
|
89
89
|
stop_after_attempt,
|
|
90
90
|
wait_exponential,
|
|
91
91
|
)
|
|
92
|
-
from typing_extensions import Self
|
|
92
|
+
from typing_extensions import Self, is_typeddict
|
|
93
93
|
|
|
94
94
|
from langchain_google_genai._common import (
|
|
95
95
|
GoogleGenerativeAIError,
|
|
@@ -110,6 +110,9 @@ from langchain_google_genai._image_utils import ImageBytesLoader
|
|
|
110
110
|
|
|
111
111
|
from . import _genai_extension as genaix
|
|
112
112
|
|
|
113
|
+
WARNED_STRUCTURED_OUTPUT_JSON_MODE = False
|
|
114
|
+
|
|
115
|
+
|
|
113
116
|
logger = logging.getLogger(__name__)
|
|
114
117
|
|
|
115
118
|
|
|
@@ -1177,6 +1180,16 @@ class ChatGoogleGenerativeAI(_BaseGoogleGenerativeAI, BaseChatModel):
|
|
|
1177
1180
|
elif functions:
|
|
1178
1181
|
formatted_tools = [convert_to_genai_function_declarations(functions)]
|
|
1179
1182
|
|
|
1183
|
+
filtered_messages = []
|
|
1184
|
+
for message in messages:
|
|
1185
|
+
if isinstance(message, HumanMessage) and not message.content:
|
|
1186
|
+
warnings.warn(
|
|
1187
|
+
"HumanMessage with empty content was removed to prevent API error"
|
|
1188
|
+
)
|
|
1189
|
+
else:
|
|
1190
|
+
filtered_messages.append(message)
|
|
1191
|
+
messages = filtered_messages
|
|
1192
|
+
|
|
1180
1193
|
system_instruction, history = _parse_chat_history(
|
|
1181
1194
|
messages,
|
|
1182
1195
|
convert_system_message_to_human=self.convert_system_message_to_human,
|
|
@@ -1245,14 +1258,33 @@ class ChatGoogleGenerativeAI(_BaseGoogleGenerativeAI, BaseChatModel):
|
|
|
1245
1258
|
) -> Runnable[LanguageModelInput, Union[Dict, BaseModel]]:
|
|
1246
1259
|
if kwargs:
|
|
1247
1260
|
raise ValueError(f"Received unsupported arguments {kwargs}")
|
|
1261
|
+
tool_name = _get_tool_name(schema) # type: ignore[arg-type]
|
|
1248
1262
|
if isinstance(schema, type) and is_basemodel_subclass_safe(schema):
|
|
1249
1263
|
parser: OutputParserLike = PydanticToolsParser(
|
|
1250
1264
|
tools=[schema], first_tool_only=True
|
|
1251
1265
|
)
|
|
1252
1266
|
else:
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1267
|
+
global WARNED_STRUCTURED_OUTPUT_JSON_MODE
|
|
1268
|
+
warnings.warn(
|
|
1269
|
+
"ChatGoogleGenerativeAI.with_structured_output with dict schema has "
|
|
1270
|
+
"changed recently to align with behavior of other LangChain chat "
|
|
1271
|
+
"models. More context: "
|
|
1272
|
+
"https://github.com/langchain-ai/langchain-google/pull/772"
|
|
1273
|
+
)
|
|
1274
|
+
WARNED_STRUCTURED_OUTPUT_JSON_MODE = True
|
|
1275
|
+
parser = JsonOutputKeyToolsParser(key_name=tool_name, first_tool_only=True)
|
|
1276
|
+
tool_choice = tool_name if self._supports_tool_choice else None
|
|
1277
|
+
try:
|
|
1278
|
+
llm = self.bind_tools(
|
|
1279
|
+
[schema],
|
|
1280
|
+
tool_choice=tool_choice,
|
|
1281
|
+
ls_structured_output_format={
|
|
1282
|
+
"kwargs": {"method": "function_calling"},
|
|
1283
|
+
"schema": convert_to_openai_tool(schema),
|
|
1284
|
+
},
|
|
1285
|
+
)
|
|
1286
|
+
except Exception:
|
|
1287
|
+
llm = self.bind_tools([schema], tool_choice=tool_choice)
|
|
1256
1288
|
if include_raw:
|
|
1257
1289
|
parser_with_fallback = RunnablePassthrough.assign(
|
|
1258
1290
|
parsed=itemgetter("raw") | parser, parsing_error=lambda _: None
|
|
@@ -1315,7 +1347,13 @@ class ChatGoogleGenerativeAI(_BaseGoogleGenerativeAI, BaseChatModel):
|
|
|
1315
1347
|
|
|
1316
1348
|
|
|
1317
1349
|
def _get_tool_name(
|
|
1318
|
-
tool: Union[_ToolDict, GoogleTool],
|
|
1350
|
+
tool: Union[_ToolDict, GoogleTool, Dict],
|
|
1319
1351
|
) -> str:
|
|
1320
|
-
|
|
1321
|
-
|
|
1352
|
+
try:
|
|
1353
|
+
genai_tool = tool_to_dict(convert_to_genai_function_declarations([tool]))
|
|
1354
|
+
return [f["name"] for f in genai_tool["function_declarations"]][0] # type: ignore[index]
|
|
1355
|
+
except ValueError as e: # other TypedDict
|
|
1356
|
+
if is_typeddict(tool):
|
|
1357
|
+
return convert_to_openai_tool(cast(Dict, tool))["function"]["name"]
|
|
1358
|
+
else:
|
|
1359
|
+
raise e
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "langchain-google-genai"
|
|
3
|
-
version = "2.0
|
|
3
|
+
version = "2.1.0"
|
|
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.43"
|
|
16
16
|
google-ai-generativelanguage = "^0.6.16"
|
|
17
17
|
pydantic = ">=2,<3"
|
|
18
18
|
filetype = "^1.2.0"
|
|
@@ -28,7 +28,7 @@ syrupy = "^4.0.2"
|
|
|
28
28
|
pytest-watcher = "^0.3.4"
|
|
29
29
|
pytest-asyncio = "^0.21.1"
|
|
30
30
|
numpy = "^1.26.2"
|
|
31
|
-
langchain-tests = "0.3.
|
|
31
|
+
langchain-tests = "0.3.14"
|
|
32
32
|
|
|
33
33
|
[tool.codespell]
|
|
34
34
|
ignore-words-list = "rouge"
|
|
File without changes
|
|
File without changes
|
{langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/__init__.py
RENAMED
|
File without changes
|
{langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/_common.py
RENAMED
|
File without changes
|
{langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/_enums.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/embeddings.py
RENAMED
|
File without changes
|
{langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/genai_aqa.py
RENAMED
|
File without changes
|
|
File without changes
|
{langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/llms.py
RENAMED
|
File without changes
|
{langchain_google_genai-2.0.11 → langchain_google_genai-2.1.0}/langchain_google_genai/py.typed
RENAMED
|
File without changes
|