- Refines the overall structure of the CLI tools and MITM server functionalities.

- Add buildQwenBaseUrl function to construct URLs for Qwen resources.
- Update buildProviderUrl to support Qwen model requests.
- Enhance token refresh logic to include provider-specific data for Qwen.
- Refactor CLI Tools page to exclude MITM tools and streamline model retrieval.
- Introduce new components for MITM server management.
- Update API routes to handle Qwen-specific resource URLs and improve error handling.
This commit is contained in:
decolua
2026-03-05 11:25:03 +07:00
parent 40a53fbd33
commit 573b0f0241
29 changed files with 1490 additions and 438 deletions

View File

@@ -145,7 +145,7 @@ export const PROVIDER_MODELS = {
// API Key Providers (alias = id)
openai: [
{ id: "gpt-4o", name: "GPT-4o" },
{ id: "gpt-4o-mini", name: "GPT-4o Mini" },
{ id: "gpt-5-mini", name: "GPT-5 Mini" },
{ id: "gpt-4-turbo", name: "GPT-4 Turbo" },
{ id: "o1", name: "O1" },
{ id: "o1-mini", name: "O1 Mini" },

View File

@@ -34,6 +34,16 @@ function buildAnthropicCompatibleUrl(baseUrl) {
return `${normalized}/messages`;
}
function buildQwenBaseUrl(resourceUrl, fallbackBaseUrl) {
const fallback = (fallbackBaseUrl || "").replace(/\/chat\/completions$/, "");
const raw = typeof resourceUrl === "string" ? resourceUrl.trim() : "";
if (!raw) return fallback;
if (raw.startsWith("http://") || raw.startsWith("https://")) {
return raw.replace(/\/$/, "");
}
return `https://${raw.replace(/\/$/, "")}/v1`;
}
// Detect request format from body structure
export function detectFormat(body) {
// OpenAI Responses API: has input (array or string) instead of messages[]
@@ -178,6 +188,11 @@ export function buildProviderUrl(provider, model, stream = true, options = {}) {
case "codex":
return config.baseUrl;
case "qwen": {
const baseUrl = buildQwenBaseUrl(options?.qwenResourceUrl, config.baseUrl);
return `${baseUrl}/chat/completions`;
}
case "github":
return config.baseUrl;

View File

@@ -180,6 +180,9 @@ export async function refreshQwenToken(refreshToken, log) {
accessToken: tokens.access_token,
refreshToken: tokens.refresh_token || refreshToken,
expiresIn: tokens.expires_in,
providerSpecificData: tokens.resource_url
? { resourceUrl: tokens.resource_url }
: undefined,
};
} else {
const errorText = await response.text().catch(() => "");