Skip to content

Commit d1cdc62

Browse files
author
Jeyaram Jeyaraj
committed
Address PR #1938 review comments: migrate to google-genai SDK, add Python 3.14, simplify to Google AI only
- Migrate from google-generativeai to google-genai SDK (>=0.2,<1) - Add Python 3.14 classifier support - Simplify to Google AI only (remove VertexAI settings and tests) - Remove google-cloud-aiplatform dependency - Update README to reflect Google AI focus and google-genai SDK - Add comprehensive GAP_ANALYSIS.md with 4-phase implementation plan - Add PR1938_CHECKLIST.md tracking review feedback and next steps - Verify implementation against official Google migration guide - All tests passing (5 tests, 100% coverage) Addresses feedback from @eavanvalkenburg: 1. Added Python 3.14 support 2. Switched to google-genai (GA release, Google-recommended) 3. Removed VertexAI to simplify first iteration
1 parent 4b0d0ec commit d1cdc62

File tree

7 files changed

+27
-590
lines changed

7 files changed

+27
-590
lines changed

python/packages/google/README.md

Lines changed: 13 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
# Get Started with Microsoft Agent Framework Google
22

3-
> **Note**: This package is currently under active development. The chat client implementations for Google AI and Vertex AI are coming soon. This initial release provides the foundational settings and configuration classes.
3+
> **Note**: This package is currently under active development. The chat client implementation for Google AI is coming soon. This initial release provides the foundational settings and configuration classes.
44
55
Please install this package via pip:
66

77
```bash
88
pip install agent-framework-google --pre
99
```
1010

11-
## Google AI & Vertex AI Integration
11+
## Google AI (Gemini API) Integration
1212

13-
This package will provide integration with Google's generative AI platforms:
13+
This package provides integration with Google's Gemini API for Agent Framework:
1414

