Skip to content

Commit 15fd879

Browse files
committed
feat(ai): integrate Gemma 4 with Native Function Calling and multi-backend support
- Add Gemma 4 model registry (2B/4B/26B/31B) and AIBackend enum (Google AI Studio, LM Studio, Ollama, OpenAI-compatible) - Implement Native Function Calling via GEMMA_TOOLS (analyze_schema, generate_column_values) with auto-fallback to JSON mode - Add AIConfig.resolve_base_url()/resolve_api_key()/to_openai_kwargs() for unified client construction - Add 3 Gemma 4 MCP tools: gemma4_analyze, gemma4_agent_fill, list_gemma_models - Add cross-platform quickstart.py script with LM Studio/Ollama auto-detection - Fix CLI api_key check for backends that don't require API keys - Extract _resolve_backend(), _build_ai_config(), _extract_tool_call_result() to reduce complexity - Update all markdown docs with Gemma 4 multi-backend documentation - Add gemma4-integration.md (EN + zh-CN) showcase docs
1 parent 61b7062 commit 15fd879

23 files changed

Lines changed: 966 additions & 143 deletions

AGENTS.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## OVERVIEW
88

9-
Declarative SQLite test data generation toolkit. YAML/JSON config or Python API. Auto-infers schema, 9-level column mapping, 31 generators, plugin system (pluggy).
9+
Declarative SQLite test data generation toolkit. YAML/JSON config or Python API. Auto-infers schema, 9-level column mapping, 31 generators, plugin system (pluggy). Gemma 4 Native Function Calling for AI-powered schema analysis.
1010

1111
**Stack**: Python 3.10+, hatchling build, ruff lint, mypy strict, pytest.
1212

@@ -42,8 +42,8 @@ sqlseed/
4242
| Modify schema inference | `src/sqlseed/core/schema.py` | SchemaInferrer class |
4343
| Change batch insert | `src/sqlseed/database/` | Two adapters: raw, sqlite-utils |
4444
| Add test fixture | `tests/conftest.py` | tmp_db, tmp_db_with_data, unique_test_db |
45-
| Configure AI plugin | `plugins/sqlseed-ai/` | Separate pyproject.toml |
46-
| Add MCP tool | `plugins/mcp-server-sqlseed/` | FastMCP decorators |
45+
| Configure AI plugin | `plugins/sqlseed-ai/` | Separate pyproject.toml, Gemma 4 multi-backend (Google AI Studio, LM Studio, Ollama) |
46+
| Add MCP tool | `plugins/mcp-server-sqlseed/` | FastMCP decorators, 3 Gemma 4 tools: gemma4_analyze, gemma4_agent_fill, list_gemma_models |
4747

4848
## CONVENTIONS
4949

@@ -65,6 +65,8 @@ sqlseed/
6565
## UNIQUE STYLES
6666

6767
- **Provider fallback chain**: mimesis → faker → base (auto-degrades)
68+
- **AI backend fallback chain**: Google AI Studio → LM Studio → Ollama (multi-backend)
69+
- **Gemma 4 Native Function Calling**: `GEMMA_TOOLS` (analyze_schema, generate_column_values) with auto-fallback to JSON mode
6870
- **Context manager pattern**: `DataOrchestrator` is a context manager
6971
- **Plugin mediation**: `PluginMediator` bridges plugins and core (not direct calls)
7072
- **DAG-based column ordering**: `ColumnDAG` handles derive_from dependencies

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
119119
- `ColumnMapper` exact match rules expanded from 68 to 74
120120

121121
#### AI Plugin (sqlseed-ai)
122-
- Auto model selection: `_model_selector` picks the best free model from OpenRouter by priority
122+
- Auto model selection: `_model_selector` picks the best Gemma 4 model by priority (26B MoE → 31B Dense → 4B → 2B), with multi-backend support (Google AI Studio, LM Studio, Ollama)
123123
- Structured output: `response_format: json_object` forces LLM to return JSON
124124
- Few-shot example library: 4 typical scenarios (users, projects, orders, employees)
125125
- `AiConfigRefiner` self-correction loop: auto-detects and fixes invalid configs, up to 3 retries

