Skip to content

Commit f6387c4

Browse files
google-genai-botcopybara-github
authored andcommitted
refactor: Upgrade Gemini Data Analytics API version to v1
Upgrades GDA API endpoints from v1beta to v1 in data agent and bigquery data insights tools. Also updates the request payloads to match the new v1 API contract (removing project and options fields). PiperOrigin-RevId: 948512493
1 parent 00760f8 commit f6387c4

4 files changed

Lines changed: 9 additions & 17 deletions

File tree

src/google/adk/integrations/bigquery/data_insights_tool.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ def ask_data_insights(
119119
"Content-Type": "application/json",
120120
"X-Goog-API-Client": _GDA_CLIENT_ID,
121121
}
122-
ca_url = (
123-
f"{endpoint}/v1beta/projects/{project_id}/locations/{location}:chat"
124-
)
122+
ca_url = f"{endpoint}/v1/projects/{project_id}/locations/{location}:chat"
125123

126124
instructions = """**INSTRUCTIONS - FOLLOW THESE RULES:**
127125
1. **CONTENT:** Your answer should present the supporting data and then provide a conclusion based on that data, including relevant details and observations where possible.
@@ -131,14 +129,12 @@ def ask_data_insights(
131129
"""
132130

133131
ca_payload = {
134-
"project": f"projects/{project_id}",
135132
"messages": [{"userMessage": {"text": user_query_with_context}}],
136133
"inlineContext": {
137134
"datasourceReferences": {
138135
"bq": {"tableReferences": table_references}
139136
},
140137
"systemInstruction": instructions,
141-
"options": {"chart": {"image": {"noImage": {}}}},
142138
},
143139
"clientIdEnum": _GDA_CLIENT_ID,
144140
}

src/google/adk/tools/data_agent/data_agent_tool.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def list_accessible_data_agents(
9595
"""
9696
try:
9797
session, endpoint = _gda_stream_util.get_gda_session(credentials)
98-
base_url = f"{endpoint}/v1beta"
98+
base_url = f"{endpoint}/v1"
9999
headers = {
100100
"Content-Type": "application/json",
101101
"X-Goog-API-Client": _GDA_CLIENT_ID,
@@ -125,7 +125,7 @@ def _get_data_agent_info(
125125
) -> dict[str, Any]:
126126
try:
127127
endpoint = _gda_stream_util.get_gda_endpoint()
128-
base_url = f"{endpoint}/v1beta"
128+
base_url = f"{endpoint}/v1"
129129
headers = {
130130
"Content-Type": "application/json",
131131
"X-Goog-API-Client": _GDA_CLIENT_ID,
@@ -289,7 +289,7 @@ def ask_data_agent(
289289
try:
290290
session, endpoint = _gda_stream_util.get_gda_session(credentials)
291291
with session:
292-
base_url = f"{endpoint}/v1beta"
292+
base_url = f"{endpoint}/v1"
293293
headers = {
294294
"Content-Type": "application/json",
295295
"X-Goog-API-Client": _GDA_CLIENT_ID,

tests/unittests/integrations/bigquery/test_bigquery_data_insights_tool.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,12 @@ def test_ask_data_insights_pipeline_from_file(mock_get_session, case_file_path):
7575
assert result["response"] == expected_final_list
7676
mock_get_session.assert_called_once_with(mock_creds)
7777
mock_session.post.assert_called_once_with(
78-
"https://geminidataanalytics.mtls.googleapis.com/v1beta/projects/test-project/locations/global:chat",
78+
"https://geminidataanalytics.mtls.googleapis.com/v1/projects/test-project/locations/global:chat",
7979
json={
80-
"project": "projects/test-project",
8180
"messages": [{"userMessage": {"text": case_data["user_question"]}}],
8281
"inlineContext": {
8382
"datasourceReferences": {"bq": {"tableReferences": []}},
8483
"systemInstruction": mock.ANY,
85-
"options": {"chart": {"image": {"noImage": {}}}},
8684
},
8785
"clientIdEnum": "GOOGLE_ADK",
8886
},
@@ -132,14 +130,12 @@ def test_ask_data_insights_success(mock_get_session, mock_get_stream):
132130
mock_get_session.assert_called_once_with(mock_creds)
133131
mock_get_stream.assert_called_once_with(
134132
mock_session,
135-
"https://geminidataanalytics.mtls.googleapis.com/v1beta/projects/test-project/locations/global:chat",
133+
"https://geminidataanalytics.mtls.googleapis.com/v1/projects/test-project/locations/global:chat",
136134
{
137-
"project": "projects/test-project",
138135
"messages": [{"userMessage": {"text": "test query"}}],
139136
"inlineContext": {
140137
"datasourceReferences": {"bq": {"tableReferences": []}},
141138
"systemInstruction": mock.ANY,
142-
"options": {"chart": {"image": {"noImage": {}}}},
143139
},
144140
"clientIdEnum": "GOOGLE_ADK",
145141
},

tests/unittests/tools/data_agent/test_data_agent_tool.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_list_accessible_data_agents_success(mock_get_session):
4040
assert result["response"] == ["agent1", "agent2"]
4141
mock_get_session.assert_called_once_with(mock_creds)
4242
mock_session.get.assert_called_once_with(
43-
"https://geminidataanalytics.googleapis.com/v1beta/projects/test-project/locations/global/dataAgents:listAccessible",
43+
"https://geminidataanalytics.googleapis.com/v1/projects/test-project/locations/global/dataAgents:listAccessible",
4444
headers={
4545
"Content-Type": "application/json",
4646
"X-Goog-API-Client": "GOOGLE_ADK",
@@ -94,7 +94,7 @@ def test_get_data_agent_info_success(mock_get_session, mock_get_endpoint):
9494
mock_get_session.assert_called_once_with(mock_creds)
9595
mock_get_endpoint.assert_called_once()
9696
mock_session.get.assert_called_once_with(
97-
"https://geminidataanalytics.googleapis.com/v1beta/agent_name",
97+
"https://geminidataanalytics.googleapis.com/v1/agent_name",
9898
headers={
9999
"Content-Type": "application/json",
100100
"X-Goog-API-Client": "GOOGLE_ADK",
@@ -171,7 +171,7 @@ def test_ask_data_agent_success(
171171
mock_get_session.assert_called_once_with(mock_creds)
172172
mock_get_stream.assert_called_once_with(
173173
mock_session,
174-
"https://geminidataanalytics.googleapis.com/v1beta/projects/p/locations/l:chat",
174+
"https://geminidataanalytics.googleapis.com/v1/projects/p/locations/l:chat",
175175
{
176176
"messages": [{"userMessage": {"text": "query"}}],
177177
"dataAgentContext": {

0 commit comments

Comments
 (0)