@magpie-community/opencode-qoder-auth 0.2.37 → 0.2.38
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/README.md +15 -0
- package/index.mjs +6 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -166,6 +166,21 @@ itself.
|
|
|
166
166
|
|
|
167
167
|
## Models
|
|
168
168
|
|
|
169
|
+
Chat responses report the display name from the same model-list entry
|
|
170
|
+
used to build the request, in both JSON completions and every SSE chunk
|
|
171
|
+
(including usage). A blank name or a name equal to the slot key falls
|
|
172
|
+
back to the requested model ID. This shared behavior applies to Qoder,
|
|
173
|
+
Qoder CN, QwenWork and QwenWork Enterprise, including tier labels.
|
|
174
|
+
|
|
175
|
+
Reporting the name does not fetch the model list again. The existing
|
|
176
|
+
cache and model-list refresh behavior remain in place: a model missing
|
|
177
|
+
from the cache still forces a refresh, and normal list refreshes update
|
|
178
|
+
the configuration and name together. Model-list keys, API IDs,
|
|
179
|
+
`X-Model-Key` and `model_config` are unchanged; slots with the same display
|
|
180
|
+
name remain independently selectable. The name describes the catalog
|
|
181
|
+
entry used for the request, not an attestation of the backend that
|
|
182
|
+
executed it.
|
|
183
|
+
|
|
169
184
|
The `provider.models` hook reads the account's own list, as Qoder's client
|
|
170
185
|
asks for it (`/algo/api/v2/model/list`). It keeps the enabled models of the
|
|
171
186
|
listing's `app` scene, the list Qoder's app shows and the one a request
|
package/index.mjs
CHANGED
|
@@ -1685,7 +1685,7 @@ async function opened(res, tools) {
|
|
|
1685
1685
|
return { it, first: await it.next() }
|
|
1686
1686
|
}
|
|
1687
1687
|
|
|
1688
|
-
async function answer({ it, first }, chat) {
|
|
1688
|
+
async function answer({ it, first }, chat, servedName = chat.model) {
|
|
1689
1689
|
const id = "chatcmpl-" + hexID()
|
|
1690
1690
|
const created = Math.floor(Date.now() / 1000)
|
|
1691
1691
|
if (first.value?.error) return errorResponse(first.value.error)
|
|
@@ -1708,12 +1708,12 @@ async function answer({ it, first }, chat) {
|
|
|
1708
1708
|
}
|
|
1709
1709
|
if (reasoning) msg.reasoning_content = reasoning
|
|
1710
1710
|
if (calls.length) msg.tool_calls = calls
|
|
1711
|
-
return Response.json({ id, object: "chat.completion", created, model:
|
|
1711
|
+
return Response.json({ id, object: "chat.completion", created, model: servedName, choices: [{ index: 0, message: msg, finish_reason: stop }], ...(usage ? { usage } : {}) })
|
|
1712
1712
|
}
|
|
1713
1713
|
|
|
1714
1714
|
const enc = new TextEncoder()
|
|
1715
1715
|
const chunk = (delta, finish_reason = null, extra = {}) =>
|
|
1716
|
-
enc.encode(`data: ${JSON.stringify({ id, object: "chat.completion.chunk", created, model:
|
|
1716
|
+
enc.encode(`data: ${JSON.stringify({ id, object: "chat.completion.chunk", created, model: servedName, choices: [{ index: 0, delta, finish_reason }], ...extra })}\n\n`)
|
|
1717
1717
|
let pending = first
|
|
1718
1718
|
let began = false
|
|
1719
1719
|
const stream = new ReadableStream({
|
|
@@ -2555,6 +2555,8 @@ const makePlugin = (site) => async ({ client }) => {
|
|
|
2555
2555
|
return errorResponse({ status: 502, message: e?.message ?? String(e) })
|
|
2556
2556
|
}
|
|
2557
2557
|
if (!m) return errorResponse({ status: 400, message: `unknown or disabled model "${chat.model}"` })
|
|
2558
|
+
const name = m.name?.trim()
|
|
2559
|
+
const servedName = name && name !== m.key ? name : chat.model
|
|
2558
2560
|
const api = siteOf(site, cred).api
|
|
2559
2561
|
const CHAT_URL = api + CHAT_PATH
|
|
2560
2562
|
const task = taskOf(sessionOf(chat, named), chat)
|
|
@@ -2582,7 +2584,7 @@ const makePlugin = (site) => async ({ client }) => {
|
|
|
2582
2584
|
const f = !res.ok ? failure(res.status, (await res.text()).slice(0, 1 << 20)) : open.first.value?.error
|
|
2583
2585
|
// an answered call moves its task on, as Qoder's client moves it
|
|
2584
2586
|
if (!f) task.answered = true
|
|
2585
|
-
if (!f?.queue || waited >= QUEUE.recoveries) return f && !res.ok ? errorResponse(f) : answer(open, chat)
|
|
2587
|
+
if (!f?.queue || waited >= QUEUE.recoveries) return f && !res.ok ? errorResponse(f) : answer(open, chat, servedName)
|
|
2586
2588
|
try {
|
|
2587
2589
|
if (!(await queueWait(api, cred, ask, f.queue, init.signal, deadline, siteOf(site, cred)))) return errorResponse(f)
|
|
2588
2590
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-qoder-auth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.38",
|
|
4
4
|
"description": "Qoder and QwenWork (千问办公) subscriptions in OpenCode and magpie: qoder.com, qoder.cn, gateway.qwenwork.cn and the enterprise flagship (VPC)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|