seekdb AI Function Lab
Use this skill to reproduce AI SQL behavior without external credentials or nondeterministic model output.
Workflow
- Locate the seekdb checkout and inspect its
AGENTS.mdbefore changing code. - Establish the failing surface: prompt rendering, model metadata, HTTP transport, response validation, batch-to-row mapping, or SQL result conversion.
- Start
scripts/mock_ai_service.pyon loopback. Use a separate port when an existing service is running; never stop an unrelated process. - Register models and endpoints against the mock service, then run the smallest SQL probe from references/seekdb-ai-sql.md.
- Inspect
GET /requeststo compare the actual wire request with the provider contract. Avoid logging or pasting real access keys. - Add a focused regression in seekdb's established unit or mysqltest suite before broad validation.
Diagnosis Rules
- Preserve input order independently from response order. For embeddings and reranking, map returned items by explicit
index; reject duplicates, gaps, and out-of-range indices. - Keep SQL
NULLrows out of remote batches while preserving their original row positions. - Validate HTTP status, JSON shape, requested dimensions, and result cardinality before publishing any row result.
- Treat OpenAI-compatible and Ollama-native payloads as separate provider contracts. Do not infer a response shape only from the URL.
- Test repeated placeholders, JSON arguments, long text, Unicode, empty input, malformed JSON, partial batches, HTTP 429/5xx, and timeout behavior when they are relevant to the change.
- Do not claim real-provider compatibility from mock-only validation. State exactly which local routes and seekdb tests ran.
Mock Service
Run:
python3 scripts/mock_ai_service.py --port 8000
The service binds to 127.0.0.1 by default and implements OpenAI-compatible chat completions and embeddings, Ollama generate/chat/embed routes, and a rerank route. Use --help for deterministic delay and failure controls. Read references/mock-api.md only when configuring faults or asserting request logs.

Scan to join WeChat group