langchain-google-genai 1.0.6__py3-none-any.whl → 1.0.7__py3-none-any.whl
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/_function_utils.py +183 -80
- langchain_google_genai/chat_models.py +43 -6
- langchain_google_genai/embeddings.py +2 -0
- langchain_google_genai/llms.py +10 -3
- {langchain_google_genai-1.0.6.dist-info → langchain_google_genai-1.0.7.dist-info}/METADATA +3 -3
- {langchain_google_genai-1.0.6.dist-info → langchain_google_genai-1.0.7.dist-info}/RECORD +8 -8
- {langchain_google_genai-1.0.6.dist-info → langchain_google_genai-1.0.7.dist-info}/LICENSE +0 -0
- {langchain_google_genai-1.0.6.dist-info → langchain_google_genai-1.0.7.dist-info}/WHEEL +0 -0
|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
from typing import (
|
|
4
4
|
Any,
|
|
5
5
|
Callable,
|
|
6
|
+
Collection,
|
|
6
7
|
Dict,
|
|
7
8
|
List,
|
|
8
9
|
Literal,
|
|
@@ -15,13 +16,9 @@ from typing import (
|
|
|
15
16
|
)
|
|
16
17
|
|
|
17
18
|
import google.ai.generativelanguage as glm
|
|
18
|
-
from google.ai.generativelanguage import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
)
|
|
22
|
-
from google.ai.generativelanguage import (
|
|
23
|
-
Tool as GoogleTool,
|
|
24
|
-
)
|
|
19
|
+
from google.ai.generativelanguage import FunctionCallingConfig, FunctionDeclaration
|
|
20
|
+
from google.ai.generativelanguage import Tool as GoogleTool
|
|
21
|
+
from google.generativeai.types.content_types import ToolDict # type: ignore[import]
|
|
25
22
|
from langchain_core.pydantic_v1 import BaseModel
|
|
26
23
|
from langchain_core.tools import BaseTool
|
|
27
24
|
from langchain_core.tools import tool as callable_as_lc_tool
|
|
@@ -38,38 +35,74 @@ TYPE_ENUM = {
|
|
|
38
35
|
|
|
39
36
|
TYPE_ENUM_REVERSE = {v: k for k, v in TYPE_ENUM.items()}
|
|
40
37
|
|
|
38
|
+
|
|
39
|
+
class _ToolDictLike(TypedDict):
|
|
40
|
+
function_declarations: _FunctionDeclarationLikeList
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class _FunctionDeclarationDict(TypedDict):
|
|
44
|
+
name: str
|
|
45
|
+
description: str
|
|
46
|
+
parameters: Dict[str, Collection[str]]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class _ToolDict(TypedDict):
|
|
50
|
+
function_declarations: Sequence[_FunctionDeclarationDict]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# Info: This is a FunctionDeclaration(=fc).
|
|
41
54
|
_FunctionDeclarationLike = Union[
|
|
42
|
-
BaseTool, Type[BaseModel],
|
|
55
|
+
BaseTool, Type[BaseModel], FunctionDeclaration, Callable, Dict[str, Any]
|
|
43
56
|
]
|
|
44
57
|
|
|
58
|
+
# Info: This mean one tool.
|
|
59
|
+
_FunctionDeclarationLikeList = Sequence[_FunctionDeclarationLike]
|
|
45
60
|
|
|
46
|
-
|
|
47
|
-
|
|
61
|
+
|
|
62
|
+
# Info: This means one tool=Sequence of FunctionDeclaration
|
|
63
|
+
# The dict should be GoogleTool like. {"function_declarations": [ { "name": ...}.
|
|
64
|
+
# OpenAI like dict is not be accepted. {{'type': 'function', 'function': {'name': ...}
|
|
65
|
+
_ToolsType = Union[
|
|
66
|
+
GoogleTool,
|
|
67
|
+
ToolDict,
|
|
68
|
+
_ToolDictLike,
|
|
69
|
+
_FunctionDeclarationLikeList,
|
|
70
|
+
_FunctionDeclarationLike,
|
|
71
|
+
]
|
|
48
72
|
|
|
49
73
|
|
|
74
|
+
#
|
|
75
|
+
# Info: GoogleTool means function_declarations and proto.Message.
|
|
50
76
|
def convert_to_genai_function_declarations(
|
|
51
|
-
tool:
|
|
52
|
-
GoogleTool,
|
|
53
|
-
_ToolDict,
|
|
54
|
-
_FunctionDeclarationLike,
|
|
55
|
-
Sequence[_FunctionDeclarationLike],
|
|
56
|
-
],
|
|
77
|
+
tool: _ToolsType,
|
|
57
78
|
) -> GoogleTool:
|
|
58
|
-
if isinstance(tool, GoogleTool):
|
|
59
|
-
return cast(GoogleTool, tool)
|
|
60
|
-
if isinstance(tool, type) and issubclass(tool, BaseModel):
|
|
61
|
-
return GoogleTool(function_declarations=[_convert_to_genai_function(tool)])
|
|
62
|
-
if callable(tool):
|
|
63
|
-
return _convert_tool_to_genai_function(callable_as_lc_tool()(tool))
|
|
64
79
|
if isinstance(tool, list):
|
|
65
|
-
|
|
66
|
-
|
|
80
|
+
# multiple _FunctionDeclarationLike
|
|
81
|
+
return GoogleTool(
|
|
82
|
+
function_declarations=_convert_fc_likes_to_genai_function(tool)
|
|
83
|
+
)
|
|
84
|
+
elif isinstance(tool, (BaseTool, FunctionDeclaration)):
|
|
85
|
+
# single _FunctionDeclarationLike
|
|
86
|
+
return GoogleTool(
|
|
87
|
+
function_declarations=[_convert_fc_like_to_genai_function(tool)]
|
|
88
|
+
)
|
|
89
|
+
elif isinstance(tool, type) and issubclass(tool, BaseModel):
|
|
90
|
+
# single _FunctionDeclarationLike
|
|
91
|
+
return GoogleTool(
|
|
92
|
+
function_declarations=[_convert_fc_like_to_genai_function(tool)]
|
|
93
|
+
)
|
|
94
|
+
elif isinstance(tool, GoogleTool):
|
|
95
|
+
return cast(GoogleTool, tool)
|
|
96
|
+
elif callable(tool):
|
|
67
97
|
return GoogleTool(
|
|
68
98
|
function_declarations=[
|
|
69
|
-
|
|
70
|
-
]
|
|
99
|
+
_convert_tool_to_genai_function(callable_as_lc_tool()(tool))
|
|
100
|
+
]
|
|
71
101
|
)
|
|
72
|
-
|
|
102
|
+
elif isinstance(tool, dict):
|
|
103
|
+
return GoogleTool(function_declarations=_convert_dict_to_genai_functions(tool)) # type: ignore
|
|
104
|
+
else:
|
|
105
|
+
raise ValueError(f"Unsupported tool type {tool}")
|
|
73
106
|
|
|
74
107
|
|
|
75
108
|
def tool_to_dict(tool: GoogleTool) -> _ToolDict:
|
|
@@ -87,64 +120,112 @@ def tool_to_dict(tool: GoogleTool) -> _ToolDict:
|
|
|
87
120
|
if property_description:
|
|
88
121
|
property_dict["description"] = property_description
|
|
89
122
|
properties[property] = property_dict
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
"parameters": {"type": "object", "properties": properties},
|
|
94
|
-
}
|
|
123
|
+
name = function_declaration_proto.name
|
|
124
|
+
description = function_declaration_proto.description
|
|
125
|
+
parameters = {"type": "object", "properties": properties}
|
|
95
126
|
if function_declaration_proto.parameters.required:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
127
|
+
parameters["required"] = function_declaration_proto.parameters.required
|
|
128
|
+
function_declaration = _FunctionDeclarationDict(
|
|
129
|
+
name=name, description=description, parameters=parameters
|
|
130
|
+
)
|
|
99
131
|
function_declarations.append(function_declaration)
|
|
100
132
|
return {"function_declarations": function_declarations}
|
|
101
133
|
|
|
102
134
|
|
|
103
|
-
def
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
return FunctionDeclaration(**formatted_fc)
|
|
135
|
+
def _convert_fc_likes_to_genai_function(
|
|
136
|
+
fc_likes: _FunctionDeclarationLikeList,
|
|
137
|
+
) -> Sequence[FunctionDeclaration]:
|
|
138
|
+
if isinstance(fc_likes, list):
|
|
139
|
+
return [_convert_fc_like_to_genai_function(fc) for fc in fc_likes]
|
|
140
|
+
raise ValueError(f"Unsupported fc_likes type {fc_likes}")
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _convert_fc_like_to_genai_function(
|
|
144
|
+
fc_like: _FunctionDeclarationLike,
|
|
145
|
+
) -> FunctionDeclaration:
|
|
146
|
+
if isinstance(fc_like, BaseTool):
|
|
147
|
+
return _convert_tool_to_genai_function(fc_like)
|
|
148
|
+
elif isinstance(fc_like, type) and issubclass(fc_like, BaseModel):
|
|
149
|
+
return _convert_pydantic_to_genai_function(fc_like)
|
|
150
|
+
elif isinstance(fc_like, dict):
|
|
151
|
+
# TODO: add declaration_index
|
|
152
|
+
return _convert_dict_to_genai_function(fc_like)
|
|
153
|
+
elif callable(fc_like):
|
|
154
|
+
return _convert_tool_to_genai_function(callable_as_lc_tool()(fc_like))
|
|
125
155
|
else:
|
|
126
|
-
raise ValueError(f"Unsupported
|
|
156
|
+
raise ValueError(f"Unsupported fc_like type {fc_like}")
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _convert_tool_dict_to_genai_functions(
|
|
160
|
+
tool_dict: _ToolDictLike,
|
|
161
|
+
) -> Sequence[FunctionDeclaration]:
|
|
162
|
+
if "function_declarations" in tool_dict:
|
|
163
|
+
return _convert_dicts_to_genai_functions(tool_dict["function_declarations"]) # type: ignore
|
|
164
|
+
else:
|
|
165
|
+
raise ValueError(f"Unsupported function tool_dict type {tool_dict}")
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def _convert_dict_to_genai_functions(
|
|
169
|
+
function_declarations_dict: Dict[str, Any],
|
|
170
|
+
) -> Sequence[FunctionDeclaration]:
|
|
171
|
+
if "function_declarations" in function_declarations_dict:
|
|
172
|
+
# GoogleTool like
|
|
173
|
+
return [
|
|
174
|
+
_convert_dict_to_genai_function(fc, i)
|
|
175
|
+
for i, fc in enumerate(function_declarations_dict["function_declarations"])
|
|
176
|
+
]
|
|
177
|
+
d = function_declarations_dict
|
|
178
|
+
if "name" in d and "description" in d and "parameters" in d:
|
|
179
|
+
# _FunctionDeclarationDict
|
|
180
|
+
return [_convert_dict_to_genai_function(d)]
|
|
181
|
+
else:
|
|
182
|
+
# OpenAI like?
|
|
183
|
+
raise ValueError(f"Unsupported function call type {function_declarations_dict}")
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def _convert_dicts_to_genai_functions(
|
|
187
|
+
function_declaration_dicts: Sequence[Dict[str, Any]],
|
|
188
|
+
) -> Sequence[FunctionDeclaration]:
|
|
189
|
+
return [
|
|
190
|
+
_convert_dict_to_genai_function(function_declaration_dict, i)
|
|
191
|
+
for i, function_declaration_dict in enumerate(function_declaration_dicts)
|
|
192
|
+
]
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def _convert_dict_to_genai_function(
|
|
196
|
+
function_declaration_dict: Dict[str, Any], declaration_index: int = 0
|
|
197
|
+
) -> FunctionDeclaration:
|
|
198
|
+
formatted_fc = {
|
|
199
|
+
"name": function_declaration_dict.get("name", f"unknown-{declaration_index}"),
|
|
200
|
+
"description": function_declaration_dict.get("description", "no-description"),
|
|
201
|
+
}
|
|
202
|
+
if "parameters" in function_declaration_dict:
|
|
203
|
+
formatted_fc["parameters"] = {
|
|
204
|
+
"properties": {
|
|
205
|
+
k: {
|
|
206
|
+
"type_": TYPE_ENUM[v["type"]],
|
|
207
|
+
"description": v.get("description"),
|
|
208
|
+
}
|
|
209
|
+
for k, v in function_declaration_dict["parameters"][
|
|
210
|
+
"properties"
|
|
211
|
+
].items()
|
|
212
|
+
},
|
|
213
|
+
"required": function_declaration_dict.get("parameters", []).get(
|
|
214
|
+
"required", []
|
|
215
|
+
),
|
|
216
|
+
"type_": TYPE_ENUM[function_declaration_dict["parameters"]["type"]],
|
|
217
|
+
}
|
|
218
|
+
return FunctionDeclaration(**formatted_fc)
|
|
127
219
|
|
|
128
220
|
|
|
129
221
|
def _convert_tool_to_genai_function(tool: BaseTool) -> FunctionDeclaration:
|
|
130
222
|
if tool.args_schema:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
"properties": {
|
|
138
|
-
k: {
|
|
139
|
-
"type_": TYPE_ENUM[v["type"]],
|
|
140
|
-
"description": v.get("description"),
|
|
141
|
-
}
|
|
142
|
-
for k, v in schema["properties"].items()
|
|
143
|
-
},
|
|
144
|
-
"required": schema.get("required", []),
|
|
145
|
-
"type_": TYPE_ENUM[schema["type"]],
|
|
146
|
-
},
|
|
147
|
-
)
|
|
223
|
+
fc = tool.args_schema
|
|
224
|
+
if isinstance(fc, type) and issubclass(fc, BaseModel):
|
|
225
|
+
return _convert_pydantic_to_genai_function(
|
|
226
|
+
fc, tool_name=tool.name, tool_description=tool.description
|
|
227
|
+
)
|
|
228
|
+
raise ValueError(f"Unsupported function call type {fc}")
|
|
148
229
|
else:
|
|
149
230
|
return FunctionDeclaration(
|
|
150
231
|
name=tool.name,
|
|
@@ -161,24 +242,46 @@ def _convert_tool_to_genai_function(tool: BaseTool) -> FunctionDeclaration:
|
|
|
161
242
|
|
|
162
243
|
def _convert_pydantic_to_genai_function(
|
|
163
244
|
pydantic_model: Type[BaseModel],
|
|
245
|
+
tool_name: Optional[str] = None,
|
|
246
|
+
tool_description: Optional[str] = None,
|
|
164
247
|
) -> FunctionDeclaration:
|
|
165
248
|
schema = dereference_refs(pydantic_model.schema())
|
|
166
249
|
schema.pop("definitions", None)
|
|
167
|
-
|
|
168
|
-
name=schema
|
|
169
|
-
description=schema.get("description"
|
|
250
|
+
function_declaration = FunctionDeclaration(
|
|
251
|
+
name=tool_name if tool_name else schema.get("title"),
|
|
252
|
+
description=tool_description if tool_description else schema.get("description"),
|
|
170
253
|
parameters={
|
|
171
254
|
"properties": {
|
|
172
255
|
k: {
|
|
173
|
-
"type_":
|
|
256
|
+
"type_": _get_type_from_schema(v),
|
|
174
257
|
"description": v.get("description"),
|
|
175
258
|
}
|
|
176
259
|
for k, v in schema["properties"].items()
|
|
177
260
|
},
|
|
178
|
-
"required": schema
|
|
261
|
+
"required": schema.get("required", []),
|
|
179
262
|
"type_": TYPE_ENUM[schema["type"]],
|
|
180
263
|
},
|
|
181
264
|
)
|
|
265
|
+
return function_declaration
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def _get_type_from_schema(schema: Dict[str, Any]) -> int:
|
|
269
|
+
if "anyOf" in schema:
|
|
270
|
+
types = [_get_type_from_schema(sub_schema) for sub_schema in schema["anyOf"]]
|
|
271
|
+
types = [t for t in types if t is not None] # Remove None values
|
|
272
|
+
if types:
|
|
273
|
+
return types[-1] # TODO: update FunctionDeclaration and pass all types?
|
|
274
|
+
else:
|
|
275
|
+
pass
|
|
276
|
+
elif "type" in schema:
|
|
277
|
+
stype = str(schema["type"])
|
|
278
|
+
if stype in TYPE_ENUM:
|
|
279
|
+
return TYPE_ENUM[stype]
|
|
280
|
+
else:
|
|
281
|
+
pass
|
|
282
|
+
else:
|
|
283
|
+
pass
|
|
284
|
+
return TYPE_ENUM["string"] # Default to string if no valid types found
|
|
182
285
|
|
|
183
286
|
|
|
184
287
|
_ToolChoiceType = Union[
|
|
@@ -8,6 +8,7 @@ import os
|
|
|
8
8
|
import uuid
|
|
9
9
|
import warnings
|
|
10
10
|
from io import BytesIO
|
|
11
|
+
from operator import itemgetter
|
|
11
12
|
from typing import (
|
|
12
13
|
Any,
|
|
13
14
|
AsyncIterator,
|
|
@@ -19,6 +20,7 @@ from typing import (
|
|
|
19
20
|
Optional,
|
|
20
21
|
Sequence,
|
|
21
22
|
Tuple,
|
|
23
|
+
Type,
|
|
22
24
|
Union,
|
|
23
25
|
cast,
|
|
24
26
|
)
|
|
@@ -65,10 +67,15 @@ from langchain_core.messages import (
|
|
|
65
67
|
ToolMessage,
|
|
66
68
|
)
|
|
67
69
|
from langchain_core.messages.ai import UsageMetadata
|
|
68
|
-
from langchain_core.output_parsers.
|
|
70
|
+
from langchain_core.output_parsers.base import OutputParserLike
|
|
71
|
+
from langchain_core.output_parsers.openai_tools import (
|
|
72
|
+
JsonOutputToolsParser,
|
|
73
|
+
PydanticToolsParser,
|
|
74
|
+
parse_tool_calls,
|
|
75
|
+
)
|
|
69
76
|
from langchain_core.outputs import ChatGeneration, ChatGenerationChunk, ChatResult
|
|
70
|
-
from langchain_core.pydantic_v1 import Field, SecretStr, root_validator
|
|
71
|
-
from langchain_core.runnables import Runnable
|
|
77
|
+
from langchain_core.pydantic_v1 import BaseModel, Field, SecretStr, root_validator
|
|
78
|
+
from langchain_core.runnables import Runnable, RunnablePassthrough
|
|
72
79
|
from langchain_core.utils import get_from_dict_or_env
|
|
73
80
|
from tenacity import (
|
|
74
81
|
before_sleep_log,
|
|
@@ -612,8 +619,8 @@ class ChatGoogleGenerativeAI(_BaseGoogleGenerativeAI, BaseChatModel):
|
|
|
612
619
|
|
|
613
620
|
convert_system_message_to_human: bool = False
|
|
614
621
|
"""Whether to merge any leading SystemMessage into the following HumanMessage.
|
|
615
|
-
|
|
616
|
-
Gemini does not support system messages; any unsupported messages will
|
|
622
|
+
|
|
623
|
+
Gemini does not support system messages; any unsupported messages will
|
|
617
624
|
raise an error."""
|
|
618
625
|
|
|
619
626
|
class Config:
|
|
@@ -937,6 +944,33 @@ class ChatGoogleGenerativeAI(_BaseGoogleGenerativeAI, BaseChatModel):
|
|
|
937
944
|
)
|
|
938
945
|
return result.total_tokens
|
|
939
946
|
|
|
947
|
+
def with_structured_output(
|
|
948
|
+
self,
|
|
949
|
+
schema: Union[Dict, Type[BaseModel]],
|
|
950
|
+
*,
|
|
951
|
+
include_raw: bool = False,
|
|
952
|
+
**kwargs: Any,
|
|
953
|
+
) -> Runnable[LanguageModelInput, Union[Dict, BaseModel]]:
|
|
954
|
+
if kwargs:
|
|
955
|
+
raise ValueError(f"Received unsupported arguments {kwargs}")
|
|
956
|
+
if isinstance(schema, type) and issubclass(schema, BaseModel):
|
|
957
|
+
parser: OutputParserLike = PydanticToolsParser(
|
|
958
|
+
tools=[schema], first_tool_only=True
|
|
959
|
+
)
|
|
960
|
+
else:
|
|
961
|
+
parser = JsonOutputToolsParser()
|
|
962
|
+
llm = self.bind_tools([schema], tool_choice=False)
|
|
963
|
+
if include_raw:
|
|
964
|
+
parser_with_fallback = RunnablePassthrough.assign(
|
|
965
|
+
parsed=itemgetter("raw") | parser, parsing_error=lambda _: None
|
|
966
|
+
).with_fallbacks(
|
|
967
|
+
[RunnablePassthrough.assign(parsed=lambda _: None)],
|
|
968
|
+
exception_key="parsing_error",
|
|
969
|
+
)
|
|
970
|
+
return {"raw": llm} | parser_with_fallback
|
|
971
|
+
else:
|
|
972
|
+
return llm | parser
|
|
973
|
+
|
|
940
974
|
def bind_tools(
|
|
941
975
|
self,
|
|
942
976
|
tools: Sequence[Union[ToolDict, GoogleTool]],
|
|
@@ -963,7 +997,9 @@ class ChatGoogleGenerativeAI(_BaseGoogleGenerativeAI, BaseChatModel):
|
|
|
963
997
|
f"both:\n\n{tool_choice=}\n\n{tool_config=}"
|
|
964
998
|
)
|
|
965
999
|
# Bind dicts for easier serialization/deserialization.
|
|
966
|
-
genai_tools = [
|
|
1000
|
+
genai_tools = [
|
|
1001
|
+
tool_to_dict(convert_to_genai_function_declarations(tool)) for tool in tools
|
|
1002
|
+
]
|
|
967
1003
|
if tool_choice:
|
|
968
1004
|
all_names = [
|
|
969
1005
|
f["name"] # type: ignore[index]
|
|
@@ -971,4 +1007,5 @@ class ChatGoogleGenerativeAI(_BaseGoogleGenerativeAI, BaseChatModel):
|
|
|
971
1007
|
for f in t["function_declarations"]
|
|
972
1008
|
]
|
|
973
1009
|
tool_config = _tool_choice_to_tool_config(tool_choice, all_names)
|
|
1010
|
+
|
|
974
1011
|
return self.bind(tools=genai_tools, tool_config=tool_config, **kwargs)
|
|
@@ -86,6 +86,8 @@ class GoogleGenerativeAIEmbeddings(BaseModel, Embeddings):
|
|
|
86
86
|
google_api_key = get_from_dict_or_env(
|
|
87
87
|
values, "google_api_key", "GOOGLE_API_KEY"
|
|
88
88
|
)
|
|
89
|
+
if isinstance(google_api_key, SecretStr):
|
|
90
|
+
google_api_key = google_api_key.get_secret_value()
|
|
89
91
|
client_info = get_client_info("GoogleGenerativeAIEmbeddings")
|
|
90
92
|
|
|
91
93
|
values["client"] = build_generative_service(
|
langchain_google_genai/llms.py
CHANGED
|
@@ -325,9 +325,16 @@ class GoogleGenerativeAI(_BaseGoogleGenerativeAI, BaseLLM):
|
|
|
325
325
|
run_manager: Optional[CallbackManagerForLLMRun] = None,
|
|
326
326
|
**kwargs: Any,
|
|
327
327
|
) -> Iterator[GenerationChunk]:
|
|
328
|
-
generation_config =
|
|
329
|
-
|
|
330
|
-
|
|
328
|
+
generation_config = {
|
|
329
|
+
"stop_sequences": stop,
|
|
330
|
+
"temperature": self.temperature,
|
|
331
|
+
"top_p": self.top_p,
|
|
332
|
+
"top_k": self.top_k,
|
|
333
|
+
"max_output_tokens": self.max_output_tokens,
|
|
334
|
+
"candidate_count": self.n,
|
|
335
|
+
}
|
|
336
|
+
generation_config = generation_config | kwargs.get("generation_config", {})
|
|
337
|
+
|
|
331
338
|
for stream_resp in _completion_with_retry(
|
|
332
339
|
self,
|
|
333
340
|
prompt,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: langchain-google-genai
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
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
|
|
@@ -12,8 +12,8 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
14
|
Provides-Extra: images
|
|
15
|
-
Requires-Dist: google-generativeai (>=0.
|
|
16
|
-
Requires-Dist: langchain-core (>=0.2.
|
|
15
|
+
Requires-Dist: google-generativeai (>=0.7.0,<0.8.0)
|
|
16
|
+
Requires-Dist: langchain-core (>=0.2.9,<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
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
langchain_google_genai/__init__.py,sha256=Oji-S2KYWrku1wyQEskY84IOfY8MfRhujjJ4d7hbsk4,2758
|
|
2
2
|
langchain_google_genai/_common.py,sha256=ASlwE8hEbvOm55BVF_D4rf2nl7RYsnpsi5xbM6DW3Cc,1576
|
|
3
3
|
langchain_google_genai/_enums.py,sha256=KLPmxS1K83K4HjBIXFaXoL_sFEOv8Hq-2B2PDMKyDgo,197
|
|
4
|
-
langchain_google_genai/_function_utils.py,sha256
|
|
4
|
+
langchain_google_genai/_function_utils.py,sha256=-q26KAD_76am90O5-UFIuBRGiVZJygrEbXyNqxEUHCw,11918
|
|
5
5
|
langchain_google_genai/_genai_extension.py,sha256=ZwNwLV22RSf9LB7FOCLsoHzLlQDF-EQmRNYM1an2uSw,20769
|
|
6
6
|
langchain_google_genai/_image_utils.py,sha256=-0XgCMdYkvrIktFvUpy-2GPbFgfSVKZICawB2hiJzus,4999
|
|
7
|
-
langchain_google_genai/chat_models.py,sha256=
|
|
8
|
-
langchain_google_genai/embeddings.py,sha256=
|
|
7
|
+
langchain_google_genai/chat_models.py,sha256=8Mk11KBSuXnNp1Kn9o0pf8BLQvc0kMPZcvS1ooBFKNk,36526
|
|
8
|
+
langchain_google_genai/embeddings.py,sha256=7HjFvlDnH7Lww8MKkhskJTqoBbmC-CKl89pbQ7PvmnA,10042
|
|
9
9
|
langchain_google_genai/genai_aqa.py,sha256=zcC5cdFYtqLK7DGPhYGvWNeHHeU-CQKA9KhewmsA5lw,4303
|
|
10
10
|
langchain_google_genai/google_vector_store.py,sha256=PPIk-4FmD5UUdmYA2u7VcEhGsiztvRVN59QoGLXdfoA,16139
|
|
11
|
-
langchain_google_genai/llms.py,sha256=
|
|
11
|
+
langchain_google_genai/llms.py,sha256=lsHvp8reQAP2pkLVM73J9bdJrxlNYFyNygKgef2Fwwo,13663
|
|
12
12
|
langchain_google_genai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
langchain_google_genai-1.0.
|
|
14
|
-
langchain_google_genai-1.0.
|
|
15
|
-
langchain_google_genai-1.0.
|
|
16
|
-
langchain_google_genai-1.0.
|
|
13
|
+
langchain_google_genai-1.0.7.dist-info/LICENSE,sha256=DppmdYJVSc1jd0aio6ptnMUn5tIHrdAhQ12SclEBfBg,1072
|
|
14
|
+
langchain_google_genai-1.0.7.dist-info/METADATA,sha256=iIE9Ue4On45Y3NFBPsIk0mnILxqbyJcBlGyZXvIDpOk,3817
|
|
15
|
+
langchain_google_genai-1.0.7.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
16
|
+
langchain_google_genai-1.0.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|