CHANGELOG.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
- `ColumnMapper` 精确匹配规则从 68 扩展到 74 条
120120

121121
#### AI 插件(sqlseed-ai)
122-
- 自动模型选择:`_model_selector` 从 OpenRouter 免费模型列表中按优先级自动选择
122+
- 自动模型选择:`_model_selector` 按 Gemma 4 优先级自动选择(26B MoE → 31B Dense → 4B → 2B),支持多后端(Google AI Studio、LM Studio、Ollama)
123123
- 结构化输出:`response_format: json_object` 强制 LLM 返回 JSON
124124
- Few-shot 示例库:4 个典型场景(用户表、银行卡表、订单表、员工表)
125125
- `AiConfigRefiner` 自纠正闭环:自动检测并修复无效配置,最多 3 轮重试

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ When preparing a new version release:
201201

202202
## Plugins (separate packages)
203203

204-
- `plugins/sqlseed-ai/` — LLM-powered schema analysis via OpenRouter. Has its own `pyproject.toml`. Install: `pip install -e "./plugins/sqlseed-ai"`
204+
- `plugins/sqlseed-ai/` — LLM-powered schema analysis via Gemma 4 (Google AI Studio, LM Studio, Ollama). Has its own `pyproject.toml`. Install: `pip install -e "./plugins/sqlseed-ai"`
205205
- `plugins/mcp-server-sqlseed/` — MCP server for schema inspect, AI YAML gen, fill. Install: `pip install -e "./plugins/mcp-server-sqlseed"`
206206

207207
## Dependencies

GEMINI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Core features include:
2424
- **`src/sqlseed/config/`**: Configuration management using `pydantic` models, YAML/JSON loader (`loader.py`, `models.py`), and runtime snapshots supporting CLI `replay` command (`snapshot.py`).
2525
- **`src/sqlseed/cli/`**: `click`-based command-line interface (`main.py` providing fill, preview, inspect, init, replay, ai-suggest).
2626
- **`src/sqlseed/_utils/`**: Internal utilities including SQL safety (`sql_safe.py`), shared schema helpers (`schema_helpers.py`), performance metrics collection (`metrics.py`), progress bar wrapper (`progress.py`, based on `rich`), and logging wrapper (`logger.py`, based on `structlog`).
27-
- **`plugins/sqlseed-ai/`**: Standalone package providing OpenAI-compatible LLM-driven generation. Contains `analyzer.py` (LLM table-level analysis), `refiner.py` (self-correction loop), `errors.py` (error summary), `examples.py` (few-shot examples), `provider.py` (AI provider compatibility stub), `config.py` (AIConfig model), `_client.py` (API client), `_json_utils.py` (JSON parsing), and `_model_selector.py` (auto model selection from OpenRouter).
27+
- **`plugins/sqlseed-ai/`**: Standalone package providing OpenAI-compatible LLM-driven generation. Contains `analyzer.py` (LLM table-level analysis), `refiner.py` (self-correction loop), `errors.py` (error summary), `examples.py` (few-shot examples), `provider.py` (AI provider compatibility stub), `config.py` (AIConfig model), `_client.py` (API client), `_json_utils.py` (JSON parsing), and `_model_selector.py` (Gemma 4 model selection, multi-backend support).
2828
- **`plugins/mcp-server-sqlseed/`**: MCP server based on FastMCP providing one Resource (`sqlseed://schema/{db_path}/{table_name}`) and three core Tools (`sqlseed_inspect_schema`, `sqlseed_generate_yaml`, `sqlseed_execute_fill`) for seamless AI assistant integration (driven by `server.py` and `config.py`).
2929
- **`examples/`**: Contains tutorial Jupyter notebooks (`notebooks/`) covering quickstart, column mapping, generators, DB association, expression/DAGs, AI configuration, MCP server, and testing patterns. Also includes demo DB builder script (`build_demo_db.py`).
3030
- **`docs/`**: Project documentation including architecture diagrams (`architecture.md`).

