Skip to content

Commit a888101

Browse files
committed
Exempt OpenRouter from model validation checks in web configurations
- model of 'open router' appears on a web configuration in settings, but does not in prompt view - do we e.g. filter web configurations for prompt view more thorough than for settings view? ├── apps │ └── editor │ └── src │ └── views │ ├── prompt │ │ ├── backend │ │ │ └── prompt-view-provider.ts │ │ └── frontend │ │ └── Main │ │ └── MainView │ │ ├── MainView.tsx │ │ └── hooks │ │ └── use-last-choice-tooltip.ts │ ├── settings │ │ ├── backend │ │ │ └── settings-view-provider.ts │ │ └── frontend │ │ └── Home │ │ └── sections │ │ └── WebSection.tsx │ └── shared │ ├── actions │ │ └── web │ │ └── pick-model.ts │ └── forms │ └── EditWebConfigurationForm │ └── EditWebConfigurationForm.tsx └── packages └── shared └── src └── constants └── chatbots.ts
1 parent 00638ca commit a888101

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

‎apps/editor/src/views/prompt/backend/prompt-view-provider.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,11 @@ export class PromptViewProvider implements vscode.WebviewViewProvider {
875875
chatbot_info.supports_user_provided_model
876876
const is_model_predefined = chatbot_info.models?.[model]
877877

878-
if (!is_user_provided_supported && !is_model_predefined) {
878+
if (
879+
!is_user_provided_supported &&
880+
!is_model_predefined &&
881+
config.chatbot != 'OpenRouter'
882+
) {
879883
model = undefined
880884
}
881885
}

‎apps/editor/src/views/settings/backend/settings-view-provider.ts‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import {
5353
} from './message-handlers'
5454
import { config_web_configuration_to_ui_format } from '@/utils/web-configuration-format-converters'
5555
import { webview_html } from '@/views/shared/utils/webview-html'
56+
import { CHATBOTS } from '@shared/constants/chatbots'
5657

5758
export class SettingsViewProvider {
5859
private _webview_panel: vscode.WebviewPanel | undefined
@@ -72,8 +73,25 @@ export class SettingsViewProvider {
7273
this.postMessage({
7374
command: 'WEB_CONFIGURATIONS',
7475
web_configurations: web_configurations_config
75-
.filter((c: any) => c.chatbot)
76-
.map((c: any) => config_web_configuration_to_ui_format(c))
76+
.filter((c: any) => c.chatbot && CHATBOTS[c.chatbot as keyof typeof CHATBOTS])
77+
.map((config: any) => {
78+
let model = config.model
79+
if (config.chatbot && model) {
80+
const chatbot_info = CHATBOTS[config.chatbot as keyof typeof CHATBOTS]
81+
const is_user_provided_supported =
82+
chatbot_info.supports_user_provided_model
83+
const is_model_predefined = chatbot_info.models?.[model]
84+
85+
if (
86+
!is_user_provided_supported &&
87+
!is_model_predefined &&
88+
config.chatbot != 'OpenRouter'
89+
) {
90+
model = undefined
91+
}
92+
}
93+
return config_web_configuration_to_ui_format({ ...config, model })
94+
})
7795
})
7896
}
7997

0 commit comments

Comments
 (0)