@fish-under-sea/magpie-dragonapi 1.1.1 → 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 +10 -8
- package/lib/catalog.mjs +5 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -118,16 +118,18 @@ function makeContext(input, options) {
|
|
|
118
118
|
catalog,
|
|
119
119
|
status,
|
|
120
120
|
/**
|
|
121
|
-
* preferResponses
|
|
121
|
+
* preferResponses 读「走 Responses API」开关。
|
|
122
122
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
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
|
|
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: '
|
|
222
|
-
description: '
|
|
223
|
-
default:
|
|
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
|
@@ -32,6 +32,11 @@ export function npmOf(row, { preferResponses = false } = {}) {
|
|
|
32
32
|
// 可以再按模型单独改回 OpenAI。
|
|
33
33
|
const responses = ends.includes('openai-response')
|
|
34
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。
|
|
35
40
|
if (responses && (!chat || preferResponses)) return '@ai-sdk/openai'
|
|
36
41
|
if (preferResponses && chat) return '@ai-sdk/openai'
|
|
37
42
|
return '@ai-sdk/openai-compatible'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fish-under-sea/magpie-dragonapi",
|
|
3
|
-
"version": "1.
|
|
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",
|