From b685fe69a4b06995214bcbd1c19e0b8acb93ac31 Mon Sep 17 00:00:00 2001 From: benjamin Date: Tue, 19 May 2026 22:04:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(channel-monitor):=20=E5=86=85=E7=BD=AE=20O?= =?UTF-8?q?penAI=20=E6=A3=80=E6=B5=8B=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- .../139_seed_openai_monitor_templates.sql | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 backend/migrations/139_seed_openai_monitor_templates.sql diff --git a/backend/migrations/139_seed_openai_monitor_templates.sql b/backend/migrations/139_seed_openai_monitor_templates.sql new file mode 100644 index 00000000..6326cd0a --- /dev/null +++ b/backend/migrations/139_seed_openai_monitor_templates.sql @@ -0,0 +1,47 @@ +-- Migration: 138_seed_openai_monitor_templates +-- 内置 OpenAI 渠道监控模板。重点是把协议模式显式化: +-- 1) OpenAI-compatible 使用 Chat Completions payload +-- 2) Responses / 本站自检 使用 Responses payload,默认 body 由后端 adapter 填入 instructions + input +-- 所有模板都可直接选择;ON CONFLICT 保证重复部署不覆盖用户编辑。 + +INSERT INTO channel_monitor_request_templates ( + name, provider, api_mode, description, extra_headers, body_override_mode, body_override +) +VALUES +( + 'OpenAI Compatible 默认检测', + 'openai', + 'chat_completions', + '适用于大多数 OpenAI-compatible 上游:POST /v1/chat/completions,后端自动生成 messages 数学 challenge。', + '{}'::jsonb, + 'off', + NULL +), +( + 'OpenAI Compatible 低 token 检测', + 'openai', + 'chat_completions', + '仍走 /v1/chat/completions,仅把 max_tokens 调低;model/messages/stream 由后端保护,避免误伤 challenge。', + '{}'::jsonb, + 'merge', + '{"max_tokens": 20}'::jsonb +), +( + 'OpenAI Responses / 本站自检', + 'openai', + 'responses', + '适用于本站或原生 Responses API:POST /v1/responses,默认 payload 自动带 instructions 与 input,避免 Instructions are required。', + '{}'::jsonb, + 'off', + NULL +), +( + 'OpenAI Responses 低 token 检测', + 'openai', + 'responses', + '仍走 /v1/responses,仅把 max_output_tokens 调低;instructions/input/model/stream 由后端保护。', + '{}'::jsonb, + 'merge', + '{"max_output_tokens": 20}'::jsonb +) +ON CONFLICT (provider, name) DO NOTHING;