1515
- **Google AI (Gemini API)**: Direct access to Google's Gemini models with API key authentication
16-
- **Vertex AI**: Enterprise-grade access via Google Cloud Platform with advanced features like grounding and code execution
16+
17+
> **Note**: This package uses the new `google-genai` SDK as recommended by Google. See the [migration guide](https://ai.google.dev/gemini-api/docs/migrate) for more information.
1718
1819
### Current Status
1920

2021
**Available Now:**
2122
- `GoogleAISettings`: Configuration class for Google AI (Gemini API) authentication and settings
22-
- `VertexAISettings`: Configuration class for Vertex AI authentication and settings
2323

2424
**Coming Soon:**
2525
- `GoogleAIChatClient`: Chat client for Google AI with streaming, function calling, and multi-modal support
26-
- `VertexAIChatClient`: Enterprise chat client with grounding (Google Search) and code execution capabilities
2726
- Integration tests and usage samples
2827

2928
### Configuration
3029

31-
You can configure the settings classes now, which will be used by the chat clients in the next release:
30+
You can configure the settings class now, which will be used by the chat client in the next release:
3231

3332
#### Google AI Settings
3433

@@ -48,34 +47,9 @@ settings = GoogleAISettings(
4847
)
4948
```
5049

51-
#### Vertex AI Settings
52-
53-
```python
54-
from agent_framework_google import VertexAISettings
55-
56-
# Configure via environment variables
57-
# VERTEX_AI_PROJECT_ID=your-project-id
58-
# VERTEX_AI_LOCATION=us-central1
59-
# VERTEX_AI_CHAT_MODEL_ID=gemini-1.5-pro
60-
# GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
61-
62-
settings = VertexAISettings()
63-
64-
# Or pass parameters directly
65-
settings = VertexAISettings(
66-
project_id="your-project-id",
67-
location="us-central1",
68-
chat_model_id="gemini-1.5-pro"
69-
)
70-
```
71-
7250
### Future Usage (Coming Soon)
7351

74-
Once the chat clients are released, usage will look like this:
75-
76-
#### Google AI (Gemini API)
77-
78-
Use Google AI for straightforward access to Gemini models with API key authentication.
52+
Once the chat client is released, usage will look like this:
7953

8054
```python
8155
from agent_framework.google import GoogleAIChatClient
@@ -94,31 +68,6 @@ response = await agent.run("Hello!")
9468
print(response.text)
9569
```
9670

97-
#### Vertex AI (Coming Soon)
98-
99-
Use Vertex AI for enterprise features including grounding with Google Search and code execution.
100-
101-
```python
102-
from agent_framework.google import VertexAIChatClient
103-
from agent_framework import HostedWebSearchTool
104-
105-
# Configure via environment variables
106-
# VERTEX_AI_PROJECT_ID=your-project-id
107-
# VERTEX_AI_LOCATION=us-central1
108-
# VERTEX_AI_CHAT_MODEL_ID=gemini-1.5-pro
109-
# GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
110-
111-
client = VertexAIChatClient()
112-
agent = client.create_agent(
113-
name="Assistant",
114-
instructions="You are a helpful assistant",
115-
tools=[HostedWebSearchTool()] # Vertex AI exclusive
116-
)
117-
118-
response = await agent.run("What's the latest news?")
119-
print(response.text)
120-
```
121-
12271
## Configuration
12372

12473
### Environment Variables
@@ -127,12 +76,6 @@ print(response.text)
12776
- `GOOGLE_AI_API_KEY`: Your Google AI API key ([Get one here](https://ai.google.dev/))
12877
- `GOOGLE_AI_CHAT_MODEL_ID`: Model to use (e.g., `gemini-1.5-pro`, `gemini-1.5-flash`)
12978

130-
**Vertex AI:**
131-
- `VERTEX_AI_PROJECT_ID`: Your GCP project ID
132-
- `VERTEX_AI_LOCATION`: GCP region (e.g., `us-central1`)
133-
- `VERTEX_AI_CHAT_MODEL_ID`: Model to use (e.g., `gemini-1.5-pro`)
134-
- `GOOGLE_APPLICATION_CREDENTIALS`: Path to service account JSON file
135-
13679
### Supported Models
13780

13881
- `gemini-1.5-pro`: Most capable model
@@ -141,39 +84,32 @@ print(response.text)
14184

14285
## Features
14386

144-
### Common Features (Both Google AI & Vertex AI)
87+
### Planned Features
14588
- ✅ Chat completion (streaming and non-streaming)
14689
- ✅ Function/tool calling
14790
- ✅ Multi-modal support (text, images, video, audio)
14891
- ✅ System instructions
14992
- ✅ Conversation history management
15093

151-
### Vertex AI Exclusive Features (Coming Soon)
152-
- Grounding with Google Search
153-
- Grounding with Vertex AI Search
154-
- Code execution tool
155-
- Enterprise security and compliance
156-
- VPC-SC support
157-
15894
## Development Roadmap
15995

16096
This package is being developed incrementally:
16197

16298
-**Phase 1 (Current)**: Package structure and settings classes
16399
- 🚧 **Phase 2 (Next)**: Google AI chat client with streaming and function calling
164100
- 🚧 **Phase 3**: Google AI integration tests and samples
165-
- 🚧 **Phase 4**: Vertex AI chat client with enterprise features
166-
- 🚧 **Phase 5**: Vertex AI integration tests and samples
167-
- 🚧 **Phase 6**: Advanced features (context caching, safety settings, etc.)
101+
- 🚧 **Phase 4**: Advanced features (context caching, safety settings, structured output)
102+
103+
> **Note**: Vertex AI support may be added in a future iteration based on user demand.
168104
169105
## Examples
170106

171-
Examples will be available once the chat clients are implemented. Check back soon or watch the [repository](https://github.com/microsoft/agent-framework) for updates.
107+
Examples will be available once the chat client is implemented. Check back soon or watch the [repository](https://github.com/microsoft/agent-framework) for updates.
172108

173109
## Documentation
174110

175111
For more information:
176112
- [Google AI Documentation](https://ai.google.dev/docs)
177-
- [Vertex AI Documentation](https://cloud.google.com/vertex-ai/docs)
113+
- [Google Gemini API Migration Guide](https://ai.google.dev/gemini-api/docs/migrate)
178114
- [Agent Framework Documentation](https://aka.ms/agent-framework)
179115
- [Agent Framework Repository](https://github.com/microsoft/agent-framework)

python/packages/google/agent_framework_google/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
import importlib.metadata
44

5-
# NOTE: Client classes will be imported here in PR #2 and PR #4
6-
# from ._chat_client import GoogleAIChatClient, VertexAIChatClient
5+
# NOTE: Client class will be imported here in a future PR
6+
# from ._chat_client import GoogleAIChatClient
77

88
try:
99
__version__ = importlib.metadata.version(__name__)
1010
except importlib.metadata.PackageNotFoundError:
1111
__version__ = "0.0.0" # Fallback for development mode
1212

1313
__all__ = [
14-
# "GoogleAIChatClient", # Will be added in PR #2
15-
# "VertexAIChatClient", # Will be added in PR #4
14+
# "GoogleAIChatClient", # Will be added in a future PR
1615
"__version__",
1716
]

python/packages/google/agent_framework_google/_chat_client.py

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -47,53 +47,5 @@ class GoogleAISettings(AFBaseSettings):
4747
chat_model_id: str | None = None
4848

4949

50-
class VertexAISettings(AFBaseSettings):
51-
"""Vertex AI settings for Google Cloud access.
52-
53-
The settings are first loaded from environment variables with the prefix 'VERTEX_AI_'.
54-
If the environment variables are not found, the settings can be loaded from a .env file
55-
with the encoding 'utf-8'. If the settings are not found in the .env file, the settings
56-
are ignored; however, validation will fail alerting that the settings are missing.
57-
58-
Keyword Args:
59-
project_id: The Google Cloud project ID.
60-
location: The Google Cloud region (e.g., us-central1).
61-
chat_model_id: The Vertex AI chat model ID (e.g., gemini-1.5-pro).
62-
credentials_path: Optional path to service account JSON file.
63-
env_file_path: If provided, the .env settings are read from this file path location.
64-
env_file_encoding: The encoding of the .env file, defaults to 'utf-8'.
65-
66-
Examples:
67-
.. code-block:: python
68-
69-
from agent_framework.google import VertexAISettings
70-
71-
# Using environment variables
72-
# Set VERTEX_AI_PROJECT_ID=your-project-id
73-
# VERTEX_AI_LOCATION=us-central1
74-
# VERTEX_AI_CHAT_MODEL_ID=gemini-1.5-pro
75-
# GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
76-
77-
settings = VertexAISettings()
78-
79-
# Or passing parameters directly
80-
settings = VertexAISettings(
81-
project_id="your-project-id",
82-
location="us-central1",
83-
chat_model_id="gemini-1.5-pro"
84-
)
85-
86-
# Or loading from a .env file
87-
settings = VertexAISettings(env_file_path="path/to/.env")
88-
"""
89-
90-
env_prefix: ClassVar[str] = "VERTEX_AI_"
91-
92-
project_id: str | None = None
93-
location: str | None = None
94-
chat_model_id: str | None = None
95-
credentials_path: str | None = None
96-
97-
98-
# NOTE: Client implementations will be added in PR #2 and PR #4
99-
# For PR #1, we're only setting up the package structure and settings
50+
# NOTE: Client implementations will be added in a future PR
51+
# For now, we're only setting up the package structure and settings

python/packages/google/pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "agent-framework-google"
3-
description = "Google AI and Vertex AI integration for Microsoft Agent Framework."
3+
description = "Google AI (Gemini API) integration for Microsoft Agent Framework."
44
authors = [{ name = "Microsoft", email = "[email protected]"}]
55
readme = "README.md"
66
requires-python = ">=3.10"
@@ -19,12 +19,12 @@ classifiers = [
1919
"Programming Language :: Python :: 3.11",
2020
"Programming Language :: Python :: 3.12",
2121
"Programming Language :: Python :: 3.13",
22+
"Programming Language :: Python :: 3.14",
2223
"Typing :: Typed",
2324
]
2425
dependencies = [
2526
"agent-framework-core",
26-
"google-generativeai>=0.8,<1",
27-
"google-cloud-aiplatform>=1.60,<2",
27+
"google-genai>=0.2,<1",
2828
]
2929

3030
[tool.uv]

python/packages/google/tests/conftest.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,3 @@ def google_ai_unit_test_env(monkeypatch, exclude_list, override_env_param_dict):
3939
monkeypatch.setenv(key, value) # type: ignore
4040

4141
return env_vars
42-
43-
44-
@fixture
45-
def vertex_ai_unit_test_env(monkeypatch, exclude_list, override_env_param_dict): # type: ignore
46-
"""Fixture to set environment variables for VertexAISettings."""
47-
if exclude_list is None:
48-
exclude_list = []
49-
50-
if override_env_param_dict is None:
51-
override_env_param_dict = {}
52-
53-
env_vars = {
54-
"VERTEX_AI_PROJECT_ID": "test-project-id",
55-
"VERTEX_AI_LOCATION": "us-central1",
56-
"VERTEX_AI_CHAT_MODEL_ID": "gemini-1.5-pro",
57-
}
58-
59-
env_vars.update(override_env_param_dict) # type: ignore
60-
61-
for key, value in env_vars.items():
62-
if key in exclude_list:
63-
monkeypatch.delenv(key, raising=False) # type: ignore
64-
continue
65-
monkeypatch.setenv(key, value) # type: ignore
66-
67-
return env_vars
Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) Microsoft. All rights reserved.
22
import pytest
33

4-
from agent_framework_google._chat_client import GoogleAISettings, VertexAISettings
4+
from agent_framework_google._chat_client import GoogleAISettings
55

66

77
# region GoogleAISettings Tests
@@ -55,81 +55,3 @@ def test_google_ai_settings_override_env() -> None:
5555

5656

5757
# endregion
58-
59-
60-
# region VertexAISettings Tests
61-
62-
63-
def test_vertex_ai_settings_from_env(vertex_ai_unit_test_env: dict[str, str]) -> None:
64-
"""Test VertexAISettings initialization from environment variables."""
65-
settings = VertexAISettings()
66-
assert settings.project_id == vertex_ai_unit_test_env["VERTEX_AI_PROJECT_ID"]
67-
assert settings.location == vertex_ai_unit_test_env["VERTEX_AI_LOCATION"]
68-
assert settings.chat_model_id == vertex_ai_unit_test_env["VERTEX_AI_CHAT_MODEL_ID"]
69-
70-
71-
def test_vertex_ai_settings_from_params() -> None:
72-
"""Test VertexAISettings initialization from parameters."""
73-
settings = VertexAISettings(
74-
project_id="my-project",
75-
location="europe-west4",
76-
chat_model_id="gemini-1.5-pro",
77-
credentials_path="/path/to/creds.json",
78-
)
79-
assert settings.project_id == "my-project"
80-
assert settings.location == "europe-west4"
81-
assert settings.chat_model_id == "gemini-1.5-pro"
82-
assert settings.credentials_path == "/path/to/creds.json"
83-
84-
85-
@pytest.mark.parametrize("exclude_list", [["VERTEX_AI_PROJECT_ID"]], indirect=True)
86-
def test_vertex_ai_settings_missing_project_id(vertex_ai_unit_test_env: dict[str, str]) -> None:
87-
"""Test VertexAISettings when project ID is missing."""
88-
settings = VertexAISettings()
89-
assert settings.project_id is None
90-
assert settings.location == vertex_ai_unit_test_env["VERTEX_AI_LOCATION"]
91-
assert settings.chat_model_id == vertex_ai_unit_test_env["VERTEX_AI_CHAT_MODEL_ID"]
92-
93-
94-
@pytest.mark.parametrize("exclude_list", [["VERTEX_AI_LOCATION"]], indirect=True)
95-
def test_vertex_ai_settings_missing_location(vertex_ai_unit_test_env: dict[str, str]) -> None:
96-
"""Test VertexAISettings when location is missing."""
97-
settings = VertexAISettings()
98-
assert settings.project_id == vertex_ai_unit_test_env["VERTEX_AI_PROJECT_ID"]
99-
assert settings.location is None
100-
assert settings.chat_model_id == vertex_ai_unit_test_env["VERTEX_AI_CHAT_MODEL_ID"]
101-
102-
103-
@pytest.mark.parametrize("exclude_list", [["VERTEX_AI_CHAT_MODEL_ID"]], indirect=True)
104-
def test_vertex_ai_settings_missing_model_id(vertex_ai_unit_test_env: dict[str, str]) -> None:
105-
"""Test VertexAISettings when model ID is missing."""
106-
settings = VertexAISettings()
107-
assert settings.project_id == vertex_ai_unit_test_env["VERTEX_AI_PROJECT_ID"]
108-
assert settings.location == vertex_ai_unit_test_env["VERTEX_AI_LOCATION"]
109-
assert settings.chat_model_id is None
110-
111-
112-
def test_vertex_ai_settings_override_env() -> None:
113-
"""Test VertexAISettings parameter override of environment variables."""
114-
settings = VertexAISettings(
115-
project_id="override-project",
116-
location="asia-southeast1",
117-
chat_model_id="gemini-2.0-flash",
118-
)
119-
assert settings.project_id == "override-project"
120-
assert settings.location == "asia-southeast1"
121-
assert settings.chat_model_id == "gemini-2.0-flash"
122-
123-
124-
def test_vertex_ai_settings_credentials_path() -> None:
125-
"""Test VertexAISettings with credentials path."""
126-
settings = VertexAISettings(
127-
project_id="test-project",
128-
location="us-central1",
129-
chat_model_id="gemini-1.5-pro",
130-
credentials_path="/custom/path/creds.json",
131-
)
132-
assert settings.credentials_path == "/custom/path/creds.json"
133-
134-
135-
# endregion

0 commit comments

Comments
 (0)