@fish-under-sea/magpie-dragonapi 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.mjs CHANGED
@@ -118,16 +118,18 @@ function makeContext(input, options) {
118
118
  catalog,
119
119
  status,
120
120
  /**
121
- * preferResponses 读「优先走 Responses API」开关。
121
+ * preferResponses 读「走 Responses API」开关。
122
122
  *
123
- * 站点有些模型同时支持 chat 与 Responses;默认走 chat 兼容性最好,
124
- * 用户打开这个开关后,声明了 openai-response 的模型改用 Responses。
123
+ * 默认**开**:站点是 New API 部署,对话模型统一走 `/v1/responses`,
124
+ * 这样 magpie 的模型设置里才会出现 Responses 协议选项(协议选项是按
125
+ * 模型表里实际用到的协议归纳的)。关掉则退回 chat completions。
126
+ * 旧宿主不提供 option 时按默认(开)处理。
125
127
  */
126
128
  preferResponses() {
127
129
  try {
128
130
  const v = input?.magpie?.option?.(PROVIDER_ID, OPT_RESPONSES)
129
- return v === true
130
- } catch { return false }
131
+ return v === undefined || v === null ? true : v === true
132
+ } catch { return true }
131
133
  },
132
134
  noteModelsError: (why) => { state.lastModelsError = why },
133
135
  }
@@ -218,9 +220,9 @@ export default async function dragonapi(input, options) {
218
220
  options: [
219
221
  {
220
222
  key: OPT_RESPONSES,
221
- label: '优先 Responses API',
222
- description: '同时支持 chat 与 Responses 的模型改用 Responses API;关掉则走 chat completions。',
223
- default: false,
223
+ label: '走 Responses API',
224
+ description: '默认走 Responses API(模型设置里可看到 Responses 协议);关掉退回 chat completions。',
225
+ default: true,
224
226
  },
225
227
  ],
226
228
  get icon() {
package/lib/catalog.mjs CHANGED
@@ -22,11 +22,23 @@ export function npmOf(row, { preferResponses = false } = {}) {
22
22
  // 按模型挑原生协议,才能真正做到「每个模型走自己的端点」。
23
23
  if (ends.includes('anthropic')) return '@ai-sdk/anthropic'
24
24
  if (ends.includes('gemini')) return '@ai-sdk/google'
25
- // Responses API:只有声明了 openai-response 才可能走它;同时支持 chat 时
26
- // 默认走 chat(兼容性最好),用户打开「优先 Responses」才切过去。
25
+ // Responses API(`@ai-sdk/openai`)。magpie 的编辑器只给它「看到了协议地址」
26
+ // 的协议出选项,而插件供应商的协议地址是从模型表里归纳出来的——所以哪怕只想
27
+ // 摆一个 Responses 选项,也必须有模型真的用它。
28
+ //
29
+ // - 只声明 openai-response:本来就只有 Responses 一条路,直接走它。
30
+ // - 同时声明 openai + openai-response:默认 chat(兼容性最好);用户打开
31
+ // 「优先 Responses」后改走 Responses,此时编辑器里才会出现 Responses 选项,
32
+ // 可以再按模型单独改回 OpenAI。
27
33
  const responses = ends.includes('openai-response')
28
34
  const chat = ends.includes('openai')
35
+ // 生图/视频等非对话模型必须留在 openai-compatible:magpie 的 Images API
36
+ // 只认这个方言(PluginOpenAICompatible),换协议会直接画不出图。
37
+ if (kindOf(row) !== 'chat') return '@ai-sdk/openai-compatible'
38
+ // 只声明 openai-response 的模型没有别的路,直接走 Responses;同时支持 chat
39
+ // 时看开关:默认开(让协议表里有 Responses 可选),关掉就退回 chat。
29
40
  if (responses && (!chat || preferResponses)) return '@ai-sdk/openai'
41
+ if (preferResponses && chat) return '@ai-sdk/openai'
30
42
  return '@ai-sdk/openai-compatible'
31
43
  }
32
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fish-under-sea/magpie-dragonapi",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "DragonAPI for magpie: a provider plugin whose models, groups and prices come from the site's public /api/pricing, with balance and per-call usage from an sk- key, plus a local page that lists the market (read-only), shows usage and can mint new keys for a group.",
5
5
  "type": "module",
6
6
  "main": "index.mjs",