qwen.js 0.1.3 → 0.1.5
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/dist/index.js +4 -3
- package/package.json +1 -1
- package/readme.md +1 -1
package/dist/index.js
CHANGED
|
@@ -30,8 +30,9 @@ async function requestDeviceCode(challenge) {
|
|
|
30
30
|
return response.json();
|
|
31
31
|
}
|
|
32
32
|
async function pollForToken(deviceCode, verifier, interval) {
|
|
33
|
+
let pollInterval = Number.isFinite(interval) && interval > 0 ? interval : 5;
|
|
33
34
|
while (true) {
|
|
34
|
-
await new Promise((r) => setTimeout(r,
|
|
35
|
+
await new Promise((r) => setTimeout(r, pollInterval * 1000));
|
|
35
36
|
const response = await fetch(`${AUTH_BASE}/token`, {
|
|
36
37
|
method: "POST",
|
|
37
38
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
@@ -50,7 +51,7 @@ async function pollForToken(deviceCode, verifier, interval) {
|
|
|
50
51
|
continue;
|
|
51
52
|
}
|
|
52
53
|
if (data.error === "slow_down") {
|
|
53
|
-
|
|
54
|
+
pollInterval += 1;
|
|
54
55
|
continue;
|
|
55
56
|
}
|
|
56
57
|
throw new Error(`Token poll failed: ${data.error_description || data.error}`);
|
|
@@ -78,7 +79,7 @@ function isTokenExpired(state) {
|
|
|
78
79
|
|
|
79
80
|
// src/client.ts
|
|
80
81
|
var API_BASE = "https://portal.qwen.ai/v1";
|
|
81
|
-
var DEFAULT_MODEL = "
|
|
82
|
+
var DEFAULT_MODEL = "coder-model";
|
|
82
83
|
var TOKEN_LIFETIME_MS = 6 * 60 * 60 * 1000;
|
|
83
84
|
|
|
84
85
|
class QwenClient {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -123,7 +123,7 @@ const qwen2 = createQwen({
|
|
|
123
123
|
|--------|------|-------------|
|
|
124
124
|
| `accessToken` | `string` | Pre-existing access token |
|
|
125
125
|
| `refreshToken` | `string` | Pre-existing refresh token |
|
|
126
|
-
| `model` | `string` | Default model (default: `
|
|
126
|
+
| `model` | `string` | Default model (default: `coder-model`) |
|
|
127
127
|
|
|
128
128
|
### Methods
|
|
129
129
|
|