README.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ mypy src/sqlseed/
180180

181181
## 🚀 Quick Start
182182

183+
### Interactive Quickstart
184+
185+
```bash
186+
python scripts/quickstart.py
187+
```
188+
183189
### Try with Demo Database
184190

185191
Want to try sqlseed right away? Build the demo database:
@@ -652,17 +658,34 @@ pip install sqlseed-ai
652658
653659
# Set API key
654660
export SQLSEED_AI_API_KEY="your-api-key"
655-
export SQLSEED_AI_BASE_URL="https://your-llm-api-endpoint"
656661
657662
# AI analysis and config generation
658663
sqlseed ai-suggest app.db --table projects --output projects.yaml
659664
660665
# AI suggestions with self-correction (3 rounds by default)
661666
sqlseed ai-suggest app.db --table projects --output projects.yaml --verify
662667
663-
# Specify model (defaults to most popular free model)
664-
sqlseed ai-suggest app.db --table projects --output projects.yaml --model nvidia/nemotron-3-super-120b-a12b:free
668+
# Specify model (defaults to Gemma 4 26B via Google AI Studio)
669+
sqlseed ai-suggest app.db --table projects --output projects.yaml --model gemma-4-26b-it
670+
671+
# Use local LM Studio / Ollama
672+
sqlseed ai-suggest app.db --table projects --output projects.yaml --backend lm_studio --model google/gemma-4-e4b
673+
```
665674

675+
**Gemma 4 Native Function Calling (GEMMA_TOOLS)**:
676+
677+
sqlseed-ai supports Gemma 4 model family (2B/4B/26B/31B) with Native Function Calling via GEMMA_TOOLS protocol. Supported backends:
678+
679+
| Backend | Description | Configuration |
680+
| :------ | :---------- | :------------ |
681+
| **Google AI Studio** | Official API, recommended for Gemma 4 26B/31B | `--backend google_ai_studio` or `SQLSEED_AI_BACKEND=google_ai_studio` |
682+
| **LM Studio** | Local inference, suitable for Gemma 4 2B/4B | `--backend lm_studio` or `SQLSEED_AI_BACKEND=lm_studio` |
683+
| **Ollama** | Local inference, suitable for Gemma 4 2B/4B/26B | `--backend ollama` or `SQLSEED_AI_BACKEND=ollama` |
684+
| **OpenAI-compatible** | Generic OpenAI-compatible endpoint (e.g., OpenRouter, DeepSeek) | `--backend openai_compat` or `SQLSEED_AI_BACKEND=openai_compat` |
685+
686+
> **💡 OpenRouter (Free)**: For users without a paid API key, OpenRouter provides free models. Set `SQLSEED_AI_BACKEND=openai_compat`, `SQLSEED_AI_BASE_URL=https://openrouter.ai/api/v1`, and `SQLSEED_AI_MODEL=<free-model-name>`.
687+
688+
```bash
666689
# Skip cache
667690
sqlseed ai-suggest app.db --table projects --output projects.yaml --no-cache
668691
```
@@ -678,7 +701,7 @@ sqlseed ai-suggest app.db --table projects --output projects.yaml --no-cache
678701
6. Up to 3 self-correction rounds, outputs validated YAML config
679702
```
680703
681-
> **💡 Environment Variables**: Supports `SQLSEED_AI_API_KEY`, `SQLSEED_AI_BASE_URL`, `SQLSEED_AI_MODEL`. Also supports `OPENAI_API_KEY` / `OPENAI_BASE_URL` as fallback. Defaults to auto-selecting the most popular free model from OpenRouter (base_url `https://openrouter.ai/api/v1`). Set `--model` or `SQLSEED_AI_MODEL` to specify a model.
704+
> **💡 Environment Variables**: Supports `SQLSEED_AI_API_KEY`, `SQLSEED_AI_BASE_URL`, `SQLSEED_AI_MODEL`, `SQLSEED_AI_BACKEND`. Also supports `OPENAI_API_KEY` / `OPENAI_BASE_URL` as fallback. Defaults to Gemma 4 26B via Google AI Studio. Supported backends: `google_ai_studio`, `lm_studio`, `ollama`, `openai_compat`.
682705
683706
***
684707
@@ -717,6 +740,9 @@ python -m mcp_server_sqlseed
717740
| 🔍 Tool | `sqlseed_inspect_schema` | Inspect schema (columns, FK, indexes, samples, schema_hash) |
718741
| 🤖 Tool | `sqlseed_generate_yaml` | AI-driven YAML config generation with self-correction. Supports `api_key`/`base_url`/`model` overrides |
719742
| ⚡ Tool | `sqlseed_execute_fill` | Execute data generation (supports YAML config string, includes `enrich` option) |
743+
| 🧠 Tool | `sqlseed_gemma4_analyze` | Analyze schema using Gemma 4 with Native Function Calling |
744+
| 🧠 Tool | `sqlseed_gemma4_agent_fill` | End-to-end Agent workflow (analyze -> config -> fill) |
745+
| 🧠 Tool | `sqlseed_list_gemma_models` | List available Gemma 4 models and backend status |
720746

