Skip to content

feat(llm): binding management in 编辑渠道 + binding-aware 移除模型 - #396

Merged
ModerRAS merged 1 commit into
feat/presets-as-datafrom
feat/binding-management-ui
Sep 17, 2026
Merged

ModerRAS merged 1 commit into
feat/presets-as-datafrom
feat/binding-management-ui

Conversation

@ModerRAS

Copy link
Copy Markdown
Owner

Stacked on #395 (which is stacked on #394). GitHub retargets the base to master as the lower PRs merge.

Why

Multi-binding channels (OpenCode Zen/Go, anything built by the new presets) had no admin surface — bindings could only be changed by editing SQLite — and 移除模型 deleted the first row matching a model name, which in a multi-binding channel can remove the wrong protocol's row (while 查看模型 displays model [channel/binding/protocol], so the two commands disagreed).

What

  • 编辑渠道 → 7. 协议绑定
    • lists the channel's bindings: id. endpoint (Protocol/Auth) [默认]
    • entering a binding id promotes it to default via new PromoteBinding (demotes the others and mirrors channel.Gateway / channel.Provider, per blueprint §七)
    • entering 0 starts the add-binding walk: endpoint → protocol (OpenAIChat/OpenAIResponses/AnthropicMessages/Ollama/Gemini) → auth (Bearer/AnthropicApiKey/None), then EnsureBinding
  • 移除模型 is binding-aware: rows come from GetModelRowsByChannelId (same display as 查看模型, duplicates become shared-model [chan/7/OpenAIResponses]) and are deleted by row id via RemoveModelRow.
  • New helper/interface methods: GetBindings, PromoteBinding, GetModelRowsByChannelId, RemoveModelRow.
  • User guide updated (field list, binding flow, row-based removal).

Validation

  • dotnet build TelegramSearchBot.sln -c Release → 0 errors
  • TelegramSearchBot.Test → 452 passed, 1 skipped (6 new tests: promote flow, add-binding flow, promote/mirror, row display + row-id delete, bindings ordering, Go catalog sync add-only)
  • TelegramSearchBot.LLM.Test → 299/299

Notes

Multi-binding channels (OpenCode Zen/Go and anything created from the new
presets) had no admin surface: bindings could only be fixed by editing SQLite,
and 移除模型 deleted the first row matching a model name, which could remove the
wrong binding's row.

- 编辑渠道 gains option 7 (协议绑定): lists the channel bindings with
  protocol/auth/default marker, promotes a chosen binding to default
  (PromoteBinding mirrors channel Gateway/Provider) or walks through
  endpoint -> protocol -> auth to add a new binding via EnsureBinding
- 移除模型 now lists rows through GetModelRowsByChannelId (same
  'model [channel/binding/protocol]' display as 查看模型) and deletes by row id
  (RemoveModelRow), so duplicate model names across bindings cannot collide
- new LLMConf states + handlers; helper/interface additions GetBindings,
  PromoteBinding, GetModelRowsByChannelId, RemoveModelRow
- tests: preset/binding promote + add flows (state machine), promote/mirror,
  row display + row-id delete, bindings ordering; user guide updated
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: b239249f-fc0e-4c10-89b2-4caec86f2447

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ModerRAS
ModerRAS merged commit 32a39ef into feat/presets-as-data Sep 17, 2026
3 checks passed
@ModerRAS
ModerRAS deleted the feat/binding-management-ui branch September 17, 2026 02:20
ModerRAS added a commit that referenced this pull request Sep 17, 2026
* fix(llm): per-model protocol bindings for OpenCode Zen/Go presets

The presets mapped both OpenCode gateways to LLMProvider.Anthropic with a single
AnthropicMessages binding, but neither gateway is Anthropic-only:
- Go serves /responses (grok-4.6, gpt-5.6-luna) and /chat/completions
- Zen is per-model: claude-* -> messages, gpt-*/grok-* -> responses,
  gemini-* -> Google, everything else -> chat completions

- LlmProviderPreset gains optional Bindings + ModelBindingRules (prefix -> binding)
  and CatalogIsEntitlement to mark subscription gateways
- preset creation builds the extra bindings and assigns seeded models to the
  protocol matched by their name; Zen stays pay-per-token (no auto-seeded models)
- Go seeds the official model list and refreshes its catalog add-only from
  /models, assigning discovered models through the same rules
- AnthropicMessagesTransport applies x-opencode-session (per-chat when known),
  fixing Go's 400 MissingSessionID on the Anthropic-compatible path
- IEditLLMConfHelper: EnsureBinding + AssignModelBinding helpers
- Tests: LlmProviderCatalogTests, AnthropicTransportSessionTests, preset flow

* feat(llm): load provider presets from data (providers.json)

Preset data lived in C# and only changed with a release; model seeds went stale
and adding a provider meant a code change.

- Providers/providers.json becomes the built-in catalog (embedded, with
  generatedAt); LlmProviderCatalogLoader overlays
  %LOCALAPPDATA%/TelegramSearchBot/providers.json when present, falling back to
  the built-in copy with a warning when the override is missing or invalid
- LlmProviderCatalog.Presets/GeneratedAt/Source now read that document
- default model lists refreshed against current vendor docs: Anthropic
  claude-opus-5/sonnet-5/haiku-4-5, OpenAI gpt-6-astra/5.6-sol/5.6-terra,
  Gemini 3.8-flash/3.1-pro-preview/3.5-flash, MiniMax M3/M2.7 (gateway
  api.minimaxi.com), DeepSeek deepseek-flash/v4-pro, Moonshot kimi-k3/k2.7-code
- GeneralBootstrap logs catalog source/version at startup
- Tests: LlmProviderCatalogLoaderTests (override wins, invalid override falls
  back with warning, empty list rejected, built-in keeps all 11 presets and the
  OpenCode bindings/rules)
- Docs: user guide documents the override file and OpenCode protocol routing

* feat(llm): binding management in 编辑渠道 + binding-aware 移除模型 (#396)

Multi-binding channels (OpenCode Zen/Go and anything created from the new
presets) had no admin surface: bindings could only be fixed by editing SQLite,
and 移除模型 deleted the first row matching a model name, which could remove the
wrong binding's row.

- 编辑渠道 gains option 7 (协议绑定): lists the channel bindings with
  protocol/auth/default marker, promotes a chosen binding to default
  (PromoteBinding mirrors channel Gateway/Provider) or walks through
  endpoint -> protocol -> auth to add a new binding via EnsureBinding
- 移除模型 now lists rows through GetModelRowsByChannelId (same
  'model [channel/binding/protocol]' display as 查看模型) and deletes by row id
  (RemoveModelRow), so duplicate model names across bindings cannot collide
- new LLMConf states + handlers; helper/interface additions GetBindings,
  PromoteBinding, GetModelRowsByChannelId, RemoveModelRow
- tests: preset/binding promote + add flows (state machine), promote/mirror,
  row display + row-id delete, bindings ordering; user guide updated
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.

1 participant