Skip to content
Open
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
01bd549
add dep
mdrxy Nov 12, 2025
2084f0e
remove unnecessary type ignores
mdrxy Nov 12, 2025
b3627d2
add helpful context to `base_url`
mdrxy Nov 12, 2025
fe53502
rfc: `load_part`
mdrxy Nov 12, 2025
8cd2ab9
remove gemini 1 from `_supports_code_execution`, prep for upcoming
mdrxy Nov 12, 2025
edd27c0
update enums
mdrxy Nov 12, 2025
f3743c0
remove check for `model/` prefix
mdrxy Nov 12, 2025
e674d08
fix `safety_settings` usage example import path
mdrxy Nov 12, 2025
d7de4e5
style/cleanup
mdrxy Nov 12, 2025
4aea216
remove unnecessary `lc_secrets`
mdrxy Nov 12, 2025
5dd2527
add clarifying comment to `build_extra`
mdrxy Nov 12, 2025
55ca9a8
handle potential `None` value in `total_tokens` return
mdrxy Nov 12, 2025
81dc395
handle potentially uninitialized client in `count_tokens`
mdrxy Nov 12, 2025
349e687
address `models/` prefix regression following f3743c07a4e74303ef47c09…
mdrxy Nov 12, 2025
4c28450
update some docstrings
mdrxy Nov 13, 2025
93e5afe
validate client presence on generate and stream methods
mdrxy Nov 13, 2025
2fef210
rfc: retry logic
mdrxy Nov 13, 2025
4fdf6c8
rfc: use `Blob` in data content block in `_convert_to_parts`
mdrxy Nov 13, 2025
0066691
fix a typing error
mdrxy Nov 13, 2025
439f047
another typing fix
mdrxy Nov 13, 2025
835d09e
use `ToolCodeExecution`
mdrxy Nov 13, 2025
b5a34bf
typing, linting use `model_dump` instead of `proto.Message.to_dict`
mdrxy Nov 13, 2025
12b2a45
new function call
mdrxy Nov 13, 2025
6b7d5d9
rearrange `_common` fields and remove `client_options`
mdrxy Nov 13, 2025
95d9b7f
big kahuna
mdrxy Nov 13, 2025
4acddd2
Merge branch 'main' into mdrxy/migrate-google-genai
mdrxy Nov 13, 2025
d0f085c
test temp fallback
mdrxy Nov 13, 2025
27c41e4
update unit test
mdrxy Nov 13, 2025
ac04692
Merge branch 'main' into mdrxy/migrate-google-genai
mdrxy Nov 13, 2025
8609ba8
Merge branch 'main' into mdrxy/migrate-google-genai
mdrxy Nov 13, 2025
a915eb2
Merge branch 'main' into mdrxy/migrate-google-genai
mdrxy Nov 13, 2025
377de89
Merge branch 'main' into mdrxy/migrate-google-genai
mdrxy Nov 13, 2025
5e662d3
Merge branch 'main' into mdrxy/migrate-google-genai
mdrxy Nov 14, 2025
24c7e57
Merge branch 'main' into mdrxy/migrate-google-genai
mdrxy Nov 14, 2025
3aeba83
Merge branch 'main' into mdrxy/migrate-google-genai
mdrxy Nov 14, 2025
13fdf1f
finish removal of aqa
mdrxy Nov 14, 2025
e6c4b9c
bump for CI
mdrxy Nov 14, 2025
bdd76d0
bump for CI
mdrxy Nov 14, 2025
e2bfc30
Big one: merge remote-tracking branch 'origin/main' into mdrxy/migrat…
mdrxy Dec 2, 2025
6df156a
updates
mdrxy Dec 2, 2025
c8371dc
fix test
mdrxy Dec 2, 2025
3ca2cc1
standard tests
mdrxy Dec 3, 2025
e524d48
rearrange params / update docstrings
mdrxy Dec 3, 2025
b235750
client options / vertex
mdrxy Dec 3, 2025
f915501
bump lock
mdrxy Dec 3, 2025
2c346b3
don't swallow errors
mdrxy Dec 3, 2025
7af4db1
lint
mdrxy Dec 3, 2025
b2abf1d
Filter out kwargs already consumed by _prepare_params
mdrxy Dec 3, 2025
216fb07
Merge branch 'main' into mdrxy/migrate-google-genai
mdrxy Dec 3, 2025
9c75f27
Merge branch 'mdrxy/migrate-google-genai' of github.com:langchain-ai/…
mdrxy Dec 3, 2025
6c4040a
fix lint
mdrxy Dec 3, 2025
0990283
add back user agent header
mdrxy Dec 3, 2025
b04e61c
refactor retries to use sdk instead of tenacity
mdrxy Dec 3, 2025
5c8c195
docstring for thought signatures
mdrxy Dec 3, 2025
4b4049e
consolidate chat model unit tests
mdrxy Dec 3, 2025
87e3cd5
consolidate url context tool int test
mdrxy Dec 3, 2025
42f077a
fix #1360
mdrxy Dec 3, 2025
0de5345
ensure test_chat_google_genai_invoke_with_generation_params uses comp…
mdrxy Dec 3, 2025
ea3f039
cleanup client
mdrxy Dec 3, 2025
1308248
misc
mdrxy Dec 3, 2025
45eee3f
strip `models/`
mdrxy Dec 3, 2025
37403db
nit
mdrxy Dec 3, 2025
51513dc
nits
mdrxy Dec 3, 2025
cb4b0a1
rfc helpers to use model profiles
mdrxy Dec 3, 2025
94056d1
nits
mdrxy Dec 3, 2025
cc026fb
lint
mdrxy Dec 3, 2025
e014037
rfc auth to allow vertexai api key
mdrxy Dec 4, 2025
788d8d6
Merge branch 'main' into mdrxy/migrate-google-genai
mdrxy Dec 4, 2025
9e44185
fix tests
mdrxy Dec 4, 2025
732c00c
more tests
mdrxy Dec 4, 2025
1b3abf4
test combined structured output google search
mdrxy Dec 4, 2025
2aebfd2
fix lint
mdrxy Dec 4, 2025
09bf8b4
test(genai): make backend chosen for tests configurable (#1408)
mdrxy Dec 4, 2025
ddc1af0
cr
mdrxy Dec 4, 2025
f922bfc
cr
mdrxy Dec 4, 2025
9ecb606
cr
mdrxy Dec 4, 2025
c4862d8
cr
mdrxy Dec 4, 2025
c03e2b7
lint
mdrxy Dec 4, 2025
ab3802f
lint
mdrxy Dec 4, 2025
1ba3d99
fix duplicate model name in `response_metadata`
mdrxy Dec 5, 2025
f199a74
cr
mdrxy Dec 5, 2025
7a704e7
cr
mdrxy Dec 5, 2025
bbe524a
cr
mdrxy Dec 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ To run integration tests:
make integration_tests
```

#### Backend Selection for Integration Tests

For `libs/genai`, integration tests can run against different backends using the `TEST_VERTEXAI` environment variable:

- **Google AI only (default)**: `make integration_tests`
- **Both Google AI and Vertex AI**: `TEST_VERTEXAI=1 make integration_tests`
- **Vertex AI only**: `TEST_VERTEXAI=only make integration_tests`

Vertex AI tests require the `GOOGLE_CLOUD_PROJECT` environment variable to be set. Tests will automatically skip if not configured.

#### Annotating integration tests

We annotate integration tests to separate those tests which heavily rely on GCP infrastructure. Especially for running those tests we have created a separate GCP project with all necessary infrastructure parts provisioned. To run the extended integration tests locally you will need to provision a GCP project and pass its configuration via env variables.
Expand Down
5 changes: 4 additions & 1 deletion libs/genai/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,8 @@ help:
@echo 'lint - run linters'
@echo 'test - run unit tests'
@echo 'tests - run unit tests'
@echo 'integration_test - run integration tests(NOTE: "export GOOGLE_API_KEY=..." is needed.)'
@echo 'integration_test - run integration tests (NOTE: "export GOOGLE_API_KEY=..." is needed.)'
@echo ' Use TEST_VERTEXAI=1 to test both Google AI and Vertex AI backends'
@echo ' Use TEST_VERTEXAI=only to test only Vertex AI backend'
@echo ' Vertex AI requires GOOGLE_CLOUD_PROJECT to be set'
@echo 'test TEST_FILE=<test_file> - run all tests in file'
66 changes: 23 additions & 43 deletions libs/genai/langchain_google_genai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,60 +1,38 @@
"""LangChain Google Generative AI Integration (GenAI).
"""LangChain Google Gen AI integration.

This module integrates Google's Generative AI models, specifically the Gemini series,
with the LangChain framework. It provides classes for interacting with chat models and
generating embeddings, leveraging Google's advanced AI capabilities.
!!! note "Vertex AI Consolidated"

As of `langchain-google-genai 4.0.0`, this package uses the
[consolidated Google Gen AI SDK](https://googleapis.github.io/python-genai/)
instead of the legacy [`google-ai-generativelanguage`](https://googleapis.dev/python/generativelanguage/latest/)
SDK.

This brings support for Gemini models both via the Gemini API and Gemini API in
Vertex AI, superseding `langchain-google-vertexai`. Users should migrate to this
package for continued support of Google's Generative AI models.

Certain Vertex AI features are not yet supported in the consolidated SDK (and
subsequently this package); see [the docs](https://docs.langchain.com/oss/python/integrations/providers/google)
for more details.

This module provides an interface to Google's Generative AI models, specifically the
Gemini series, with the LangChain framework. It provides classes for interacting with
chat models, generating embeddings, and more.

**Chat Models**

The `ChatGoogleGenerativeAI` class is the primary interface for interacting with
Google's Gemini chat models. It allows users to send and receive messages using a
specified Gemini model, suitable for various conversational AI applications.

**LLMs**

The `GoogleGenerativeAI` class is the primary interface for interacting with Google's
Gemini LLMs. It allows users to generate text using a specified Gemini model.

**Embeddings**

The `GoogleGenerativeAIEmbeddings` class provides functionalities to generate embeddings
using Google's models. These embeddings can be used for a range of NLP tasks, including
semantic analysis, similarity comparisons, and more.

**Using Chat Models**

After setting up your environment with the required API key, you can interact with the
Google Gemini models.

```python
from langchain_google_genai import ChatGoogleGenerativeAI

llm = ChatGoogleGenerativeAI(model="gemini-2.5-pro")
llm.invoke("Sing a ballad of LangChain.")
```

**Using LLMs**

The package also supports generating text with Google's models.

```python
from langchain_google_genai import GoogleGenerativeAI

llm = GoogleGenerativeAI(model="gemini-2.5-pro")
llm.invoke("Once upon a time, a library called LangChain")
```

**Embedding Generation**

The package also supports creating embeddings with Google's models, useful for textual
similarity and other NLP applications.

```python
from langchain_google_genai import GoogleGenerativeAIEmbeddings

embeddings = GoogleGenerativeAIEmbeddings(model="models/gemini-embedding-001")
embeddings.embed_query("hello, world!")
```
See [the docs](https://docs.langchain.com/oss/python/integrations/providers/google) for
more information on usage of this package.
"""

from langchain_google_genai._enums import (
Expand All @@ -70,6 +48,7 @@
GoogleVectorStore,
)
from langchain_google_genai.llms import GoogleGenerativeAI
from langchain_google_genai.utils import create_context_cache

__all__ = [
"ChatGoogleGenerativeAI",
Expand All @@ -81,4 +60,5 @@
"HarmCategory",
"MediaResolution",
"Modality",
"create_context_cache",
]
Loading
Loading