From 3b4eccdd5d24e2a3ba0b4c5da7a66de071570d38 Mon Sep 17 00:00:00 2001 From: benjamin Date: Mon, 18 May 2026 19:01:44 +0800 Subject: [PATCH] feat: add upstream model sync frontend API Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- frontend/src/api/admin/accounts.ts | 15 +++++++++++++++ frontend/src/i18n/locales/en.ts | 7 +++++++ frontend/src/i18n/locales/zh.ts | 7 +++++++ 3 files changed, 29 insertions(+) diff --git a/frontend/src/api/admin/accounts.ts b/frontend/src/api/admin/accounts.ts index 00ed4087..f1be5e1d 100644 --- a/frontend/src/api/admin/accounts.ts +++ b/frontend/src/api/admin/accounts.ts @@ -446,6 +446,20 @@ export async function getAvailableModels(id: number): Promise { return data } +export interface SyncUpstreamModelsResult { + models: string[] +} + +/** + * Sync live supported models from the account's upstream model-list endpoint + * @param id - Account ID + * @returns List of model IDs returned by the upstream + */ +export async function syncUpstreamModels(id: number): Promise { + const { data } = await apiClient.post(`/admin/accounts/${id}/models/sync-upstream`) + return data +} + export interface CRSPreviewAccount { crs_account_id: string kind: string @@ -660,6 +674,7 @@ export const accountsAPI = { resetTempUnschedulable, setSchedulable, getAvailableModels, + syncUpstreamModels, generateAuthUrl, exchangeCode, refreshOpenAIToken, diff --git a/frontend/src/i18n/locales/en.ts b/frontend/src/i18n/locales/en.ts index 02d044ef..596af94c 100644 --- a/frontend/src/i18n/locales/en.ts +++ b/frontend/src/i18n/locales/en.ts @@ -3216,6 +3216,13 @@ export default { searchModels: 'Search models...', noMatchingModels: 'No matching models', fillRelatedModels: 'Sync latest supported models', + syncUpstreamModels: 'Sync upstream supported models', + syncUpstreamModelsLoading: 'Syncing upstream...', + syncUpstreamModelsSuccess: 'Synced {count} new model(s) from upstream ({total} upstream total)', + syncUpstreamModelsNoChanges: 'All {count} upstream model(s) are already in the whitelist', + syncUpstreamModelsEmpty: 'Upstream returned no models to sync', + syncUpstreamModelsFailed: 'Failed to sync upstream models', + syncUpstreamModelsError: 'Failed to sync upstream models: {message}', clearAllModels: 'Clear all models', customModelName: 'Custom model name', enterCustomModelName: 'Enter custom model name', diff --git a/frontend/src/i18n/locales/zh.ts b/frontend/src/i18n/locales/zh.ts index 687c2df6..cbbc6872 100644 --- a/frontend/src/i18n/locales/zh.ts +++ b/frontend/src/i18n/locales/zh.ts @@ -3360,6 +3360,13 @@ export default { searchModels: '搜索模型...', noMatchingModels: '没有匹配的模型', fillRelatedModels: '同步最新支持模型', + syncUpstreamModels: '同步上游支持的模型', + syncUpstreamModelsLoading: '同步上游中...', + syncUpstreamModelsSuccess: '已从上游同步 {count} 个新模型(上游共 {total} 个)', + syncUpstreamModelsNoChanges: '上游 {count} 个模型均已在白名单中', + syncUpstreamModelsEmpty: '上游没有返回可同步的模型', + syncUpstreamModelsFailed: '同步上游模型失败', + syncUpstreamModelsError: '同步上游模型失败:{message}', clearAllModels: '清除所有模型', customModelName: '自定义模型名称', enterCustomModelName: '输入自定义模型名称',