AI-powered data generation plugin for sqlseed
Project description
sqlseed-ai
AI-powered data generation plugin for sqlseed.
LLM-driven schema analysis, self-correcting config generation, and template pool assistance. Uses OpenAI-compatible API (default: OpenRouter free models).
Installation
pip install sqlseed-ai
Quick Start
# Set API key (OpenRouter, OpenAI, DeepSeek, etc.)
export SQLSEED_AI_API_KEY="your-api-key"
# Generate AI-suggested YAML config
sqlseed ai-suggest app.db --table users --output users.yaml
# With self-correction (3 rounds by default)
sqlseed ai-suggest app.db --table users --output users.yaml --verify
# Specify model
sqlseed ai-suggest app.db --table users -o users.yaml --model deepseek/deepseek-chat
# Skip cache
sqlseed ai-suggest app.db --table users -o users.yaml --no-cache
Features
Schema Analyzer
SchemaAnalyzer extracts rich context from your database (columns, indexes, sample data, foreign keys, data distribution) and builds a structured prompt for LLM analysis. Returns column-level generation configs as JSON.
Self-Correcting Refiner
AiConfigRefiner validates LLM output against actual schema:
- LLM generates column config
- Refiner checks for unknown generators, type mismatches, expression errors
- If errors found, sends correction request back to LLM
- Up to 3 retry rounds, then raises
AISuggestionFailedError
Auto Model Selection
Queries OpenRouter API to find the best available free model. Falls back through a priority list:
nvidia/nemotron-3-super-120b-a12b:free → tencent/hy3-preview:free → ...
Result cached for 1 hour. Skip auto-selection by specifying --model or SQLSEED_AI_MODEL.
Template Pool
When sqlseed fills a table with skip_ai=False, the plugin pre-generates candidate values for columns that can't be mapped to a deterministic generator (via sqlseed_pre_generate_templates hook).
File Caching
AI configs cached in .sqlseed_cache/ai_configs/ with schema hash validation. Schema changes auto-invalidate cache. Use --no-cache to skip.
Configuration
Environment Variables
| Variable | Fallback | Default | Description |
|---|---|---|---|
SQLSEED_AI_API_KEY |
OPENAI_API_KEY |
— | API key (required) |
SQLSEED_AI_BASE_URL |
OPENAI_BASE_URL |
https://openrouter.ai/api/v1 |
API endpoint |
SQLSEED_AI_MODEL |
— | auto-select | Model name |
SQLSEED_AI_TIMEOUT |
— | 60 |
API timeout (seconds) |
CLI Options
--model, -m Model name (overrides auto-selection)
--api-key API key (overrides env)
--base-url API base URL (overrides env)
--max-retries Self-correction rounds (default: 3, 0=disable)
--verify/--no-verify Toggle self-correction (default: verify)
--no-cache Skip file cache
--timeout API timeout in seconds (default: 120)
Plugin Hooks
This plugin registers via [project.entry-points."sqlseed"] and implements:
| Hook | Purpose |
|---|---|
sqlseed_ai_analyze_table |
LLM-driven table analysis, returns column configs |
sqlseed_pre_generate_templates |
Pre-generate candidate values for complex columns |
sqlseed_register_providers |
Placeholder (no-op, entry-point registration) |
sqlseed_register_column_mappers |
Placeholder (no-op, entry-point registration) |
Requirements
- Python >= 3.10
sqlseed >= 0.1.0openai >= 1.0- An OpenAI-compatible API key
License
AGPL-3.0-or-later
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqlseed_ai-0.1.14.tar.gz.
File metadata
- Download URL: sqlseed_ai-0.1.14.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc008c3e34a7e1d564013f10b66f3b24090c588cb79aa11cc7cce4fd9794500e
|
|
| MD5 |
6a0c1af9ae87440fed3d1e8689e181ab
|
|
| BLAKE2b-256 |
83ce748b704fa410e0c4c3833fcb5e5e2e6310210007527542c1cd6201f4d9c3
|
Provenance
The following attestation bundles were made for sqlseed_ai-0.1.14.tar.gz:
Publisher:
publish.yml on sunbos/sqlseed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlseed_ai-0.1.14.tar.gz -
Subject digest:
dc008c3e34a7e1d564013f10b66f3b24090c588cb79aa11cc7cce4fd9794500e - Sigstore transparency entry: 1419831566
- Sigstore integration time:
-
Permalink:
sunbos/sqlseed@c611d173016da1aef7eb43532e015cfddbb2dba6 -
Branch / Tag:
refs/tags/v0.1.14 - Owner: https://github.com/sunbos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c611d173016da1aef7eb43532e015cfddbb2dba6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sqlseed_ai-0.1.14-py3-none-any.whl.
File metadata
- Download URL: sqlseed_ai-0.1.14-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32b507ec3f3879522935a812175013cb6c12f80c94715210998531593d1bbdbd
|
|
| MD5 |
77466952827ec8cc710ed1cdd3028aff
|
|
| BLAKE2b-256 |
4b9d3de869f07541c5efd4a46b38f09610e81941cdfbea29d76e5fa074f54796
|
Provenance
The following attestation bundles were made for sqlseed_ai-0.1.14-py3-none-any.whl:
Publisher:
publish.yml on sunbos/sqlseed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlseed_ai-0.1.14-py3-none-any.whl -
Subject digest:
32b507ec3f3879522935a812175013cb6c12f80c94715210998531593d1bbdbd - Sigstore transparency entry: 1419832076
- Sigstore integration time:
-
Permalink:
sunbos/sqlseed@c611d173016da1aef7eb43532e015cfddbb2dba6 -
Branch / Tag:
refs/tags/v0.1.14 - Owner: https://github.com/sunbos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c611d173016da1aef7eb43532e015cfddbb2dba6 -
Trigger Event:
release
-
Statement type: