Skip to content

Cherry pick #109232 to 26.5: AI functions parameter map - #112520

Merged
robot-clickhouse-ci-2 merged 17 commits into
backport/26.5/109232from
cherrypick/26.5/109232
Jul 31, 2026
Merged

robot-clickhouse-ci-2 merged 17 commits into
backport/26.5/109232from
cherrypick/26.5/109232

Conversation

@robot-ch-test-poll

Copy link
Copy Markdown
Contributor

Original pull-request #109232

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

george-larionov and others added 16 commits July 7, 2026 20:40
Move the named collection out of the positional arguments. Credentials now
come from a `credentials` key in an optional trailing `Map(String, String)`
argument, or from `ai_function_text_default_credentials` (chat functions) /
`ai_function_embedding_default_credentials` (aiEmbed) when the map omits it.
The map also carries tunables (`model`, `max_tokens`, `temperature`,
`system_prompt`, `instructions`, `dimensions`); each function declares its
params, defaults, and required-ness via a small spec resolved centrally.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Reject duplicate keys in the parameter map instead of silently keeping the
  last value, matching the unknown-key rejection.
- AIParams::getString/getFloat/getUInt throw a DB::Exception on a missing key
  rather than std::map::at's std::out_of_range.
- Drop the unnecessary ColumnMap.h include.
- Tests: negative / out-of-range max_tokens and duplicate map key.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Parse UInt map values (max_tokens, dimensions) with overflow checking so a
value above UInt64 max is rejected instead of silently wrapping (e.g.
"18446744073709551616" -> 0). Add a test for the wrap boundary.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Expand each function's `params` documentation with per-key meaning and defaults.
- Clarify the `AIParamKind` and parameter-parsing comments.
- Parse parameters via exhaustive `switch` over `AIParamKind` so a new kind is a
  compile error rather than a silent fallthrough; guard `getResolvedAIParam`
  with `chassert`.
- Add a test rejecting a parameter map passed in the prompt position.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Style check: give the small AI-parameter `std::vector`/`std::map` config
  containers `STYLE_CHECK_ALLOW_STD_CONTAINERS`-marked aliases instead of raw
  std containers.
- clang-tidy (cppcoreguidelines-init-variables): initialize `value` in the
  UInt parameter parser.
- Fast test: update 04142_ai_functions_named_collection_access to the new
  signature (credentials via the parameter map); reference unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Add `ai_function_text_default_credentials` and
  `ai_function_embedding_default_credentials` to the reference settings docs
  (session-settings.mdx and the experimental-features list) so the links from
  the AI functions page resolve and the Mintlify docs check passes.
- SettingsChangesHistory: use a terse "New setting" reason for both.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ntials-params-map

AI functions parameter map
@robot-ch-test-poll robot-ch-test-poll added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request labels Jul 30, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

Heads-up: the cherry-pick of #110619 to 26.5 (#112515) has been resolved by adapting it onto the current 26.5 API, making model a required positional argument of aiEmbed (aiEmbed(collection, text, model[, dimensions])). This cherry-pick's source (#109232) predates #110619, so when resolving the conflicts here, keep model positional for aiEmbed — i.e. converge aiEmbed to the current master state (aiEmbed(text, model[, params])) rather than reintroducing model as a parameter-map/collection key. See #112515 (comment) for details.

Resolved the conflicts onto the 26.5 AI-function code, with `aiEmbed` converged to
the current master signature `aiEmbed(text, model[, params])` per the review comment:
`model` is a required positional argument and is rejected in the parameter map and in
the named collection.

26.5-specific deviations from master: `api_key` stays a required named-collection
field, the two new default-credentials settings are registered in the 26.5 block of
`SettingsChangesHistory.cpp`, `aiEmbed`'s `introduced_in` stays 26.5, and the parts
that do not exist in 26.5 are dropped (`docs/reference/**`,
`tests/integration/test_ai_functions/test.py`, the `QueryFuzzer` AI swap groups and
the `04142` default-credentials access helper).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
george-larionov added a commit that referenced this pull request Jul 31, 2026
26.6 carries #106881 (credentials from `ai_function_credentials`), which master
reverted and re-landed as #109232, so that setting is replaced by the two
default-credentials settings. Keep 26.6's retry handling and converge `aiEmbed`
to `aiEmbed(text, model[, params])` so the #110619 backport is not undone.

Related: #112520 (comment)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@robot-clickhouse-ci-2
robot-clickhouse-ci-2 merged commit a902ae1 into backport/26.5/109232 Jul 31, 2026
@robot-clickhouse-ci-2
robot-clickhouse-ci-2 deleted the cherrypick/26.5/109232 branch July 31, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants