langchain-google-genai 2.1.12__py3-none-any.whl → 3.0.0__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/_common.py +2 -1
- langchain_google_genai/_compat.py +286 -0
- langchain_google_genai/_function_utils.py +30 -3
- langchain_google_genai/_genai_extension.py +25 -6
- langchain_google_genai/chat_models.py +405 -79
- langchain_google_genai/embeddings.py +6 -18
- langchain_google_genai/genai_aqa.py +14 -3
- langchain_google_genai/google_vector_store.py +19 -9
- {langchain_google_genai-2.1.12.dist-info → langchain_google_genai-3.0.0.dist-info}/METADATA +8 -8
- langchain_google_genai-3.0.0.dist-info/RECORD +18 -0
- langchain_google_genai-2.1.12.dist-info/RECORD +0 -17
- {langchain_google_genai-2.1.12.dist-info → langchain_google_genai-3.0.0.dist-info}/WHEEL +0 -0
- {langchain_google_genai-2.1.12.dist-info → langchain_google_genai-3.0.0.dist-info}/entry_points.txt +0 -0
- {langchain_google_genai-2.1.12.dist-info → langchain_google_genai-3.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -116,22 +116,10 @@ class GoogleGenerativeAIEmbeddings(BaseModel, Embeddings):
|
|
|
116
116
|
client_options=self.client_options,
|
|
117
117
|
transport=self.transport,
|
|
118
118
|
)
|
|
119
|
-
#
|
|
120
|
-
#
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
transport = self.transport
|
|
124
|
-
if transport == "rest":
|
|
125
|
-
transport = "grpc_asyncio"
|
|
126
|
-
self.async_client = build_generative_async_service(
|
|
127
|
-
credentials=self.credentials,
|
|
128
|
-
api_key=google_api_key,
|
|
129
|
-
client_info=client_info,
|
|
130
|
-
client_options=self.client_options,
|
|
131
|
-
transport=transport,
|
|
132
|
-
)
|
|
133
|
-
else:
|
|
134
|
-
self.async_client = None
|
|
119
|
+
# Always defer async client initialization to first async call.
|
|
120
|
+
# Avoids implicit event loop creation and aligns with lazy init
|
|
121
|
+
# in chat models.
|
|
122
|
+
self.async_client = None
|
|
135
123
|
return self
|
|
136
124
|
|
|
137
125
|
@property
|
|
@@ -254,7 +242,7 @@ class GoogleGenerativeAIEmbeddings(BaseModel, Embeddings):
|
|
|
254
242
|
batch_size: [int] The batch size of embeddings to send to the model
|
|
255
243
|
task_type: `task_type <https://ai.google.dev/api/embeddings#tasktype>`__
|
|
256
244
|
titles: An optional list of titles for texts provided.
|
|
257
|
-
|
|
245
|
+
Only applicable when TaskType is ``'RETRIEVAL_DOCUMENT'``.
|
|
258
246
|
output_dimensionality: Optional `reduced dimension for the output embedding <https://ai.google.dev/api/embeddings#EmbedContentRequest>`__.
|
|
259
247
|
|
|
260
248
|
Returns:
|
|
@@ -305,7 +293,7 @@ class GoogleGenerativeAIEmbeddings(BaseModel, Embeddings):
|
|
|
305
293
|
text: The text to embed.
|
|
306
294
|
task_type: `task_type <https://ai.google.dev/api/embeddings#tasktype>`__
|
|
307
295
|
title: An optional title for the text.
|
|
308
|
-
|
|
296
|
+
Only applicable when TaskType is ``'RETRIEVAL_DOCUMENT'``.
|
|
309
297
|
output_dimensionality: Optional `reduced dimension for the output embedding <https://ai.google.dev/api/embeddings#EmbedContentRequest>`__.
|
|
310
298
|
|
|
311
299
|
Returns:
|
|
@@ -103,19 +103,30 @@ class GenAIAqa(RunnableSerializable[AqaInput, AqaOutput]):
|
|
|
103
103
|
# google.generativeai installed.
|
|
104
104
|
answer_style: int = 1
|
|
105
105
|
|
|
106
|
-
def __init__(
|
|
106
|
+
def __init__(
|
|
107
|
+
self,
|
|
108
|
+
*,
|
|
109
|
+
answer_style: int = genai.GenerateAnswerRequest.AnswerStyle.ABSTRACTIVE,
|
|
110
|
+
safety_settings: Optional[List[genai.SafetySetting]] = None,
|
|
111
|
+
temperature: Optional[float] = None,
|
|
112
|
+
**kwargs: Any,
|
|
113
|
+
) -> None:
|
|
107
114
|
"""Construct a Google Generative AI AQA model.
|
|
108
115
|
|
|
109
116
|
All arguments are optional.
|
|
110
117
|
|
|
111
118
|
Args:
|
|
112
119
|
answer_style: See
|
|
113
|
-
|
|
120
|
+
`google.ai.generativelanguage.GenerateAnswerRequest.AnswerStyle`.
|
|
114
121
|
safety_settings: See `google.ai.generativelanguage.SafetySetting`.
|
|
115
122
|
temperature: 0.0 to 1.0.
|
|
116
123
|
"""
|
|
117
124
|
super().__init__(**kwargs)
|
|
118
|
-
self._client = _AqaModel(
|
|
125
|
+
self._client = _AqaModel(
|
|
126
|
+
answer_style=answer_style,
|
|
127
|
+
safety_settings=safety_settings,
|
|
128
|
+
temperature=temperature,
|
|
129
|
+
)
|
|
119
130
|
|
|
120
131
|
def invoke(
|
|
121
132
|
self, input: AqaInput, config: Optional[RunnableConfig] = None, **kwargs: Any
|
|
@@ -262,9 +262,9 @@ class GoogleVectorStore(VectorStore):
|
|
|
262
262
|
document.
|
|
263
263
|
|
|
264
264
|
Raises:
|
|
265
|
-
DoesNotExistsException
|
|
266
|
-
server. In this case, consider using
|
|
267
|
-
|
|
265
|
+
DoesNotExistsException: If the IDs do not match to anything on Google
|
|
266
|
+
server. In this case, consider using ``create_corpus`` or
|
|
267
|
+
``create_document`` to create one.
|
|
268
268
|
"""
|
|
269
269
|
super().__init__(**kwargs)
|
|
270
270
|
self._retriever = _SemanticRetriever.from_ids(corpus_id, document_id)
|
|
@@ -352,7 +352,7 @@ class GoogleVectorStore(VectorStore):
|
|
|
352
352
|
Document.
|
|
353
353
|
|
|
354
354
|
Raises:
|
|
355
|
-
DoesNotExistsException
|
|
355
|
+
DoesNotExistsException: If the IDs do not match to anything at
|
|
356
356
|
Google server.
|
|
357
357
|
"""
|
|
358
358
|
if corpus_id is None or document_id is None:
|
|
@@ -463,16 +463,22 @@ class GoogleVectorStore(VectorStore):
|
|
|
463
463
|
"""
|
|
464
464
|
return lambda score: score
|
|
465
465
|
|
|
466
|
-
def as_aqa(
|
|
466
|
+
def as_aqa(
|
|
467
|
+
self,
|
|
468
|
+
*,
|
|
469
|
+
answer_style: int = 1,
|
|
470
|
+
safety_settings: Optional[List[Any]] = None,
|
|
471
|
+
temperature: Optional[float] = None,
|
|
472
|
+
) -> Runnable[str, AqaOutput]:
|
|
467
473
|
"""Construct a Google Generative AI AQA engine.
|
|
468
474
|
|
|
469
475
|
All arguments are optional.
|
|
470
476
|
|
|
471
477
|
Args:
|
|
472
478
|
answer_style: See
|
|
473
|
-
|
|
474
|
-
safety_settings: See
|
|
475
|
-
temperature: 0.0
|
|
479
|
+
``google.ai.generativelanguage.GenerateAnswerRequest.AnswerStyle``.
|
|
480
|
+
safety_settings: See ``google.ai.generativelanguage.SafetySetting``.
|
|
481
|
+
temperature: Value between 0.0 and 1.0 controlling randomness.
|
|
476
482
|
"""
|
|
477
483
|
return (
|
|
478
484
|
RunnablePassthrough[str]()
|
|
@@ -481,7 +487,11 @@ class GoogleVectorStore(VectorStore):
|
|
|
481
487
|
"passages": self.as_retriever(),
|
|
482
488
|
}
|
|
483
489
|
| RunnableLambda(_toAqaInput)
|
|
484
|
-
| GenAIAqa(
|
|
490
|
+
| GenAIAqa(
|
|
491
|
+
answer_style=answer_style,
|
|
492
|
+
safety_settings=safety_settings,
|
|
493
|
+
temperature=temperature,
|
|
494
|
+
)
|
|
485
495
|
)
|
|
486
496
|
|
|
487
497
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: langchain-google-genai
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: An integration package connecting Google's genai package and LangChain
|
|
5
5
|
License: MIT
|
|
6
6
|
Project-URL: Source Code, https://github.com/langchain-ai/langchain-google/tree/main/libs/genai
|
|
7
7
|
Project-URL: Release Notes, https://github.com/langchain-ai/langchain-google/releases
|
|
8
8
|
Project-URL: repository, https://github.com/langchain-ai/langchain-google
|
|
9
|
-
Requires-Python:
|
|
10
|
-
Requires-Dist: langchain-core
|
|
11
|
-
Requires-Dist: google-ai-generativelanguage<1,>=0.7
|
|
12
|
-
Requires-Dist: pydantic<3,>=2
|
|
13
|
-
Requires-Dist: filetype<2,>=1.2
|
|
9
|
+
Requires-Python: <4.0.0,>=3.10.0
|
|
10
|
+
Requires-Dist: langchain-core<2.0.0,>=1.0.0
|
|
11
|
+
Requires-Dist: google-ai-generativelanguage<1.0.0,>=0.7.0
|
|
12
|
+
Requires-Dist: pydantic<3.0.0,>=2.0.0
|
|
13
|
+
Requires-Dist: filetype<2.0.0,>=1.2.0
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
|
|
16
16
|
# langchain-google-genai
|
|
@@ -76,7 +76,7 @@ Then use the `ChatGoogleGenerativeAI` interface:
|
|
|
76
76
|
```python
|
|
77
77
|
from langchain_google_genai import ChatGoogleGenerativeAI
|
|
78
78
|
|
|
79
|
-
llm = ChatGoogleGenerativeAI(model="gemini-
|
|
79
|
+
llm = ChatGoogleGenerativeAI(model="gemini-flash-latest")
|
|
80
80
|
response = llm.invoke("Sing a ballad of LangChain.")
|
|
81
81
|
print(response.content)
|
|
82
82
|
```
|
|
@@ -97,7 +97,7 @@ Most Gemini models support image inputs.
|
|
|
97
97
|
from langchain_core.messages import HumanMessage
|
|
98
98
|
from langchain_google_genai import ChatGoogleGenerativeAI
|
|
99
99
|
|
|
100
|
-
llm = ChatGoogleGenerativeAI(model="gemini-
|
|
100
|
+
llm = ChatGoogleGenerativeAI(model="gemini-flash-latest")
|
|
101
101
|
|
|
102
102
|
message = HumanMessage(
|
|
103
103
|
content=[
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
langchain_google_genai-3.0.0.dist-info/METADATA,sha256=O7aX_xT6ujAmBIRcWw7qzbylSrJL1ZGGUe-DFC2ufEE,7092
|
|
2
|
+
langchain_google_genai-3.0.0.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
|
|
3
|
+
langchain_google_genai-3.0.0.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
|
4
|
+
langchain_google_genai-3.0.0.dist-info/licenses/LICENSE,sha256=DppmdYJVSc1jd0aio6ptnMUn5tIHrdAhQ12SclEBfBg,1072
|
|
5
|
+
langchain_google_genai/__init__.py,sha256=yVc4wCHzajs8mvDVQLGmkxxivzApvdu7jTytrLr_i7g,2891
|
|
6
|
+
langchain_google_genai/_common.py,sha256=qV7EqGEsi1_BCnUDJf1ZDgOhHOIGKbgw8-D1g7Afo3g,6307
|
|
7
|
+
langchain_google_genai/_compat.py,sha256=QGQhorN0DHpbXMVJyKlzYdNz62L8EU6XM9EK-kfg-rQ,10979
|
|
8
|
+
langchain_google_genai/_enums.py,sha256=Zj3BXXLlkm_UybegCi6fLsfFhriJCt_LAJvgatgPWQ0,252
|
|
9
|
+
langchain_google_genai/_function_utils.py,sha256=zlH0YhFZolP6mhppBPr-7d1t6psvZcpSmkuS1oER0S0,23647
|
|
10
|
+
langchain_google_genai/_genai_extension.py,sha256=3W8N_vMxrwtzZvmPgmyIr6T8q6UkyS3y-IYMcr_67Ac,22597
|
|
11
|
+
langchain_google_genai/_image_utils.py,sha256=iJ3KrFWQhA0UwsT8ryAFAmNM7-_2ahHAppT8t9WFZGQ,5304
|
|
12
|
+
langchain_google_genai/chat_models.py,sha256=jVeoq3r1ekE2KXQmbEalLaMgAFxXATB3i1HDz4S1zDI,101386
|
|
13
|
+
langchain_google_genai/embeddings.py,sha256=ubnQlnciDezNWA0RFJqcq7TBEahSQ2Cw6qLIgdySnj0,16197
|
|
14
|
+
langchain_google_genai/genai_aqa.py,sha256=O3HDQLEi50OugTmYw5p4g3MbFuSTUFz0zTwMGvF0dxI,4733
|
|
15
|
+
langchain_google_genai/google_vector_store.py,sha256=pkpOKFiZNognkMJ8dNE6kDqPZSjiiAofGRihadk0XQw,16865
|
|
16
|
+
langchain_google_genai/llms.py,sha256=P_e_ImBWexhKqc7LZPo6tQbwLH2-ljr6oqpE5M27TRc,5755
|
|
17
|
+
langchain_google_genai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
+
langchain_google_genai-3.0.0.dist-info/RECORD,,
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
langchain_google_genai-2.1.12.dist-info/METADATA,sha256=cIpzlJRZXFdHG-aZmSE6MJUmSr-JAZzH7pDvU30nzOs,7051
|
|
2
|
-
langchain_google_genai-2.1.12.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
|
|
3
|
-
langchain_google_genai-2.1.12.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
|
4
|
-
langchain_google_genai-2.1.12.dist-info/licenses/LICENSE,sha256=DppmdYJVSc1jd0aio6ptnMUn5tIHrdAhQ12SclEBfBg,1072
|
|
5
|
-
langchain_google_genai/__init__.py,sha256=yVc4wCHzajs8mvDVQLGmkxxivzApvdu7jTytrLr_i7g,2891
|
|
6
|
-
langchain_google_genai/_common.py,sha256=dzzcJeDVnUUI_8Y20F40SZ5NjW6RHD4xJu74naYK58k,6192
|
|
7
|
-
langchain_google_genai/_enums.py,sha256=Zj3BXXLlkm_UybegCi6fLsfFhriJCt_LAJvgatgPWQ0,252
|
|
8
|
-
langchain_google_genai/_function_utils.py,sha256=Pur365t4M8O5dkrnFkDc_jHiPfuI_C7ucSxvxA3tioM,22254
|
|
9
|
-
langchain_google_genai/_genai_extension.py,sha256=LiNa7b6BZp41meJMtgaSEbaGJa59BY3UMCRMHO_CCtQ,21467
|
|
10
|
-
langchain_google_genai/_image_utils.py,sha256=iJ3KrFWQhA0UwsT8ryAFAmNM7-_2ahHAppT8t9WFZGQ,5304
|
|
11
|
-
langchain_google_genai/chat_models.py,sha256=G619buVU9Sef33Ubk9JL8gYLd5y_jsGMgFXeuPq7wJ0,85067
|
|
12
|
-
langchain_google_genai/embeddings.py,sha256=Kar6nHpAJ0rWQZ0nc7_anWETlwCIovd4DhieIviGNQ8,16687
|
|
13
|
-
langchain_google_genai/genai_aqa.py,sha256=NVW8wOWxU7T6VVshFrFlFHa5HzEPAedrgh1fOwFH7Og,4380
|
|
14
|
-
langchain_google_genai/google_vector_store.py,sha256=x4OcXkcYWTubu-AESNzNDJG_dbge16GeNCAOCsBoc4g,16537
|
|
15
|
-
langchain_google_genai/llms.py,sha256=P_e_ImBWexhKqc7LZPo6tQbwLH2-ljr6oqpE5M27TRc,5755
|
|
16
|
-
langchain_google_genai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
-
langchain_google_genai-2.1.12.dist-info/RECORD,,
|
|
File without changes
|
{langchain_google_genai-2.1.12.dist-info → langchain_google_genai-3.0.0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{langchain_google_genai-2.1.12.dist-info → langchain_google_genai-3.0.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|