agent-mp 0.4.8 → 0.4.9
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/utils/qwen-auth.js +7 -2
- package/package.json +1 -1
package/dist/utils/qwen-auth.js
CHANGED
|
@@ -225,6 +225,9 @@ export async function qwenAuthStatus() {
|
|
|
225
225
|
const token = await loadToken();
|
|
226
226
|
if (!token)
|
|
227
227
|
return { authenticated: false };
|
|
228
|
+
// Verify token is not expired (loadToken already refreshes if close to expiry)
|
|
229
|
+
if (token.expiresAt > 0 && token.expiresAt < Date.now())
|
|
230
|
+
return { authenticated: false };
|
|
228
231
|
return { authenticated: true };
|
|
229
232
|
}
|
|
230
233
|
export async function fetchQwenModels() {
|
|
@@ -232,7 +235,8 @@ export async function fetchQwenModels() {
|
|
|
232
235
|
if (!token)
|
|
233
236
|
return [];
|
|
234
237
|
try {
|
|
235
|
-
const
|
|
238
|
+
const host = token.resourceUrl ? `https://${token.resourceUrl}` : 'https://chat.qwen.ai';
|
|
239
|
+
const res = await fetch(`${host}/api/models`, {
|
|
236
240
|
headers: { Authorization: `Bearer ${token.accessToken}` },
|
|
237
241
|
});
|
|
238
242
|
if (!res.ok)
|
|
@@ -249,7 +253,8 @@ export async function getQwenAccessToken() {
|
|
|
249
253
|
return token?.accessToken || null;
|
|
250
254
|
}
|
|
251
255
|
async function callQwenAPIWithToken(token, prompt, model, onData) {
|
|
252
|
-
const
|
|
256
|
+
const host = token.resourceUrl ? `https://${token.resourceUrl}` : 'https://chat.qwen.ai';
|
|
257
|
+
const baseUrl = `${host}/api/v1`;
|
|
253
258
|
const useStream = !!onData;
|
|
254
259
|
const response = await fetch(`${baseUrl}/chat/completions`, {
|
|
255
260
|
method: 'POST',
|