721747
This means you can tell your AI assistant:
722748

@@ -993,7 +1019,7 @@ Tests cover all core modules, with path structure mirroring `src/`: `test_core/`
9931019
| `sqlseed[faker]` | + faker>=30.0 | Faker data engine |
9941020
| `sqlseed[mimesis]` | + mimesis>=18.0 | Mimesis data engine (recommended) |
9951021
| `sqlseed[docs]` | + mkdocs-material, mkdocstrings | Documentation build |
996-
| `sqlseed-ai` | sqlseed, **openai>=1.0** | AI plugin, auto-registered via entry-point |
1022+
| `sqlseed-ai` | sqlseed, **openai>=1.0**, **google-generativeai>=0.8** | AI plugin (Gemma 4 Native Function Calling), auto-registered via entry-point |
9971023
| `mcp-server-sqlseed` | sqlseed, **mcp>=1.0** | MCP server, standalone CLI tool |
9981024
| `mcp-server-sqlseed[ai]` | + sqlseed-ai | MCP server with AI support |
9991025

README.zh-CN.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@ mypy src/sqlseed/
178178

179179
## 🚀 快速开始
180180

181+
### 一键体验脚本
182+
183+
```bash
184+
python scripts/quickstart.py
185+
```
186+
187+
该脚本会自动创建示例数据库、填充数据并展示结果,适合首次体验。
188+
181189
### 使用示例数据库体验
182190

