google-cloud-db-context-engineering 0.7.0__tar.gz → 0.7.2__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.
- {google_cloud_db_context_engineering-0.7.0/src/google_cloud_db_context_engineering.egg-info → google_cloud_db_context_engineering-0.7.2}/PKG-INFO +20 -8
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/README.md +19 -7
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/pyproject.toml +2 -2
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/evaluate/db_generators/alloydb.py +17 -19
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/evaluate/db_generators/base.py +9 -15
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/evaluate/db_generators/mysql.py +17 -19
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/evaluate/db_generators/postgres.py +17 -19
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/evaluate/db_generators/spanner.py +18 -18
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2/src/google_cloud_db_context_engineering.egg-info}/PKG-INFO +20 -8
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/LICENSE +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/setup.cfg +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/__init__.py +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/common/__init__.py +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/common/config.py +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/common/context_mutator.py +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/common/context_store_client.py +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/dataset/__init__.py +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/dataset/dataset_generator.py +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/evaluate/__init__.py +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/evaluate/db_generators/__init__.py +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/evaluate/evaluate_generator.py +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/evaluate/result_reader.py +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/main.py +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/model/__init__.py +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google/cloud/db_context_enrichment/model/context.py +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google_cloud_db_context_engineering.egg-info/SOURCES.txt +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google_cloud_db_context_engineering.egg-info/dependency_links.txt +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google_cloud_db_context_engineering.egg-info/entry_points.txt +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google_cloud_db_context_engineering.egg-info/requires.txt +0 -0
- {google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/src/google_cloud_db_context_engineering.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: google-cloud-db-context-engineering
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: A FastMCP server for generating natural language to SQL templates from database schemas.
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -20,25 +20,25 @@ This is not an officially supported Google product. This project is not eligible
|
|
|
20
20
|
|
|
21
21
|
# Context Engineering Agent
|
|
22
22
|
|
|
23
|
-
The **Context Engineering Agent** is an AI coding agent plugin designed to run in developer agent harnesses (such as Claude Code, Antigravity, or Gemini CLI). It generates, evaluates, and iteratively tunes tailored context artifacts (`ContextSets` comprising `Templates`, `Facets`, and `Value Searches`) to enrich database schemas for **Gemini Data Analytics's data agent developer platform tools**,
|
|
23
|
+
The **Context Engineering Agent** is an AI coding agent plugin designed to run in developer agent harnesses (such as Claude Code, Antigravity, or Gemini CLI). It generates, evaluates, and iteratively tunes tailored context artifacts (`ContextSets` comprising `Templates`, `Facets`, and `Value Searches`) to enrich database schemas for **Gemini Data Analytics's data agent developer platform tools**, supporting both **relational SQL** and **Graph Query Language (GQL)** across [AlloyDB](https://docs.cloud.google.com/gemini/data-agents/querydata/alloydb/data-agent-overview), Cloud SQL ([PostgreSQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-postgres/data-agent-overview) / [MySQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-mysql/data-agent-overview)), and [Cloud Spanner (GoogleSQL & Spanner Graph)](https://docs.cloud.google.com/gemini/data-agents/querydata/spanner/data-agent-overview).
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
27
27
|
## Why Context Engineering?
|
|
28
28
|
|
|
29
|
-
When building data agents and natural language analytics interfaces, accurately translating user intent into database queries is critical.
|
|
29
|
+
When building data agents and natural language analytics interfaces, accurately translating user intent into database queries—whether relational SQL, pure GQL, or hybrid graph queries—is critical.
|
|
30
30
|
|
|
31
|
-
As outlined in **Build Context with Context Engineering Agent** ([AlloyDB](https://docs.cloud.google.com/gemini/data-agents/querydata/alloydb/build-context-gemini-cli) | Cloud SQL: [PostgreSQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-postgres/build-context-gemini-cli) / [MySQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-mysql/build-context-gemini-cli) | [Spanner (GoogleSQL)](https://docs.cloud.google.com/gemini/data-agents/querydata/spanner/build-context-gemini-cli)), by optimizing a `ContextSet` to match your application's expected query stream, the **QueryData API** acts as a data agent tool capable of achieving **~100% NL-to-SQL translation accuracy with low latency**.
|
|
31
|
+
As outlined in **Build Context with Context Engineering Agent** ([AlloyDB](https://docs.cloud.google.com/gemini/data-agents/querydata/alloydb/build-context-gemini-cli) | Cloud SQL: [PostgreSQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-postgres/build-context-gemini-cli) / [MySQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-mysql/build-context-gemini-cli) | [Spanner (GoogleSQL)](https://docs.cloud.google.com/gemini/data-agents/querydata/spanner/build-context-gemini-cli)), by optimizing a `ContextSet` to match your application's expected query stream, the **QueryData API** acts as a data agent tool capable of achieving **~100% NL-to-SQL/GQL translation accuracy with low latency**.
|
|
32
32
|
|
|
33
33
|
---
|
|
34
34
|
|
|
35
35
|
## Core Concepts
|
|
36
36
|
|
|
37
|
-
A `ContextSet` is the central artifact generated and managed by the agent, containing structured knowledge in three primary forms:
|
|
37
|
+
A `ContextSet` is the central artifact generated and managed by the agent, containing structured knowledge across SQL and GQL query domains in three primary forms:
|
|
38
38
|
|
|
39
|
-
* **Templates**: Link natural language query patterns to complete query statements.
|
|
40
|
-
* **Facets**: Reusable, modular query fragments (e.g., parameterized `WHERE` clauses
|
|
41
|
-
* **Value Searches**: Specialized mapping queries that dynamically resolve user-supplied values (e.g., *"Lndn"*) to database records (*"London"*) via the capabilities of the underlying database, such as embedding search, AI operators, or
|
|
39
|
+
* **Templates**: Link natural language query patterns to complete query statements (supporting relational SQL, pure GQL with `GRAPH ... MATCH`, and hybrid `GRAPH_TABLE` queries for Spanner Graph).
|
|
40
|
+
* **Facets**: Reusable, modular query fragments (e.g., parameterized `WHERE` clauses, specialized join filters, or graph `MATCH` traversal patterns) linked to domain vocabulary.
|
|
41
|
+
* **Value Searches**: Specialized mapping queries that dynamically resolve user-supplied values (e.g., *"Lndn"*) to database records (*"London"*) via the capabilities of the underlying database, such as embedding search, AI operators, or trigram search on relational and graph property tables.
|
|
42
42
|
|
|
43
43
|
For full schema details, structure specifications, and dialect-specific JSON representations of `ContextSets`, see the official **Context Sets Overview** ([AlloyDB](https://docs.cloud.google.com/gemini/data-agents/querydata/alloydb/context-sets-overview) | Cloud SQL: [PostgreSQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-postgres/context-sets-overview) / [MySQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-mysql/context-sets-overview) | [Spanner (GoogleSQL)](https://docs.cloud.google.com/gemini/data-agents/querydata/spanner/context-sets-overview)).
|
|
44
44
|
|
|
@@ -95,6 +95,18 @@ You can provide business artifacts directly to the agent from local filesystems
|
|
|
95
95
|
|
|
96
96
|
---
|
|
97
97
|
|
|
98
|
+
## Installing via a compatible Agent Plugins client
|
|
99
|
+
|
|
100
|
+
This repository ships a valid [Agent Plugins](https://github.com/agentplugins/agent-plugins-spec) (v1) plugin under [`plugin/`](plugin/), bundling both agent skills and its MCP servers. Any [Agent Plugins–compatible client](https://agent-plugins.org/compatible-clients) (VS Code, Cursor, GitHub Copilot, Kiro, and others) can install it directly using its own built-in plugin command — no extra tooling required — by pointing at this repository:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
https://github.com/GoogleCloudPlatform/db-context-enrichment
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
See your agent's documentation for its exact install command.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
98
110
|
## How to Use
|
|
99
111
|
|
|
100
112
|
Launch your agent harness (Gemini CLI, Claude Code, or Antigravity) in your workspace directory and interact in natural language:
|
{google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/README.md
RENAMED
|
@@ -2,25 +2,25 @@ This is not an officially supported Google product. This project is not eligible
|
|
|
2
2
|
|
|
3
3
|
# Context Engineering Agent
|
|
4
4
|
|
|
5
|
-
The **Context Engineering Agent** is an AI coding agent plugin designed to run in developer agent harnesses (such as Claude Code, Antigravity, or Gemini CLI). It generates, evaluates, and iteratively tunes tailored context artifacts (`ContextSets` comprising `Templates`, `Facets`, and `Value Searches`) to enrich database schemas for **Gemini Data Analytics's data agent developer platform tools**,
|
|
5
|
+
The **Context Engineering Agent** is an AI coding agent plugin designed to run in developer agent harnesses (such as Claude Code, Antigravity, or Gemini CLI). It generates, evaluates, and iteratively tunes tailored context artifacts (`ContextSets` comprising `Templates`, `Facets`, and `Value Searches`) to enrich database schemas for **Gemini Data Analytics's data agent developer platform tools**, supporting both **relational SQL** and **Graph Query Language (GQL)** across [AlloyDB](https://docs.cloud.google.com/gemini/data-agents/querydata/alloydb/data-agent-overview), Cloud SQL ([PostgreSQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-postgres/data-agent-overview) / [MySQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-mysql/data-agent-overview)), and [Cloud Spanner (GoogleSQL & Spanner Graph)](https://docs.cloud.google.com/gemini/data-agents/querydata/spanner/data-agent-overview).
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## Why Context Engineering?
|
|
10
10
|
|
|
11
|
-
When building data agents and natural language analytics interfaces, accurately translating user intent into database queries is critical.
|
|
11
|
+
When building data agents and natural language analytics interfaces, accurately translating user intent into database queries—whether relational SQL, pure GQL, or hybrid graph queries—is critical.
|
|
12
12
|
|
|
13
|
-
As outlined in **Build Context with Context Engineering Agent** ([AlloyDB](https://docs.cloud.google.com/gemini/data-agents/querydata/alloydb/build-context-gemini-cli) | Cloud SQL: [PostgreSQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-postgres/build-context-gemini-cli) / [MySQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-mysql/build-context-gemini-cli) | [Spanner (GoogleSQL)](https://docs.cloud.google.com/gemini/data-agents/querydata/spanner/build-context-gemini-cli)), by optimizing a `ContextSet` to match your application's expected query stream, the **QueryData API** acts as a data agent tool capable of achieving **~100% NL-to-SQL translation accuracy with low latency**.
|
|
13
|
+
As outlined in **Build Context with Context Engineering Agent** ([AlloyDB](https://docs.cloud.google.com/gemini/data-agents/querydata/alloydb/build-context-gemini-cli) | Cloud SQL: [PostgreSQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-postgres/build-context-gemini-cli) / [MySQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-mysql/build-context-gemini-cli) | [Spanner (GoogleSQL)](https://docs.cloud.google.com/gemini/data-agents/querydata/spanner/build-context-gemini-cli)), by optimizing a `ContextSet` to match your application's expected query stream, the **QueryData API** acts as a data agent tool capable of achieving **~100% NL-to-SQL/GQL translation accuracy with low latency**.
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
17
|
## Core Concepts
|
|
18
18
|
|
|
19
|
-
A `ContextSet` is the central artifact generated and managed by the agent, containing structured knowledge in three primary forms:
|
|
19
|
+
A `ContextSet` is the central artifact generated and managed by the agent, containing structured knowledge across SQL and GQL query domains in three primary forms:
|
|
20
20
|
|
|
21
|
-
* **Templates**: Link natural language query patterns to complete query statements.
|
|
22
|
-
* **Facets**: Reusable, modular query fragments (e.g., parameterized `WHERE` clauses
|
|
23
|
-
* **Value Searches**: Specialized mapping queries that dynamically resolve user-supplied values (e.g., *"Lndn"*) to database records (*"London"*) via the capabilities of the underlying database, such as embedding search, AI operators, or
|
|
21
|
+
* **Templates**: Link natural language query patterns to complete query statements (supporting relational SQL, pure GQL with `GRAPH ... MATCH`, and hybrid `GRAPH_TABLE` queries for Spanner Graph).
|
|
22
|
+
* **Facets**: Reusable, modular query fragments (e.g., parameterized `WHERE` clauses, specialized join filters, or graph `MATCH` traversal patterns) linked to domain vocabulary.
|
|
23
|
+
* **Value Searches**: Specialized mapping queries that dynamically resolve user-supplied values (e.g., *"Lndn"*) to database records (*"London"*) via the capabilities of the underlying database, such as embedding search, AI operators, or trigram search on relational and graph property tables.
|
|
24
24
|
|
|
25
25
|
For full schema details, structure specifications, and dialect-specific JSON representations of `ContextSets`, see the official **Context Sets Overview** ([AlloyDB](https://docs.cloud.google.com/gemini/data-agents/querydata/alloydb/context-sets-overview) | Cloud SQL: [PostgreSQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-postgres/context-sets-overview) / [MySQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-mysql/context-sets-overview) | [Spanner (GoogleSQL)](https://docs.cloud.google.com/gemini/data-agents/querydata/spanner/context-sets-overview)).
|
|
26
26
|
|
|
@@ -77,6 +77,18 @@ You can provide business artifacts directly to the agent from local filesystems
|
|
|
77
77
|
|
|
78
78
|
---
|
|
79
79
|
|
|
80
|
+
## Installing via a compatible Agent Plugins client
|
|
81
|
+
|
|
82
|
+
This repository ships a valid [Agent Plugins](https://github.com/agentplugins/agent-plugins-spec) (v1) plugin under [`plugin/`](plugin/), bundling both agent skills and its MCP servers. Any [Agent Plugins–compatible client](https://agent-plugins.org/compatible-clients) (VS Code, Cursor, GitHub Copilot, Kiro, and others) can install it directly using its own built-in plugin command — no extra tooling required — by pointing at this repository:
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
https://github.com/GoogleCloudPlatform/db-context-enrichment
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
See your agent's documentation for its exact install command.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
80
92
|
## How to Use
|
|
81
93
|
|
|
82
94
|
Launch your agent harness (Gemini CLI, Claude Code, or Antigravity) in your workspace directory and interact in natural language:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "google-cloud-db-context-engineering"
|
|
3
|
-
version = "0.7.
|
|
3
|
+
version = "0.7.2"
|
|
4
4
|
description = "A FastMCP server for generating natural language to SQL templates from database schemas."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
@@ -46,7 +46,7 @@ dev = [
|
|
|
46
46
|
|
|
47
47
|
[tool.db-context-engineering]
|
|
48
48
|
toolbox_version = "1.4.0"
|
|
49
|
-
evalbench_version = "1.
|
|
49
|
+
evalbench_version = "1.12.0"
|
|
50
50
|
|
|
51
51
|
[tool.ruff]
|
|
52
52
|
line-length = 88
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
|
|
3
|
-
import google.cloud.geminidataanalytics_v1beta as gda
|
|
4
3
|
import yaml
|
|
5
4
|
|
|
6
5
|
from .base import BaseDBConfigGenerator
|
|
@@ -52,21 +51,20 @@ class AlloyDBConfigGenerator(BaseDBConfigGenerator):
|
|
|
52
51
|
db_config, sort_keys=False, default_flow_style=False
|
|
53
52
|
).strip()
|
|
54
53
|
|
|
55
|
-
def build_datasource_reference(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
agent_context_reference=
|
|
69
|
-
context_set_id
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return datasource_ref
|
|
54
|
+
def build_datasource_reference(self, context_set_id: str) -> dict[str, Any]:
|
|
55
|
+
ref: dict[str, Any] = {
|
|
56
|
+
"alloydb": {
|
|
57
|
+
"database_reference": {
|
|
58
|
+
"project_id": self.project,
|
|
59
|
+
"region": self.region,
|
|
60
|
+
"cluster_id": self.cluster,
|
|
61
|
+
"instance_id": self.instance,
|
|
62
|
+
"database_id": self.database,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if context_set_id:
|
|
67
|
+
ref["alloydb"]["agent_context_reference"] = {
|
|
68
|
+
"context_set_id": context_set_id
|
|
69
|
+
}
|
|
70
|
+
return ref
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
2
|
from typing import Any
|
|
3
3
|
|
|
4
|
-
import google.cloud.geminidataanalytics_v1beta as gda
|
|
5
4
|
import yaml
|
|
6
|
-
from google.protobuf.json_format import MessageToDict
|
|
7
5
|
|
|
8
6
|
|
|
9
7
|
class BaseDBConfigGenerator(ABC):
|
|
10
8
|
"""
|
|
11
9
|
Abstract Base Class enforcing the construction contract for Evalbench database topologies.
|
|
12
10
|
Each distinct DB type (Spanner, Postgres, AlloyDB, MySQL) must inherit and implement
|
|
13
|
-
the mappings required by both the standard EvalBench framework and the GDA
|
|
11
|
+
the mappings required by both the standard EvalBench framework and the GDA REST API.
|
|
14
12
|
"""
|
|
15
13
|
|
|
16
14
|
SOURCE_TYPE = "unknown"
|
|
@@ -29,11 +27,9 @@ class BaseDBConfigGenerator(ABC):
|
|
|
29
27
|
raise NotImplementedError("Subclasses must implement generate_db_config")
|
|
30
28
|
|
|
31
29
|
@abstractmethod
|
|
32
|
-
def build_datasource_reference(
|
|
33
|
-
self, context_set_id: str
|
|
34
|
-
) -> gda.DatasourceReferences:
|
|
30
|
+
def build_datasource_reference(self, context_set_id: str) -> dict[str, Any]:
|
|
35
31
|
"""
|
|
36
|
-
Constructs the
|
|
32
|
+
Constructs the REST datasource_references dictionary required by the QueryDataAPI
|
|
37
33
|
context generation flow.
|
|
38
34
|
"""
|
|
39
35
|
raise NotImplementedError(
|
|
@@ -54,23 +50,21 @@ class BaseDBConfigGenerator(ABC):
|
|
|
54
50
|
|
|
55
51
|
def generate_model_config(self, context_set_id: str) -> str:
|
|
56
52
|
"""
|
|
57
|
-
Standardized Model Builder converting the
|
|
53
|
+
Standardized Model Builder converting the datasource reference dict into an EvalBench model dict.
|
|
58
54
|
"""
|
|
59
55
|
datasource_ref = self.build_datasource_reference(context_set_id)
|
|
60
56
|
|
|
61
|
-
query_context = gda.QueryDataContext(datasource_references=datasource_ref)
|
|
62
|
-
|
|
63
|
-
query_context_dict = MessageToDict(
|
|
64
|
-
query_context._pb, preserving_proto_field_name=True
|
|
65
|
-
)
|
|
66
|
-
|
|
67
57
|
model_config = {
|
|
68
58
|
"generator": "query_data_api",
|
|
69
59
|
"project_id": self.params.get("project"),
|
|
70
60
|
"location": self.params.get("region") or "global",
|
|
71
|
-
"
|
|
61
|
+
"use_rest_api": True,
|
|
62
|
+
"context": {"datasource_references": datasource_ref},
|
|
72
63
|
}
|
|
73
64
|
|
|
65
|
+
if self.params.get("api_endpoint"):
|
|
66
|
+
model_config["api_endpoint"] = self.params.get("api_endpoint")
|
|
67
|
+
|
|
74
68
|
return yaml.safe_dump(
|
|
75
69
|
model_config, sort_keys=False, default_flow_style=False
|
|
76
70
|
).strip()
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
|
|
3
|
-
import google.cloud.geminidataanalytics_v1beta as gda
|
|
4
3
|
import yaml
|
|
5
4
|
|
|
6
5
|
from .base import BaseDBConfigGenerator
|
|
@@ -49,21 +48,20 @@ class MySQLConfigGenerator(BaseDBConfigGenerator):
|
|
|
49
48
|
db_config, sort_keys=False, default_flow_style=False
|
|
50
49
|
).strip()
|
|
51
50
|
|
|
52
|
-
def build_datasource_reference(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
agent_context_reference=
|
|
66
|
-
context_set_id
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return datasource_ref
|
|
51
|
+
def build_datasource_reference(self, context_set_id: str) -> dict[str, Any]:
|
|
52
|
+
ref: dict[str, Any] = {
|
|
53
|
+
"cloud_sql_reference": {
|
|
54
|
+
"database_reference": {
|
|
55
|
+
"engine": "MYSQL",
|
|
56
|
+
"project_id": self.project,
|
|
57
|
+
"region": self.region,
|
|
58
|
+
"instance_id": self.instance,
|
|
59
|
+
"database_id": self.database,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if context_set_id:
|
|
64
|
+
ref["cloud_sql_reference"]["agent_context_reference"] = {
|
|
65
|
+
"context_set_id": context_set_id
|
|
66
|
+
}
|
|
67
|
+
return ref
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
|
|
3
|
-
import google.cloud.geminidataanalytics_v1beta as gda
|
|
4
3
|
import yaml
|
|
5
4
|
|
|
6
5
|
from .base import BaseDBConfigGenerator
|
|
@@ -49,21 +48,20 @@ class PostgresConfigGenerator(BaseDBConfigGenerator):
|
|
|
49
48
|
db_config, sort_keys=False, default_flow_style=False
|
|
50
49
|
).strip()
|
|
51
50
|
|
|
52
|
-
def build_datasource_reference(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
agent_context_reference=
|
|
66
|
-
context_set_id
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return datasource_ref
|
|
51
|
+
def build_datasource_reference(self, context_set_id: str) -> dict[str, Any]:
|
|
52
|
+
ref: dict[str, Any] = {
|
|
53
|
+
"cloud_sql_reference": {
|
|
54
|
+
"database_reference": {
|
|
55
|
+
"engine": "POSTGRESQL",
|
|
56
|
+
"project_id": self.project,
|
|
57
|
+
"region": self.region,
|
|
58
|
+
"instance_id": self.instance,
|
|
59
|
+
"database_id": self.database,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if context_set_id:
|
|
64
|
+
ref["cloud_sql_reference"]["agent_context_reference"] = {
|
|
65
|
+
"context_set_id": context_set_id
|
|
66
|
+
}
|
|
67
|
+
return ref
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
|
|
3
|
-
import google.cloud.geminidataanalytics_v1beta as gda
|
|
4
3
|
import yaml
|
|
5
4
|
|
|
6
5
|
from .base import BaseDBConfigGenerator
|
|
@@ -43,20 +42,21 @@ class SpannerConfigGenerator(BaseDBConfigGenerator):
|
|
|
43
42
|
db_config, sort_keys=False, default_flow_style=False
|
|
44
43
|
).strip()
|
|
45
44
|
|
|
46
|
-
def build_datasource_reference(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
def build_datasource_reference(self, context_set_id: str) -> dict[str, Any]:
|
|
46
|
+
database_ref: dict[str, Any] = {
|
|
47
|
+
"engine": "GOOGLE_SQL",
|
|
48
|
+
"project_id": self.project,
|
|
49
|
+
"instance_id": self.instance,
|
|
50
|
+
"database_id": self.database,
|
|
51
|
+
}
|
|
52
|
+
if graph_ids := self.params.get("graph_ids"):
|
|
53
|
+
if not isinstance(graph_ids, list) or not all(
|
|
54
|
+
isinstance(g, str) for g in graph_ids
|
|
55
|
+
):
|
|
56
|
+
raise ValueError("graph_ids must be a list of strings")
|
|
57
|
+
database_ref["graph_ids"] = graph_ids
|
|
58
|
+
|
|
59
|
+
spanner_ref: dict[str, Any] = {"database_reference": database_ref}
|
|
60
|
+
if context_set_id:
|
|
61
|
+
spanner_ref["agent_context_reference"] = {"context_set_id": context_set_id}
|
|
62
|
+
return {"spanner_reference": spanner_ref}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: google-cloud-db-context-engineering
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: A FastMCP server for generating natural language to SQL templates from database schemas.
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -20,25 +20,25 @@ This is not an officially supported Google product. This project is not eligible
|
|
|
20
20
|
|
|
21
21
|
# Context Engineering Agent
|
|
22
22
|
|
|
23
|
-
The **Context Engineering Agent** is an AI coding agent plugin designed to run in developer agent harnesses (such as Claude Code, Antigravity, or Gemini CLI). It generates, evaluates, and iteratively tunes tailored context artifacts (`ContextSets` comprising `Templates`, `Facets`, and `Value Searches`) to enrich database schemas for **Gemini Data Analytics's data agent developer platform tools**,
|
|
23
|
+
The **Context Engineering Agent** is an AI coding agent plugin designed to run in developer agent harnesses (such as Claude Code, Antigravity, or Gemini CLI). It generates, evaluates, and iteratively tunes tailored context artifacts (`ContextSets` comprising `Templates`, `Facets`, and `Value Searches`) to enrich database schemas for **Gemini Data Analytics's data agent developer platform tools**, supporting both **relational SQL** and **Graph Query Language (GQL)** across [AlloyDB](https://docs.cloud.google.com/gemini/data-agents/querydata/alloydb/data-agent-overview), Cloud SQL ([PostgreSQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-postgres/data-agent-overview) / [MySQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-mysql/data-agent-overview)), and [Cloud Spanner (GoogleSQL & Spanner Graph)](https://docs.cloud.google.com/gemini/data-agents/querydata/spanner/data-agent-overview).
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
27
27
|
## Why Context Engineering?
|
|
28
28
|
|
|
29
|
-
When building data agents and natural language analytics interfaces, accurately translating user intent into database queries is critical.
|
|
29
|
+
When building data agents and natural language analytics interfaces, accurately translating user intent into database queries—whether relational SQL, pure GQL, or hybrid graph queries—is critical.
|
|
30
30
|
|
|
31
|
-
As outlined in **Build Context with Context Engineering Agent** ([AlloyDB](https://docs.cloud.google.com/gemini/data-agents/querydata/alloydb/build-context-gemini-cli) | Cloud SQL: [PostgreSQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-postgres/build-context-gemini-cli) / [MySQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-mysql/build-context-gemini-cli) | [Spanner (GoogleSQL)](https://docs.cloud.google.com/gemini/data-agents/querydata/spanner/build-context-gemini-cli)), by optimizing a `ContextSet` to match your application's expected query stream, the **QueryData API** acts as a data agent tool capable of achieving **~100% NL-to-SQL translation accuracy with low latency**.
|
|
31
|
+
As outlined in **Build Context with Context Engineering Agent** ([AlloyDB](https://docs.cloud.google.com/gemini/data-agents/querydata/alloydb/build-context-gemini-cli) | Cloud SQL: [PostgreSQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-postgres/build-context-gemini-cli) / [MySQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-mysql/build-context-gemini-cli) | [Spanner (GoogleSQL)](https://docs.cloud.google.com/gemini/data-agents/querydata/spanner/build-context-gemini-cli)), by optimizing a `ContextSet` to match your application's expected query stream, the **QueryData API** acts as a data agent tool capable of achieving **~100% NL-to-SQL/GQL translation accuracy with low latency**.
|
|
32
32
|
|
|
33
33
|
---
|
|
34
34
|
|
|
35
35
|
## Core Concepts
|
|
36
36
|
|
|
37
|
-
A `ContextSet` is the central artifact generated and managed by the agent, containing structured knowledge in three primary forms:
|
|
37
|
+
A `ContextSet` is the central artifact generated and managed by the agent, containing structured knowledge across SQL and GQL query domains in three primary forms:
|
|
38
38
|
|
|
39
|
-
* **Templates**: Link natural language query patterns to complete query statements.
|
|
40
|
-
* **Facets**: Reusable, modular query fragments (e.g., parameterized `WHERE` clauses
|
|
41
|
-
* **Value Searches**: Specialized mapping queries that dynamically resolve user-supplied values (e.g., *"Lndn"*) to database records (*"London"*) via the capabilities of the underlying database, such as embedding search, AI operators, or
|
|
39
|
+
* **Templates**: Link natural language query patterns to complete query statements (supporting relational SQL, pure GQL with `GRAPH ... MATCH`, and hybrid `GRAPH_TABLE` queries for Spanner Graph).
|
|
40
|
+
* **Facets**: Reusable, modular query fragments (e.g., parameterized `WHERE` clauses, specialized join filters, or graph `MATCH` traversal patterns) linked to domain vocabulary.
|
|
41
|
+
* **Value Searches**: Specialized mapping queries that dynamically resolve user-supplied values (e.g., *"Lndn"*) to database records (*"London"*) via the capabilities of the underlying database, such as embedding search, AI operators, or trigram search on relational and graph property tables.
|
|
42
42
|
|
|
43
43
|
For full schema details, structure specifications, and dialect-specific JSON representations of `ContextSets`, see the official **Context Sets Overview** ([AlloyDB](https://docs.cloud.google.com/gemini/data-agents/querydata/alloydb/context-sets-overview) | Cloud SQL: [PostgreSQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-postgres/context-sets-overview) / [MySQL](https://docs.cloud.google.com/gemini/data-agents/querydata/sql-mysql/context-sets-overview) | [Spanner (GoogleSQL)](https://docs.cloud.google.com/gemini/data-agents/querydata/spanner/context-sets-overview)).
|
|
44
44
|
|
|
@@ -95,6 +95,18 @@ You can provide business artifacts directly to the agent from local filesystems
|
|
|
95
95
|
|
|
96
96
|
---
|
|
97
97
|
|
|
98
|
+
## Installing via a compatible Agent Plugins client
|
|
99
|
+
|
|
100
|
+
This repository ships a valid [Agent Plugins](https://github.com/agentplugins/agent-plugins-spec) (v1) plugin under [`plugin/`](plugin/), bundling both agent skills and its MCP servers. Any [Agent Plugins–compatible client](https://agent-plugins.org/compatible-clients) (VS Code, Cursor, GitHub Copilot, Kiro, and others) can install it directly using its own built-in plugin command — no extra tooling required — by pointing at this repository:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
https://github.com/GoogleCloudPlatform/db-context-enrichment
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
See your agent's documentation for its exact install command.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
98
110
|
## How to Use
|
|
99
111
|
|
|
100
112
|
Launch your agent harness (Gemini CLI, Claude Code, or Antigravity) in your workspace directory and interact in natural language:
|
{google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/LICENSE
RENAMED
|
File without changes
|
{google_cloud_db_context_engineering-0.7.0 → google_cloud_db_context_engineering-0.7.2}/setup.cfg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|