+
+
+
+
+
+
+
()
@@ -263,6 +292,7 @@ interface TemplateForm {
id: number | null
name: string
provider: Provider
+ api_mode: APIMode
description: string
extra_headers: Record
body_override_mode: BodyOverrideMode
@@ -278,6 +308,7 @@ function emptyForm(provider: Provider): TemplateForm {
id: null,
name: '',
provider,
+ api_mode: API_MODE_CHAT_COMPLETIONS,
description: '',
extra_headers: {},
body_override_mode: 'off',
@@ -289,6 +320,7 @@ function loadForm(tpl: ChannelMonitorTemplate) {
form.id = tpl.id
form.name = tpl.name
form.provider = tpl.provider
+ form.api_mode = normalizeAPIMode(tpl.api_mode)
form.description = tpl.description
form.extra_headers = { ...(tpl.extra_headers || {}) }
form.body_override_mode = tpl.body_override_mode
@@ -346,6 +378,7 @@ async function handleSubmit() {
await adminAPI.channelMonitorTemplate.create({
name: form.name.trim(),
provider: form.provider,
+ api_mode: form.provider === PROVIDER_OPENAI ? form.api_mode : API_MODE_CHAT_COMPLETIONS,
description: form.description.trim(),
extra_headers: form.extra_headers,
body_override_mode: form.body_override_mode,
@@ -355,6 +388,7 @@ async function handleSubmit() {
} else if (typeof editing.value === 'number') {
await adminAPI.channelMonitorTemplate.update(editing.value, {
name: form.name.trim(),
+ api_mode: form.provider === PROVIDER_OPENAI ? form.api_mode : API_MODE_CHAT_COMPLETIONS,
description: form.description.trim(),
extra_headers: form.extra_headers,
body_override_mode: form.body_override_mode,
@@ -444,4 +478,48 @@ function modeBadgeClass(mode: BodyOverrideMode): string {
function modeLabel(mode: BodyOverrideMode): string {
return t(`admin.channelMonitor.advanced.bodyMode${mode.charAt(0).toUpperCase()}${mode.slice(1)}`)
}
+
+const apiModeOptions = computed<{ value: APIMode; label: string; hint: string }[]>(() => [
+ {
+ value: API_MODE_CHAT_COMPLETIONS,
+ label: t('admin.channelMonitor.form.apiModeChatCompletions'),
+ hint: t('admin.channelMonitor.form.apiModeChatCompletionsHint'),
+ },
+ {
+ value: API_MODE_RESPONSES,
+ label: t('admin.channelMonitor.form.apiModeResponses'),
+ hint: t('admin.channelMonitor.form.apiModeResponsesHint'),
+ },
+])
+
+watch(() => form.provider, (provider) => {
+ if (provider !== PROVIDER_OPENAI) {
+ form.api_mode = API_MODE_CHAT_COMPLETIONS
+ }
+})
+
+function normalizeAPIMode(mode: APIMode | undefined | null): APIMode {
+ return mode === API_MODE_RESPONSES ? API_MODE_RESPONSES : API_MODE_CHAT_COMPLETIONS
+}
+
+function apiModeButtonClass(mode: APIMode): string {
+ const active = form.api_mode === mode
+ if (active) {
+ return 'border-primary-500 bg-white text-primary-700 shadow-sm dark:border-primary-400 dark:bg-primary-500/15 dark:text-primary-300'
+ }
+ return 'border-blue-100 bg-white/70 text-gray-600 hover:border-primary-300 dark:border-dark-700 dark:bg-dark-800 dark:text-gray-400'
+}
+
+function apiModeLabel(mode: APIMode): string {
+ return normalizeAPIMode(mode) === API_MODE_RESPONSES
+ ? t('admin.channelMonitor.form.apiModeResponses')
+ : t('admin.channelMonitor.form.apiModeChatCompletions')
+}
+
+function apiModeBadgeClass(mode: APIMode): string {
+ if (normalizeAPIMode(mode) === API_MODE_RESPONSES) {
+ return 'bg-blue-100 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300'
+ }
+ return 'bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300'
+}