183191
想立即体验 sqlseed?构建示例数据库:
@@ -553,22 +561,27 @@ sqlseed ai-suggest app.db --table projects --output projects.yaml
553561
# 带自纠正的 AI 建议(默认 3 轮修正)
554562
sqlseed ai-suggest app.db --table projects --output projects.yaml --verify
555563
556-
# 指定模型
557-
sqlseed ai-suggest app.db --table projects -o projects.yaml --model deepseek/deepseek-chat
564+
# 指定模型(支持多后端:Google AI Studio、LM Studio、Ollama、OpenAI-compatible)
565+
sqlseed ai-suggest app.db --table projects -o projects.yaml --model gemma-4-26b-it --backend google_ai_studio
566+
sqlseed ai-suggest app.db --table projects -o projects.yaml --model gemma-4-31b-it --backend google_ai_studio
567+
sqlseed ai-suggest app.db --table projects -o projects.yaml --model google/gemma-4-e4b --backend lm_studio
568+
sqlseed ai-suggest app.db --table projects -o projects.yaml --model gemma-4-4b-it --backend ollama
558569
```
559570

560-
**AI 工作流程**:
571+
**Gemma 4 原生函数调用(GEMMA_TOOLS)**:
561572

562-
```
563-
1. 提取 Schema 上下文(列信息、索引、样本数据、外键、数据分布)
564-
2. 构建带 Few-shot 示例的 LLM Prompt
565-
3. LLM 返回 JSON 格式的列配置建议
566-
4. AiConfigRefiner 自动验证配置的正确性
567-
5. 若发现错误,自动向 LLM 发送修正请求
568-
6. 最多 3 轮自纠正,输出经过验证的 YAML 配置
569-
```
573+
sqlseed-ai 支持 Gemma 4 系列模型(2B/4B/26B/31B)通过 GEMMA_TOOLS 协议实现原生函数调用,无需 JSON Mode 模拟。支持的后端:
574+
575+
| 后端 | 说明 | 配置方式 |
576+
| :--- | :--- | :--- |
577+
| **Google AI Studio** | 官方 API,推荐 Gemma 4 26B/31B | `--backend google_ai_studio` 或 `SQLSEED_AI_BACKEND=google_ai_studio` |
578+
| **LM Studio** | 本地推理,适合 Gemma 4 2B/4B | `--backend lm_studio` 或 `SQLSEED_AI_BACKEND=lm_studio` |
579+
| **Ollama** | 本地推理,适合 Gemma 4 2B/4B/26B | `--backend ollama` 或 `SQLSEED_AI_BACKEND=ollama` |
580+
| **OpenAI-compatible** | 通用 OpenAI 兼容端点(如 OpenRouter、DeepSeek) | `--backend openai_compat` 或 `SQLSEED_AI_BACKEND=openai_compat` |
570581

571-
> **💡 环境变量**:支持 `SQLSEED_AI_API_KEY`、`SQLSEED_AI_BASE_URL`、`SQLSEED_AI_MODEL`。也支持 `OPENAI_API_KEY` / `OPENAI_BASE_URL` 作为回退。
582+
> **💡 OpenRouter(免费方案)**:没有付费 API Key 的用户,可以使用 OpenRouter 的免费模型。设置 `SQLSEED_AI_BACKEND=openai_compat`、`SQLSEED_AI_BASE_URL=https://openrouter.ai/api/v1`、`SQLSEED_AI_MODEL=<免费模型名>`。
583+
584+
> **💡 环境变量**:支持 `SQLSEED_AI_API_KEY`、`SQLSEED_AI_BASE_URL`、`SQLSEED_AI_MODEL`、`SQLSEED_AI_BACKEND`。也支持 `OPENAI_API_KEY` / `OPENAI_BASE_URL` 作为回退。
572585

573586
***
574587

@@ -598,6 +611,9 @@ pip install mcp-server-sqlseed[ai]
598611
| 🔍 Tool | `sqlseed_inspect_schema` | 检查 Schema(列、外键、索引、样本数据、schema_hash) |
599612
| 🤖 Tool | `sqlseed_generate_yaml` | AI 驱动的 YAML 配置生成(含自纠正) |
600613
| ⚡ Tool | `sqlseed_execute_fill` | 执行数据生成(支持 YAML 配置字符串,含 `enrich` 选项) |
614+
| 🤖 Tool | `sqlseed_gemma4_analyze` | Gemma 4 原生函数调用分析 Schema(GEMMA_TOOLS 协议) |
615+
| 🤖 Tool | `sqlseed_gemma4_agent_fill` | Gemma 4 Agent 模式端到端数据生成(分析→配置→填充) |
616+
| 📋 Tool | `sqlseed_list_gemma_models` | 列出可用的 Gemma 4 模型及后端支持情况 |
601617

602618
***
603619

