langchain-google-genai 0.0.11__tar.gz → 1.0.1__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.

Files changed (15) hide show
  1. {langchain_google_genai-0.0.11 → langchain_google_genai-1.0.1}/PKG-INFO +1 -1
  2. {langchain_google_genai-0.0.11 → langchain_google_genai-1.0.1}/langchain_google_genai/chat_models.py +17 -10
  3. {langchain_google_genai-0.0.11 → langchain_google_genai-1.0.1}/langchain_google_genai/embeddings.py +26 -12
  4. {langchain_google_genai-0.0.11 → langchain_google_genai-1.0.1}/langchain_google_genai/llms.py +22 -12
  5. {langchain_google_genai-0.0.11 → langchain_google_genai-1.0.1}/pyproject.toml +1 -1
  6. {langchain_google_genai-0.0.11 → langchain_google_genai-1.0.1}/LICENSE +0 -0
  7. {langchain_google_genai-0.0.11 → langchain_google_genai-1.0.1}/README.md +0 -0
  8. {langchain_google_genai-0.0.11 → langchain_google_genai-1.0.1}/langchain_google_genai/__init__.py +0 -0
  9. {langchain_google_genai-0.0.11 → langchain_google_genai-1.0.1}/langchain_google_genai/_common.py +0 -0
  10. {langchain_google_genai-0.0.11 → langchain_google_genai-1.0.1}/langchain_google_genai/_enums.py +0 -0
  11. {langchain_google_genai-0.0.11 → langchain_google_genai-1.0.1}/langchain_google_genai/_function_utils.py +0 -0
  12. {langchain_google_genai-0.0.11 → langchain_google_genai-1.0.1}/langchain_google_genai/_genai_extension.py +0 -0
  13. {langchain_google_genai-0.0.11 → langchain_google_genai-1.0.1}/langchain_google_genai/genai_aqa.py +0 -0
  14. {langchain_google_genai-0.0.11 → langchain_google_genai-1.0.1}/langchain_google_genai/google_vector_store.py +0 -0
  15. {langchain_google_genai-0.0.11 → langchain_google_genai-1.0.1}/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: 0.0.11
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
@@ -483,17 +483,24 @@ class ChatGoogleGenerativeAI(_BaseGoogleGenerativeAI, BaseChatModel):
483
483
  @root_validator()
484
484
  def validate_environment(cls, values: Dict) -> Dict:
485
485
  """Validates params and passes them to google-generativeai package."""
486
- google_api_key = get_from_dict_or_env(
487
- values, "google_api_key", "GOOGLE_API_KEY"
488
- )
489
- if isinstance(google_api_key, SecretStr):
490
- google_api_key = google_api_key.get_secret_value()
486
+ if values.get("credentials"):
487
+ genai.configure(
488
+ credentials=values.get("credentials"),
489
+ transport=values.get("transport"),
490
+ client_options=values.get("client_options"),
491
+ )
492
+ else:
493
+ google_api_key = get_from_dict_or_env(
494
+ values, "google_api_key", "GOOGLE_API_KEY"
495
+ )
496
+ if isinstance(google_api_key, SecretStr):
497
+ google_api_key = google_api_key.get_secret_value()
491
498
 
492
- genai.configure(
493
- api_key=google_api_key,
494
- transport=values.get("transport"),
495
- client_options=values.get("client_options"),
496
- )
499
+ genai.configure(
500
+ api_key=google_api_key,
501
+ transport=values.get("transport"),
502
+ client_options=values.get("client_options"),
503
+ )
497
504
  if (
498
505
  values.get("temperature") is not None
499
506
  and not 0 <= values["temperature"] <= 1
@@ -1,4 +1,4 @@
1
- from typing import Dict, List, Optional
1
+ from typing import Any, Dict, List, Optional
2
2
 
3
3
  # TODO: remove ignore once the google package is published with types
4
4
  import google.generativeai as genai # type: ignore[import]
@@ -43,6 +43,13 @@ class GoogleGenerativeAIEmbeddings(BaseModel, Embeddings):
43
43
  description="The Google API key to use. If not provided, "
44
44
  "the GOOGLE_API_KEY environment variable will be used.",
45
45
  )
46
+ credentials: Any = Field(
47
+ default=None,
48
+ exclude=True,
49
+ description="The default custom credentials "
50
+ "(google.auth.credentials.Credentials) to use when making API calls. If not "
51
+ "provided, credentials will be ascertained from the GOOGLE_API_KEY envvar",
52
+ )
46
53
  client_options: Optional[Dict] = Field(
47
54
  None,
48
55
  description=(
@@ -58,17 +65,24 @@ class GoogleGenerativeAIEmbeddings(BaseModel, Embeddings):
58
65
  @root_validator()
59
66
  def validate_environment(cls, values: Dict) -> Dict:
60
67
  """Validates params and passes them to google-generativeai package."""
61
- google_api_key = get_from_dict_or_env(
62
- values, "google_api_key", "GOOGLE_API_KEY"
63
- )
64
- if isinstance(google_api_key, SecretStr):
65
- google_api_key = google_api_key.get_secret_value()
66
-
67
- genai.configure(
68
- api_key=google_api_key,
69
- transport=values.get("transport"),
70
- client_options=values.get("client_options"),
71
- )
68
+ if values.get("credentials"):
69
+ genai.configure(
70
+ credentials=values.get("credentials"),
71
+ transport=values.get("transport"),
72
+ client_options=values.get("client_options"),
73
+ )
74
+ else:
75
+ google_api_key = get_from_dict_or_env(
76
+ values, "google_api_key", "GOOGLE_API_KEY"
77
+ )
78
+ if isinstance(google_api_key, SecretStr):
79
+ google_api_key = google_api_key.get_secret_value()
80
+
81
+ genai.configure(
82
+ api_key=google_api_key,
83
+ transport=values.get("transport"),
84
+ client_options=values.get("client_options"),
85
+ )
72
86
  return values
73
87
 
74
88
  def _embed(
@@ -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
- google_api_key = get_from_dict_or_env(
207
- values, "google_api_key", "GOOGLE_API_KEY"
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
  ):
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "langchain-google-genai"
3
- version = "0.0.11"
3
+ version = "1.0.1"
4
4
  description = "An integration package connecting Google's genai package and LangChain"
5
5
  authors = []
6
6
  readme = "README.md"