Skip to content

feat: add Hologres connector and OpenAI-compatible LLM/embedding backend#356

Open
TimothyHologres wants to merge 16 commits into
Kaelio:mainfrom
aliyun:main
Open

feat: add Hologres connector and OpenAI-compatible LLM/embedding backend#356
TimothyHologres wants to merge 16 commits into
Kaelio:mainfrom
aliyun:main

Conversation

@TimothyHologres

Copy link
Copy Markdown

Summary

Upstreams 16 commits (62 files) from the aliyun/ktx fork's main, adding two independent features:

  • Hologres connector — scan connector + driver registration, setup-wizard support, query-history ingest from hg_query_log, Hologres 4.0+ requirement via hg_version(), and postgres dialect normalization for daemon SQL analysis (plus docs).
  • OpenAI-compatible LLM / embedding backend — runtime backend, setup flow/flags, configurable embedding base_url/model/dimensions, and --embedding-batch-size for batch-limited endpoints (plus docs).

Also: chore(git): add .qoder to .gitignore.

Commits

OpenAI-compatible

  • feat(llm): add openai-compatible backend runtime
  • feat(setup): add openai-compatible LLM setup flow and flags
  • feat(setup): expose openai embedding base_url/model/dimensions
  • docs: document openai-compatible LLM backend and embedding options
  • fix(setup): add --embedding-batch-size for batch-limited endpoints

Hologres

  • feat(hologres): add Hologres scan connector and driver registration
  • feat(hologres): support Hologres in the setup wizard
  • feat(hologres): ingest query history from hologres.hg_query_log
  • docs(hologres): document the Hologres primary source
  • feat(hologres): require Hologres 4.0+ via hg_version()
  • docs(hologres): note the Hologres 4.0+ requirement
  • fix(scan): accept hologres via registry-derived driver allowlist
  • fix(hologres): normalize dialect to postgres for daemon SQL analysis

Test plan

  • pnpm run build, pnpm run type-check, pnpm run test
  • Hologres: setup wizard → scan → query-history ingest against a Hologres 4.0+ instance
  • OpenAI-compatible: LLM setup flow + embedding (base_url/model/dimensions, batch size)

