Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds BYOK (Bring Your Own Key) enhancements across the webapp, proto API, and backend LLM client so custom models can expose additional OpenAI-compatible parameters and be selected more reliably.
Changes:
- Extends custom model settings (temperature, parallel tool calls, store) and updates the settings UI with validation, sorting, and tooltips.
- Adds custom model identifiers to supported-model listings and includes
custom_model_idin the chat streaming request path. - Updates backend model mapping/storage and OpenAI request parameter construction to use the new custom-model fields.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| webapp/_webapp/src/views/settings/sections/api-key-settings.tsx | UI/UX for custom model CRUD; adds new BYOK fields, tooltips, validation, duplicate prevention |
| webapp/_webapp/src/views/chat/footer/toolbar/selection.tsx | Extends selection item metadata to carry custom model identity flags |
| webapp/_webapp/src/views/chat/footer/toolbar/model-selection.tsx | Selects custom models by ID (when available) to disambiguate custom entries |
| webapp/_webapp/src/utils/stream-request-builder.ts | Adds customModelId to the stream request builder params/payload |
| webapp/_webapp/src/stores/setting-store.ts | Initializes settings defaults to include customModels |
| webapp/_webapp/src/stores/conversation/conversation-ui-store.ts | Persists lastUsedCustomModelId in UI store |
| webapp/_webapp/src/pkg/gen/apiclient/user/v1/user_pb.ts | Regenerated TS client types for added custom model fields |
| webapp/_webapp/src/pkg/gen/apiclient/chat/v2/chat_pb.ts | Regenerated TS client types for supported model IDs + stream request customModelId |
| webapp/_webapp/src/hooks/useSendMessageStream.ts | Sends customModelId with message stream requests |
| webapp/_webapp/src/hooks/useLanguageModels.ts | Tracks/uses lastUsedCustomModelId for selecting custom models |
| proto/user/v1/user.proto | Adds custom model fields (temperature, parallel tool calls, store) |
| proto/chat/v2/chat.proto | Adds supported model id + stream request custom_model_id |
| pkg/gen/api/user/v1/user.pb.go | Regenerated Go proto for custom model fields |
| pkg/gen/api/chat/v2/chat.pb.go | Regenerated Go proto for supported model IDs + stream request custom_model_id |
| internal/services/toolkit/client/utils_v2.go | Uses custom model fields when building OpenAI chat completion params |
| internal/services/toolkit/client/get_conversation_title_v2.go | Plumbs custom model through title generation path |
| internal/services/toolkit/client/get_citation_keys.go | Updates call signature for ChatCompletionV2 with custom model param |
| internal/services/toolkit/client/completion_v2.go | Updates ChatCompletionV2/StreamV2 signatures to accept custom model |
| internal/models/user.go | Persists new custom model fields in MongoDB model struct |
| internal/api/mapper/user.go | Maps new custom model fields between proto and internal models |
| internal/api/chat/list_supported_models_v2.go | Includes custom model ID in supported models response |
| internal/api/chat/create_conversation_message_stream_v2.go | Resolves custom models by custom_model_id and passes through to LLM client |
Comments suppressed due to low confidence (1)
internal/api/chat/create_conversation_message_stream_v2.go:300
- Custom models are now only resolved when
custom_model_idis present. If the client omitscustom_model_id(e.g., older clients, or loading an existing conversation where the UI store has no matchinglastUsedCustomModelId), a custom model slug will be treated as a built-in model and the BYOK endpoint/API key won’t be applied. Consider keeping a backward-compatible fallback: whencustom_model_idis empty, attempt to resolvesettings.CustomModelsbymodelSlug(or persist custom model ID in the conversation state and always send it).
customModelID := req.GetCustomModelId()
if customModelID != "" {
for i := range settings.CustomModels {
if settings.CustomModels[i].Id.Hex() == customModelID {
customModel = &settings.CustomModels[i]
break
}
}
if customModel == nil {
return s.sendStreamError(stream, fmt.Errorf("custom model not found: %q", customModelID))
}
modelSlug = customModel.Slug
}
if customModel == nil {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Key Changes:
Yet to fix bad request error for certain DeepSeek requests.