langchain-google-genai 0.0.10rc0__py3-none-any.whl → 1.0.1__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/__init__.py +15 -0
- langchain_google_genai/_genai_extension.py +618 -0
- langchain_google_genai/chat_models.py +17 -10
- langchain_google_genai/embeddings.py +26 -12
- langchain_google_genai/genai_aqa.py +134 -0
- langchain_google_genai/google_vector_store.py +493 -0
- langchain_google_genai/llms.py +22 -12
- {langchain_google_genai-0.0.10rc0.dist-info → langchain_google_genai-1.0.1.dist-info}/METADATA +32 -2
- langchain_google_genai-1.0.1.dist-info/RECORD +15 -0
- langchain_google_genai-0.0.10rc0.dist-info/RECORD +0 -12
- {langchain_google_genai-0.0.10rc0.dist-info → langchain_google_genai-1.0.1.dist-info}/LICENSE +0 -0
- {langchain_google_genai-0.0.10rc0.dist-info → langchain_google_genai-1.0.1.dist-info}/WHEEL +0 -0
langchain_google_genai/llms.py
CHANGED
|
@@ -122,6 +122,10 @@ Supported examples:
|
|
|
122
122
|
)
|
|
123
123
|
"""Model name to use."""
|
|
124
124
|
google_api_key: Optional[SecretStr] = None
|
|
125
|
+
credentials: Any = None
|
|
126
|
+
"The default custom credentials (google.auth.credentials.Credentials) to use "
|
|
127
|
+
"when making API calls. If not provided, credentials will be ascertained from "
|
|
128
|
+
"the GOOGLE_API_KEY envvar"
|
|
125
129
|
temperature: float = 0.7
|
|
126
130
|
"""Run inference with this temperature. Must by in the closed interval
|
|
127
131
|
[0.0, 1.0]."""
|
|
@@ -203,22 +207,28 @@ class GoogleGenerativeAI(_BaseGoogleGenerativeAI, BaseLLM):
|
|
|
203
207
|
@root_validator()
|
|
204
208
|
def validate_environment(cls, values: Dict) -> Dict:
|
|
205
209
|
"""Validates params and passes them to google-generativeai package."""
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
210
|
+
if values.get("credentials"):
|
|
211
|
+
genai.configure(
|
|
212
|
+
credentials=values.get("credentials"),
|
|
213
|
+
transport=values.get("transport"),
|
|
214
|
+
client_options=values.get("client_options"),
|
|
215
|
+
)
|
|
216
|
+
else:
|
|
217
|
+
google_api_key = get_from_dict_or_env(
|
|
218
|
+
values, "google_api_key", "GOOGLE_API_KEY"
|
|
219
|
+
)
|
|
220
|
+
if isinstance(google_api_key, SecretStr):
|
|
221
|
+
google_api_key = google_api_key.get_secret_value()
|
|
222
|
+
genai.configure(
|
|
223
|
+
api_key=google_api_key,
|
|
224
|
+
transport=values.get("transport"),
|
|
225
|
+
client_options=values.get("client_options"),
|
|
226
|
+
)
|
|
227
|
+
|
|
209
228
|
model_name = values["model"]
|
|
210
229
|
|
|
211
230
|
safety_settings = values["safety_settings"]
|
|
212
231
|
|
|
213
|
-
if isinstance(google_api_key, SecretStr):
|
|
214
|
-
google_api_key = google_api_key.get_secret_value()
|
|
215
|
-
|
|
216
|
-
genai.configure(
|
|
217
|
-
api_key=google_api_key,
|
|
218
|
-
transport=values.get("transport"),
|
|
219
|
-
client_options=values.get("client_options"),
|
|
220
|
-
)
|
|
221
|
-
|
|
222
232
|
if safety_settings and (
|
|
223
233
|
not GoogleModelFamily(model_name) == GoogleModelFamily.GEMINI
|
|
224
234
|
):
|
{langchain_google_genai-0.0.10rc0.dist-info → langchain_google_genai-1.0.1.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: langchain-google-genai
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1.0.1
|
|
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,7 +12,7 @@ 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.
|
|
15
|
+
Requires-Dist: google-generativeai (>=0.4.1,<0.5.0)
|
|
16
16
|
Requires-Dist: langchain-core (>=0.1,<0.2)
|
|
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
|
|
@@ -97,3 +97,33 @@ from langchain_google_genai import GoogleGenerativeAIEmbeddings
|
|
|
97
97
|
embeddings = GoogleGenerativeAIEmbeddings(model="models/embedding-001")
|
|
98
98
|
embeddings.embed_query("hello, world!")
|
|
99
99
|
```
|
|
100
|
+
|
|
101
|
+
## Semantic Retrieval
|
|
102
|
+
|
|
103
|
+
Enables retrieval augmented generation (RAG) in your application.
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
# Create a new store for housing your documents.
|
|
107
|
+
corpus_store = GoogleVectorStore.create_corpus(display_name="My Corpus")
|
|
108
|
+
|
|
109
|
+
# Create a new document under the above corpus.
|
|
110
|
+
document_store = GoogleVectorStore.create_document(
|
|
111
|
+
corpus_id=corpus_store.corpus_id, display_name="My Document"
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
# Upload some texts to the document.
|
|
115
|
+
text_splitter = CharacterTextSplitter(chunk_size=500, chunk_overlap=0)
|
|
116
|
+
for file in DirectoryLoader(path="data/").load():
|
|
117
|
+
documents = text_splitter.split_documents([file])
|
|
118
|
+
document_store.add_documents(documents)
|
|
119
|
+
|
|
120
|
+
# Talk to your entire corpus with possibly many documents.
|
|
121
|
+
aqa = corpus_store.as_aqa()
|
|
122
|
+
answer = aqa.invoke("What is the meaning of life?")
|
|
123
|
+
|
|
124
|
+
# Read the response along with the attributed passages and answerability.
|
|
125
|
+
print(response.answer)
|
|
126
|
+
print(response.attributed_passages)
|
|
127
|
+
print(response.answerable_probability)
|
|
128
|
+
```
|
|
129
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
langchain_google_genai/__init__.py,sha256=NiLfU4IyEQSlSl8hbN_fTdX-hrO5tuOflxFlEK0Sy4c,2762
|
|
2
|
+
langchain_google_genai/_common.py,sha256=1r0VrrBSTZfGprmICZ5OV-W5SK31jKRFFCNE3vJ3jmk,136
|
|
3
|
+
langchain_google_genai/_enums.py,sha256=q8IYAqufV-_yZ98FDnsZ3x-1w4804J_e8PrTKT0sdhY,163
|
|
4
|
+
langchain_google_genai/_function_utils.py,sha256=9IVMPQq5lQB8F_whG3mrGOM_tjmP-TMEY3URHfJnjgI,3640
|
|
5
|
+
langchain_google_genai/_genai_extension.py,sha256=2Uqg7vSF0vu1J4AhAyIPzadtpM5JJwZsBXvpItO2TY4,18736
|
|
6
|
+
langchain_google_genai/chat_models.py,sha256=WQnwqHLoKf6P4lViEbCcfumGQhrZoYVWzk6rO0EIG9M,23680
|
|
7
|
+
langchain_google_genai/embeddings.py,sha256=VbrVGX5f_aKo-XA_2lATB4GblomXYWoj9J1Cz20Pr4E,4562
|
|
8
|
+
langchain_google_genai/genai_aqa.py,sha256=zcC5cdFYtqLK7DGPhYGvWNeHHeU-CQKA9KhewmsA5lw,4303
|
|
9
|
+
langchain_google_genai/google_vector_store.py,sha256=PPIk-4FmD5UUdmYA2u7VcEhGsiztvRVN59QoGLXdfoA,16139
|
|
10
|
+
langchain_google_genai/llms.py,sha256=zhkZDB9d9-pLwAxKnfZaP0rdn_dodBJmQAn45hIGXF4,12994
|
|
11
|
+
langchain_google_genai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
+
langchain_google_genai-1.0.1.dist-info/LICENSE,sha256=DppmdYJVSc1jd0aio6ptnMUn5tIHrdAhQ12SclEBfBg,1072
|
|
13
|
+
langchain_google_genai-1.0.1.dist-info/METADATA,sha256=o8A_0hORZ3sMcxHrYn_uL2u3how0vzlmV03JQPQn5ak,3815
|
|
14
|
+
langchain_google_genai-1.0.1.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
15
|
+
langchain_google_genai-1.0.1.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
langchain_google_genai/__init__.py,sha256=4ePIj3bg38LPq5JQnVIvbropWTb6-Ln32Ee8H6Xcysg,2426
|
|
2
|
-
langchain_google_genai/_common.py,sha256=1r0VrrBSTZfGprmICZ5OV-W5SK31jKRFFCNE3vJ3jmk,136
|
|
3
|
-
langchain_google_genai/_enums.py,sha256=q8IYAqufV-_yZ98FDnsZ3x-1w4804J_e8PrTKT0sdhY,163
|
|
4
|
-
langchain_google_genai/_function_utils.py,sha256=9IVMPQq5lQB8F_whG3mrGOM_tjmP-TMEY3URHfJnjgI,3640
|
|
5
|
-
langchain_google_genai/chat_models.py,sha256=O3Ix7z-v5DbDgQMtx2GgeUcVWVcuLgHj0Kt21h5F_Kc,23378
|
|
6
|
-
langchain_google_genai/embeddings.py,sha256=EMa-sDGXUpAPMSyjA2-YXF_TGrlSlqljNeqysAh574s,3951
|
|
7
|
-
langchain_google_genai/llms.py,sha256=UUA23zfQeS53zJVN822jX4YElypoOlho4y6d1d5dVys,12466
|
|
8
|
-
langchain_google_genai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
langchain_google_genai-0.0.10rc0.dist-info/LICENSE,sha256=DppmdYJVSc1jd0aio6ptnMUn5tIHrdAhQ12SclEBfBg,1072
|
|
10
|
-
langchain_google_genai-0.0.10rc0.dist-info/METADATA,sha256=x6fIsFayMQktflGpKdXc4FZCzAdliw3RscMwMhgMrx8,2858
|
|
11
|
-
langchain_google_genai-0.0.10rc0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
12
|
-
langchain_google_genai-0.0.10rc0.dist-info/RECORD,,
|
{langchain_google_genai-0.0.10rc0.dist-info → langchain_google_genai-1.0.1.dist-info}/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|