TimothyDing and others added 16 commits July 14, 2026 14:35
Add an openai-compatible LLM backend that talks to any OpenAI-compatible
endpoint (base URL + API key) via @ai-sdk/openai-compatible. Wire the
backend through the config schema, provider factory, local-config
resolution, rate-limit classification, and health-check redaction.
Prompt caching stays disabled for non-Anthropic models via the existing
isAnthropicProtocolModel gate.
Add the openai-compatible backend to the interactive setup wizard and
the scriptable CLI flags (--llm-base-url, --llm-model, --llm-api-key-env,
--llm-api-key-file). The wizard prompts for base URL, an optional API key
(paste / env var / none), and a single model id applied to every ktx
role. ktx status reports the new backend, and the flags validate that
they only apply to --llm-backend openai-compatible.
The openai embedding provider already accepts a custom base URL and
dimensions, but the setup wizard hardcoded text-embedding-3-small at
1536 dimensions. Prompt for (and accept flags for) the base URL, model,
and dimensions so users can point embeddings at any OpenAI-compatible
endpoint, including ones that require a specific vector size.
Document the new openai-compatible LLM backend (provider block, setup
flags, single-model preset) and the openai embedding base_url/model/
dimensions options across the LLM configuration guide, the ktx setup CLI
reference, and the ktx.yaml reference.
OpenAI-compatible embedding endpoints can cap the number of inputs per
request (Alibaba Bailian text-embedding-v4 rejects batches larger than
10), but ktx defaulted to 100, so schema-scan enrichment failed with an
HTTP 400 during ingest. Expose the embedding batch size in the setup
wizard and as a CLI flag, persisting it to ingest.embeddings.batchSize
(mirrored into scan.enrichment.embeddings) so scan and ingest chunk
embedding requests within the endpoint's limit.
- Exclude .qoder folder from .gitignore
- Remove trailing empty lines at the end of the file
Register hologres as a first-class PostgreSQL-wire-compatible driver.
KtxHologresScanConnector extends the postgres connector, reusing its
transaction-free connection, introspection, sampling, and pg_stats-based
statistics, and only overrides listSchemas to drop Hologres engine-internal
schemas (matched exactly so user schemas like hologres_dataset_* are kept).
The postgres connector now derives its driver from the connection config so
snapshots stamp the correct driver. Hologres reuses the postgres SQL dialect
and sqlglot dialect; CLI live-database dispatch routes it to the native Node
path so it never hits the daemon (which uses transactions Hologres forbids).
Add Hologres to the ktx setup driver picker, the --database flag parser,
scope discovery (schema-scoped like postgres, default port 80), default
connection id, and connection-test support. Hologres reuses the shared
URL/host connection flow. Query-history wizard wiring is deferred until the
hg_query_log reader lands.
Add a windowed HologresQueryLogReader that aggregates hologres.hg_query_log by
its digest fingerprint (executions, distinct users, p50/p95 duration, error
rate from status, rows, top users) over a query_start window, plus a readiness
probe runner. Missing pg_read_all_stats degrades to a warning rather than
failing, since Hologres still exposes the current user's own log. Wire the
hologres dialect through the historic-SQL config union, dialect maps, probe
factory registry, and CLI reader selection (explicit branch so it never falls
through to Snowflake), and flip the driver's hasHistoricSqlReader to true. The
reader runs a single read-only statement, honoring Hologres's no-transaction
constraint.
Add a Hologres section to the primary-sources integration page covering the
PostgreSQL-compatible connection config (default port 80), the auto-excluded
Hologres system schemas, hg_query_log query history (digest aggregation, slow-log
and 30-day retention caveats, pg_read_all_stats soft-degrade), and dialect notes,
and reference Hologres in the description and field table.
Detect the Hologres version with select hg_version() (which returns e.g.
"Hologres 4.2.10 ...", distinct from the compatible PostgreSQL 11.3 version) and
refuse connections older than 4.0 — the first release that supports ktx — in both
testConnection and introspect with a clear expected error. Parses the three-part
Hologres version after the "Hologres " prefix. connectionId is now protected on
the shared Postgres connector so the subclass can run the check via executeReadOnly.
Document that ktx requires Hologres 4.0 or newer and checks it via hg_version()
when testing a connection or scanning.
Title: chore(git): add .qoder to .gitignore

此次代码评审主要增加了OpenAI兼容端点的配置支持,包括LLM和嵌入模型的相关参数设置及验证逻辑。
Link: https://code.alibaba-inc.com/kunwu.dy/ktx/codereview/28596518
Title: docs(hologres): note the Hologres 4.0+ requirement

此次代码评审主要添加了Hologres数据库的支持,包括连接配置、查询日志读取、版本检查等功能,并更新了相关文档和测试用例。
Link: https://code.alibaba-inc.com/kunwu.dy/ktx/codereview/28596493
Standalone scan's normalizeDriver kept a hardcoded driver allowlist that
drifted from the canonical driverRegistrations registry, so a hologres
connection passed the connection test but failed the scan phase. Derive
the allowlist (and error message) from the registry so every registered
driver is accepted and future connectors cannot regress.
The daemon's /sql/analyze-batch and read-only validation passed the connection
dialect straight to sqlglot, which has no "hologres" dialect, so Hologres
query-history ingest failed with 500 "Unknown dialect 'hologres'". Hologres is
Postgres wire/SQL compatible, so normalize hologres -> postgres at both entry
points before any sqlglot call. Adds regression tests for the analyze and
validate paths.
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

@TimothyDing is attempting to deploy a commit to the Kaelio Team on Vercel.

A member of the Team first needs to authorize it.

@TimothyHologres

Copy link
Copy Markdown
Author

@andreybavt Hi~~~ Could you help me to check it?

@andreybavt

Copy link
Copy Markdown
Contributor

Hey @TimothyHologres , thanks for the PR! I'm AFK during this week, will do my best to have a look ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants