fix: clarify ark agent plan model discovery

This commit is contained in:
stupid-h4er
2026-05-27 10:52:59 +08:00
parent fa9a3c1920
commit 3be0df0df6
6 changed files with 121 additions and 17 deletions
+6 -1
View File
@@ -215,6 +215,10 @@ export default function AdminSettingsPage() {
const channelModels = await fetchChannelModels(token, { index: editingChannelIndex ?? undefined, channel: normalizeChannel(channel) });
const current = isModelSelectorOpen ? uniqueModels(modelSelectSelected) : uniqueModels(channelForm.getFieldValue("models") || []);
rememberModels(channelModels);
if (!channelModels.length) {
message.warning("上游未返回模型列表,请手动输入模型名称");
return;
}
setModelSelectExisting(current);
setModelSelectSource(uniqueModels(channelModels));
setModelSelectSelected(uniqueModels([...current, ...channelModels]));
@@ -707,6 +711,7 @@ export default function AdminSettingsPage() {
</Button>
</Space.Compact>
</Flex>
<Typography.Text type="secondary"> OpenAI /models </Typography.Text>
<Tabs
activeKey={modelSelectTab}
onChange={(key) => setModelSelectTab(key as ModelSelectTabKey)}
@@ -765,7 +770,7 @@ export default function AdminSettingsPage() {
destroyOnHidden
>
<Flex vertical gap={12}>
<Typography.Text type="secondary"> hi</Typography.Text>
<Typography.Text type="secondary"> hiAgent Plan / Seedance </Typography.Text>
<Input.Search placeholder="搜索模型..." allowClear value={testKeyword} onChange={(event) => setTestKeyword(event.target.value)} />
<Table
rowKey="model"
+21 -3
View File
@@ -126,8 +126,26 @@ export function useEffectiveConfig() {
export function buildApiUrl(baseUrl: string, path: string) {
let normalizedBaseUrl = baseUrl.trim().replace(/\/+$/, "");
const arkPlanIndex = normalizedBaseUrl.toLowerCase().indexOf("/api/plan/v3");
if (arkPlanIndex >= 0) normalizedBaseUrl = normalizedBaseUrl.slice(0, arkPlanIndex + "/api/plan/v3".length);
const apiBaseUrl = normalizedBaseUrl.endsWith("/v1") || normalizedBaseUrl.endsWith("/api/v3") || normalizedBaseUrl.endsWith("/api/plan/v3") ? normalizedBaseUrl : `${normalizedBaseUrl}/v1`;
normalizedBaseUrl = normalizeArkPlanBaseUrl(normalizedBaseUrl);
const lowerBaseUrl = normalizedBaseUrl.toLowerCase();
const apiBaseUrl = lowerBaseUrl.endsWith("/v1") || lowerBaseUrl.endsWith("/api/v3") || lowerBaseUrl.endsWith("/api/plan/v3") ? normalizedBaseUrl : `${normalizedBaseUrl}/v1`;
return `${apiBaseUrl}${path}`;
}
function normalizeArkPlanBaseUrl(baseUrl: string) {
try {
const url = new URL(baseUrl);
const path = url.pathname.replace(/\/+$/, "");
const lowerPath = path.toLowerCase();
const arkPlanIndex = lowerPath.indexOf("/api/plan/v3");
if (arkPlanIndex < 0) return baseUrl;
const end = arkPlanIndex + "/api/plan/v3".length;
if (lowerPath.length !== end && lowerPath[end] !== "/") return baseUrl;
url.pathname = path.slice(0, end);
url.search = "";
url.hash = "";
return url.toString().replace(/\/+$/, "");
} catch {
return baseUrl;
}
}