@@ -679,6 +695,12 @@ sqlseed ai-suggest app.db -t users -o users.yaml --verify
679695
sqlseed ai-suggest app.db -t users -o users.yaml --api-key sk-xxx --base-url https://api.openai.com/v1
680696
sqlseed ai-suggest app.db -t users -o users.yaml --max-retries 0
681697
sqlseed ai-suggest app.db -t users -o users.yaml --no-cache
698+
699+
# ═══ AI 后端选择 ═══
700+
sqlseed ai-suggest app.db -t users -o users.yaml --backend google_ai_studio --model gemma-4-26b-it
701+
sqlseed ai-suggest app.db -t users -o users.yaml --backend ollama --model gemma-4-4b-it
702+
sqlseed ai-suggest app.db -t users -o users.yaml --backend lm_studio --model google/gemma-4-e4b
703+
sqlseed ai-suggest app.db -t users -o users.yaml --backend openai_compat --model your-model --base-url https://your-api-endpoint
682704
```
683705

684706
***
@@ -805,7 +827,7 @@ mypy src/sqlseed/ # 类型检查
805827
| `sqlseed[faker]` | + faker>=30.0 | Faker 数据引擎 |
806828
| `sqlseed[mimesis]` | + mimesis>=18.0 | Mimesis 数据引擎(推荐) |
807829
| `sqlseed[docs]` | + mkdocs-material, mkdocstrings | 文档构建 |
808-
| `sqlseed-ai` | sqlseed, **openai>=1.0** | AI 插件,通过 entry-point 自动注册 |
830+
| `sqlseed-ai` | sqlseed, **openai>=1.0**, **google-generativeai>=0.8** | AI 插件,通过 entry-point 自动注册,支持 Gemma 4 GEMMA_TOOLS |
809831
| `mcp-server-sqlseed` | sqlseed, **mcp>=1.0** | MCP 服务器,独立 CLI 工具 |
810832
| `mcp-server-sqlseed[ai]` | + sqlseed-ai | MCP 服务器含 AI 支持 |
811833

docs/architecture.md

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ graph TB
6262
Refiner["AiConfigRefiner<br/>self-correction loop"]
6363
Examples["Few-shot<br/>example library"]
6464
Errors["ErrorSummary<br/>error classification"]
65+
GemmaModel["GemmaModel<br/>Gemma 4 model adapter"]
66+
AIBackend["AIBackend<br/>multi-backend router"]
67+
GemmaTools["GEMMA_TOOLS<br/>Native Function Calling"]
6568
end
6669
6770
subgraph Utils["🔧 Utilities (_utils/)"]
@@ -115,6 +118,9 @@ graph TB
115118
Analyzer --> Refiner
116119
Refiner --> Errors
117120
Analyzer --> Examples
121+
AIBackend --> GemmaModel
122+
AIBackend --> Analyzer
123+
GemmaModel --> GemmaTools
118124
119125
Orch --> Config
120126
@@ -426,13 +432,15 @@ flowchart TB
426432
CLICmd["sqlseed ai-suggest"]
427433
HookCall["sqlseed_ai_analyze_table Hook"]
428434
MCPTool["MCP: sqlseed_generate_yaml"]
435+
MCPGemma4Analyze["MCP: sqlseed_gemma4_analyze"]
436+
MCPGemma4AgentFill["MCP: sqlseed_gemma4_agent_fill"]
429437
end
430438
431439
subgraph Analyzer["SchemaAnalyzer"]
432440
Context["Build context<br/>columns + indexes + FK + samples + distribution"]
433441
FewShot["Inject few-shot examples<br/>(4 typical scenarios)"]
434442
SysPrompt["System Prompt<br/>generator list + output format"]
435-
LLM["Call LLM<br/>OpenAI-compatible API<br/>response_format: json_object"]
443+
LLM["Call LLM<br/>AIBackend multi-backend<br/>OpenAI API / Gemma 4 GEMMA_TOOLS<br/>response_format: json_object"]
436444
end
437445
438446
subgraph Refiner["AiConfigRefiner Self-Correction Loop"]
@@ -474,6 +482,8 @@ flowchart TB
474482
CLICmd --> Analyzer
475483
HookCall --> Analyzer
476484
MCPTool --> Analyzer
485+
MCPGemma4Analyze --> Analyzer
486+
MCPGemma4AgentFill --> Analyzer
477487
478488
Context --> FewShot --> SysPrompt --> LLM
479489
LLM --> Refiner
@@ -625,6 +635,9 @@ flowchart LR
625635
Tool1["🔍 sqlseed_inspect_schema<br/>Returns: columns + FK + indexes + samples + hash"]
626636
Tool2["🤖 sqlseed_generate_yaml<br/>AI analysis → self-correction → YAML"]
627637
Tool3["⚡ sqlseed_execute_fill<br/>Execute data generation"]
638+
Tool4["💎 sqlseed_gemma4_analyze<br/>Gemma 4 native function calling analysis"]
639+
Tool5["💎 sqlseed_gemma4_agent_fill<br/>Gemma 4 agent-driven data fill"]
640+
Tool6["💎 sqlseed_gemma4_suggest<br/>Gemma 4 column mapping suggestions"]
628641
end
629642
630643
subgraph SQLSeed["sqlseed Core"]
@@ -641,11 +654,77 @@ flowchart LR
641654
Request --> Tool1
642655
Request --> Tool2
643656
Request --> Tool3
657+
Request --> Tool4
658+
Request --> Tool5
659+
Request --> Tool6
644660
645661
Resource --> SchemaCtx
646662
Tool1 --> SchemaCtx
647663
Tool2 --> SA --> ACR
648664
Tool3 --> Orchestrator
665+
Tool4 --> SA
666+
Tool5 --> Orchestrator
667+
Tool6 --> SA
649668
650669
SchemaCtx --> Orchestrator
651670
```
671+
672+
---
673+
674+
## 11. Gemma 4 Integration Architecture
675+
676+
```mermaid
677+
flowchart TB
678+
subgraph MCPEntry["MCP Tool Entry Points"]
679+
G4Analyze["💎 sqlseed_gemma4_analyze<br/>Schema analysis via Gemma 4"]
680+
G4AgentFill["💎 sqlseed_gemma4_agent_fill<br/>Agent-driven data fill"]
681+
G4Suggest["💎 sqlseed_gemma4_suggest<br/>Column mapping suggestions"]
682+
end
683+
684+
subgraph Backend["AIBackend Multi-Backend Router"]
685+
Router["AIBackend<br/>backend selection"]
686+
OpenAIBe["OpenAI Backend<br/>chat.completions API"]
687+
GemmaBe["Gemma 4 Backend<br/>GEMMA_TOOLS Native FC"]
688+
end
689+
690+
subgraph GemmaFC["GEMMA_TOOLS Native Function Calling"]
691+
ToolReg["Tool Registration<br/>auto_register(sqlseed tools)"]
692+
FCRequest["Function Call Request<br/>model generates tool_call"]
693+
FCExec["Tool Execution<br/>sqlseed core executes"]
694+
FCResult["Result Injection<br/>tool_result → conversation"]
695+
FCIterate["Iterative Refinement<br/>multi-turn tool use"]
696+
end
697+
698+
subgraph Core["sqlseed Core Integration"]
699+
SchemaCtx["get_schema_context()"]
700+
Orchestrator["DataOrchestrator"]
701+
Mapper["ColumnMapper"]
702+
end
703+
704+
G4Analyze --> Router
705+
G4AgentFill --> Router
706+
G4Suggest --> Router
707+
708+
Router --> OpenAIBe
709+
Router --> GemmaBe
710+
711+
GemmaBe --> ToolReg
712+
ToolReg --> FCRequest
713+
FCRequest --> FCExec
714+
FCExec --> FCResult
715+
FCResult --> FCIterate
716+
FCIterate --> FCRequest
717+
718+
FCExec --> SchemaCtx
719+
FCExec --> Orchestrator
720+
FCExec --> Mapper
721+
722+
SchemaCtx --> Orchestrator
723+
724+
style GemmaBe fill:#4285F4,color:#fff
725+
style ToolReg fill:#34A853,color:#fff
726+
style FCRequest fill:#34A853,color:#fff
727+
style FCExec fill:#FBBC05,color:#000
728+
style FCResult fill:#34A853,color:#fff
729+
style FCIterate fill:#EA4335,color:#fff
730+
```

0 commit comments

Comments
 (0)