new-api/web/src/components/table/models/ModelsActions.jsx

260 lines
7.5 KiB
React
Raw Normal View History

🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements Backend • Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps • Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go` • Auto-migrate new tables in DB startup logic Frontend • Build complete “Model Management” module under `/console/models` - New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs - Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile` • Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature • Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes Table UX improvements • Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style) • Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags • Color all tags deterministically using `stringToColor` for consistent theming • Change vendor column tag color to white for better contrast Misc • Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { useState } from 'react';
import MissingModelsModal from './modals/MissingModelsModal';
import PrefillGroupManagement from './modals/PrefillGroupManagement';
import EditPrefillGroupModal from './modals/EditPrefillGroupModal';
✨ feat(sync): multi-language sync wizard, backend locale support, and conflict modal UX improvements Frontend (web) - ModelsActions.jsx - Replace “Sync Official” with “Sync” and open a new two-step SyncWizard. - Pass selected locale through to preview, sync, and overwrite flows. - Keep conflict resolution flow; inject locale into overwrite submission. - New: models/modals/SyncWizardModal.jsx - Two-step wizard: (1) method selection (config-sync disabled for now), (2) language selection (en/zh/ja). - Horizontal, centered Radio cards; returns { option, locale } via onConfirm. - UpstreamConflictModal.jsx - Add search input (model fuzzy search) and native pagination. - Column header checkbox now only applies to rows in the current filtered result. - Fix “Cannot access ‘filteredDataSource’ before initialization”. - Refactor with useMemo/useCallback; extract helpers to remove duplicated logic: - getPresentRowsForField, getHeaderState, applyHeaderChange - Minor code cleanups and stability improvements. - i18n (en.json) - Add strings for the sync wizard and related actions (Sync, Sync Wizard, Select method/source/language, etc.). - Adjust minor translations. Hooks - useModelsData.jsx - Extend previewUpstreamDiff, syncUpstream, applyUpstreamOverwrite to accept options with locale. - Send locale via query/body accordingly. Backend (Go) - controller/model_sync.go - Accept locale from query/body and resolve i18n upstream URLs. - Add SYNC_UPSTREAM_BASE for upstream base override (default: https://basellm.github.io/llm-metadata). - Make HTTP timeouts/retries/limits configurable: - SYNC_HTTP_TIMEOUT_SECONDS, SYNC_HTTP_RETRY, SYNC_HTTP_MAX_MB - Add ETag-based caching and support both envelope and pure array JSON formats. - Concurrently fetch vendors and models; improve error responses with locale and source URLs. - Include source meta (locale, models_url, vendors_url) in success payloads. Notes - No breaking changes expected. - Lint passes for touched files.
2025-09-02 18:49:37 +08:00
import { Button, Modal, Popover, RadioGroup, Radio } from '@douyinfe/semi-ui';
import { showSuccess, showError, copy } from '../../../helpers';
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements Backend • Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps • Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go` • Auto-migrate new tables in DB startup logic Frontend • Build complete “Model Management” module under `/console/models` - New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs - Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile` • Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature • Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes Table UX improvements • Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style) • Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags • Color all tags deterministically using `stringToColor` for consistent theming • Change vendor column tag color to white for better contrast Misc • Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
import CompactModeToggle from '../../common/ui/CompactModeToggle';
import SelectionNotification from './components/SelectionNotification';
✨ feat(models-sync): official upstream sync with conflict resolution UI, opt‑out flag, and backend resiliency Backend - Add endpoints: - GET /api/models/sync_upstream/preview — diff preview (filters out models with sync_official = 0) - POST /api/models/sync_upstream — apply sync (create missing; optionally overwrite selected fields) - Respect opt‑out: skip models with sync_official = 0 in both preview and apply - Return detailed stats: created_models, created_vendors, updated_models, skipped_models, plus created_list / updated_list - Add model.Model.SyncOfficial (default 1); auto‑migrated by GORM - Make HTTP fetching robust: - Shared http.Client (connection reuse) with 3x exponential backoff retry - 10MB response cap; keep existing IPv4‑first for *.github.io - Vendor handling: - New ensureVendorID helper (cache lookup → DB lookup → create), reduces round‑trips - Transactional overwrite to avoid partial updates - Small cleanups and clearer helpers (containsField, coalesce, chooseStatus) Frontend - ModelsActions: add “Sync official” button with Popover (p‑2) explaining community contribution; loading = syncing || previewing; preview → conflict modal → apply flow - New UpstreamConflictModal: - Per‑field columns (description/icon/tags/vendor/name_rule/status) with column‑level checkbox to select all - Cell with Checkbox + Tag (“Click to view differences”) and Popover (p‑2) showing Local vs Official values - Auto‑hide columns with no conflicts; responsive width; use native Semi Modal footer - Full i18n coverage - useModelsData: add syncing/previewing states; new methods previewUpstreamDiff, applyUpstreamOverwrite, syncUpstream; refresh vendors/models after apply - EditModelModal: add “Participate in official sync” switch; persisted as sync_official - ModelsColumnDefs: add “Participate in official sync” column i18n - Add missing English keys for the new UI and messages; fix quoting issues Refs - Upstream metadata: https://github.com/basellm/llm-metadata
2025-09-02 02:04:22 +08:00
import UpstreamConflictModal from './modals/UpstreamConflictModal';
✨ feat(sync): multi-language sync wizard, backend locale support, and conflict modal UX improvements Frontend (web) - ModelsActions.jsx - Replace “Sync Official” with “Sync” and open a new two-step SyncWizard. - Pass selected locale through to preview, sync, and overwrite flows. - Keep conflict resolution flow; inject locale into overwrite submission. - New: models/modals/SyncWizardModal.jsx - Two-step wizard: (1) method selection (config-sync disabled for now), (2) language selection (en/zh/ja). - Horizontal, centered Radio cards; returns { option, locale } via onConfirm. - UpstreamConflictModal.jsx - Add search input (model fuzzy search) and native pagination. - Column header checkbox now only applies to rows in the current filtered result. - Fix “Cannot access ‘filteredDataSource’ before initialization”. - Refactor with useMemo/useCallback; extract helpers to remove duplicated logic: - getPresentRowsForField, getHeaderState, applyHeaderChange - Minor code cleanups and stability improvements. - i18n (en.json) - Add strings for the sync wizard and related actions (Sync, Sync Wizard, Select method/source/language, etc.). - Adjust minor translations. Hooks - useModelsData.jsx - Extend previewUpstreamDiff, syncUpstream, applyUpstreamOverwrite to accept options with locale. - Send locale via query/body accordingly. Backend (Go) - controller/model_sync.go - Accept locale from query/body and resolve i18n upstream URLs. - Add SYNC_UPSTREAM_BASE for upstream base override (default: https://basellm.github.io/llm-metadata). - Make HTTP timeouts/retries/limits configurable: - SYNC_HTTP_TIMEOUT_SECONDS, SYNC_HTTP_RETRY, SYNC_HTTP_MAX_MB - Add ETag-based caching and support both envelope and pure array JSON formats. - Concurrently fetch vendors and models; improve error responses with locale and source URLs. - Include source meta (locale, models_url, vendors_url) in success payloads. Notes - No breaking changes expected. - Lint passes for touched files.
2025-09-02 18:49:37 +08:00
import SyncWizardModal from './modals/SyncWizardModal';
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements Backend • Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps • Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go` • Auto-migrate new tables in DB startup logic Frontend • Build complete “Model Management” module under `/console/models` - New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs - Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile` • Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature • Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes Table UX improvements • Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style) • Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags • Color all tags deterministically using `stringToColor` for consistent theming • Change vendor column tag color to white for better contrast Misc • Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
const ModelsActions = ({
selectedKeys,
setSelectedKeys,
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements Backend • Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps • Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go` • Auto-migrate new tables in DB startup logic Frontend • Build complete “Model Management” module under `/console/models` - New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs - Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile` • Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature • Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes Table UX improvements • Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style) • Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags • Color all tags deterministically using `stringToColor` for consistent theming • Change vendor column tag color to white for better contrast Misc • Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
setEditingModel,
setShowEdit,
batchDeleteModels,
✨ feat(models-sync): official upstream sync with conflict resolution UI, opt‑out flag, and backend resiliency Backend - Add endpoints: - GET /api/models/sync_upstream/preview — diff preview (filters out models with sync_official = 0) - POST /api/models/sync_upstream — apply sync (create missing; optionally overwrite selected fields) - Respect opt‑out: skip models with sync_official = 0 in both preview and apply - Return detailed stats: created_models, created_vendors, updated_models, skipped_models, plus created_list / updated_list - Add model.Model.SyncOfficial (default 1); auto‑migrated by GORM - Make HTTP fetching robust: - Shared http.Client (connection reuse) with 3x exponential backoff retry - 10MB response cap; keep existing IPv4‑first for *.github.io - Vendor handling: - New ensureVendorID helper (cache lookup → DB lookup → create), reduces round‑trips - Transactional overwrite to avoid partial updates - Small cleanups and clearer helpers (containsField, coalesce, chooseStatus) Frontend - ModelsActions: add “Sync official” button with Popover (p‑2) explaining community contribution; loading = syncing || previewing; preview → conflict modal → apply flow - New UpstreamConflictModal: - Per‑field columns (description/icon/tags/vendor/name_rule/status) with column‑level checkbox to select all - Cell with Checkbox + Tag (“Click to view differences”) and Popover (p‑2) showing Local vs Official values - Auto‑hide columns with no conflicts; responsive width; use native Semi Modal footer - Full i18n coverage - useModelsData: add syncing/previewing states; new methods previewUpstreamDiff, applyUpstreamOverwrite, syncUpstream; refresh vendors/models after apply - EditModelModal: add “Participate in official sync” switch; persisted as sync_official - ModelsColumnDefs: add “Participate in official sync” column i18n - Add missing English keys for the new UI and messages; fix quoting issues Refs - Upstream metadata: https://github.com/basellm/llm-metadata
2025-09-02 02:04:22 +08:00
syncing,
previewing,
syncUpstream,
previewUpstreamDiff,
applyUpstreamOverwrite,
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements Backend • Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps • Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go` • Auto-migrate new tables in DB startup logic Frontend • Build complete “Model Management” module under `/console/models` - New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs - Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile` • Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature • Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes Table UX improvements • Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style) • Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags • Color all tags deterministically using `stringToColor` for consistent theming • Change vendor column tag color to white for better contrast Misc • Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
compactMode,
setCompactMode,
t,
}) => {
// Modal states
const [showDeleteModal, setShowDeleteModal] = useState(false);
const [showMissingModal, setShowMissingModal] = useState(false);
const [showGroupManagement, setShowGroupManagement] = useState(false);
const [showAddPrefill, setShowAddPrefill] = useState(false);
const [prefillInit, setPrefillInit] = useState({ id: undefined });
✨ feat(models-sync): official upstream sync with conflict resolution UI, opt‑out flag, and backend resiliency Backend - Add endpoints: - GET /api/models/sync_upstream/preview — diff preview (filters out models with sync_official = 0) - POST /api/models/sync_upstream — apply sync (create missing; optionally overwrite selected fields) - Respect opt‑out: skip models with sync_official = 0 in both preview and apply - Return detailed stats: created_models, created_vendors, updated_models, skipped_models, plus created_list / updated_list - Add model.Model.SyncOfficial (default 1); auto‑migrated by GORM - Make HTTP fetching robust: - Shared http.Client (connection reuse) with 3x exponential backoff retry - 10MB response cap; keep existing IPv4‑first for *.github.io - Vendor handling: - New ensureVendorID helper (cache lookup → DB lookup → create), reduces round‑trips - Transactional overwrite to avoid partial updates - Small cleanups and clearer helpers (containsField, coalesce, chooseStatus) Frontend - ModelsActions: add “Sync official” button with Popover (p‑2) explaining community contribution; loading = syncing || previewing; preview → conflict modal → apply flow - New UpstreamConflictModal: - Per‑field columns (description/icon/tags/vendor/name_rule/status) with column‑level checkbox to select all - Cell with Checkbox + Tag (“Click to view differences”) and Popover (p‑2) showing Local vs Official values - Auto‑hide columns with no conflicts; responsive width; use native Semi Modal footer - Full i18n coverage - useModelsData: add syncing/previewing states; new methods previewUpstreamDiff, applyUpstreamOverwrite, syncUpstream; refresh vendors/models after apply - EditModelModal: add “Participate in official sync” switch; persisted as sync_official - ModelsColumnDefs: add “Participate in official sync” column i18n - Add missing English keys for the new UI and messages; fix quoting issues Refs - Upstream metadata: https://github.com/basellm/llm-metadata
2025-09-02 02:04:22 +08:00
const [showConflict, setShowConflict] = useState(false);
const [conflicts, setConflicts] = useState([]);
✨ feat(sync): multi-language sync wizard, backend locale support, and conflict modal UX improvements Frontend (web) - ModelsActions.jsx - Replace “Sync Official” with “Sync” and open a new two-step SyncWizard. - Pass selected locale through to preview, sync, and overwrite flows. - Keep conflict resolution flow; inject locale into overwrite submission. - New: models/modals/SyncWizardModal.jsx - Two-step wizard: (1) method selection (config-sync disabled for now), (2) language selection (en/zh/ja). - Horizontal, centered Radio cards; returns { option, locale } via onConfirm. - UpstreamConflictModal.jsx - Add search input (model fuzzy search) and native pagination. - Column header checkbox now only applies to rows in the current filtered result. - Fix “Cannot access ‘filteredDataSource’ before initialization”. - Refactor with useMemo/useCallback; extract helpers to remove duplicated logic: - getPresentRowsForField, getHeaderState, applyHeaderChange - Minor code cleanups and stability improvements. - i18n (en.json) - Add strings for the sync wizard and related actions (Sync, Sync Wizard, Select method/source/language, etc.). - Adjust minor translations. Hooks - useModelsData.jsx - Extend previewUpstreamDiff, syncUpstream, applyUpstreamOverwrite to accept options with locale. - Send locale via query/body accordingly. Backend (Go) - controller/model_sync.go - Accept locale from query/body and resolve i18n upstream URLs. - Add SYNC_UPSTREAM_BASE for upstream base override (default: https://basellm.github.io/llm-metadata). - Make HTTP timeouts/retries/limits configurable: - SYNC_HTTP_TIMEOUT_SECONDS, SYNC_HTTP_RETRY, SYNC_HTTP_MAX_MB - Add ETag-based caching and support both envelope and pure array JSON formats. - Concurrently fetch vendors and models; improve error responses with locale and source URLs. - Include source meta (locale, models_url, vendors_url) in success payloads. Notes - No breaking changes expected. - Lint passes for touched files.
2025-09-02 18:49:37 +08:00
const [showSyncModal, setShowSyncModal] = useState(false);
const [syncLocale, setSyncLocale] = useState('zh');
✨ feat(models-sync): official upstream sync with conflict resolution UI, opt‑out flag, and backend resiliency Backend - Add endpoints: - GET /api/models/sync_upstream/preview — diff preview (filters out models with sync_official = 0) - POST /api/models/sync_upstream — apply sync (create missing; optionally overwrite selected fields) - Respect opt‑out: skip models with sync_official = 0 in both preview and apply - Return detailed stats: created_models, created_vendors, updated_models, skipped_models, plus created_list / updated_list - Add model.Model.SyncOfficial (default 1); auto‑migrated by GORM - Make HTTP fetching robust: - Shared http.Client (connection reuse) with 3x exponential backoff retry - 10MB response cap; keep existing IPv4‑first for *.github.io - Vendor handling: - New ensureVendorID helper (cache lookup → DB lookup → create), reduces round‑trips - Transactional overwrite to avoid partial updates - Small cleanups and clearer helpers (containsField, coalesce, chooseStatus) Frontend - ModelsActions: add “Sync official” button with Popover (p‑2) explaining community contribution; loading = syncing || previewing; preview → conflict modal → apply flow - New UpstreamConflictModal: - Per‑field columns (description/icon/tags/vendor/name_rule/status) with column‑level checkbox to select all - Cell with Checkbox + Tag (“Click to view differences”) and Popover (p‑2) showing Local vs Official values - Auto‑hide columns with no conflicts; responsive width; use native Semi Modal footer - Full i18n coverage - useModelsData: add syncing/previewing states; new methods previewUpstreamDiff, applyUpstreamOverwrite, syncUpstream; refresh vendors/models after apply - EditModelModal: add “Participate in official sync” switch; persisted as sync_official - ModelsColumnDefs: add “Participate in official sync” column i18n - Add missing English keys for the new UI and messages; fix quoting issues Refs - Upstream metadata: https://github.com/basellm/llm-metadata
2025-09-02 02:04:22 +08:00
✨ feat(sync): multi-language sync wizard, backend locale support, and conflict modal UX improvements Frontend (web) - ModelsActions.jsx - Replace “Sync Official” with “Sync” and open a new two-step SyncWizard. - Pass selected locale through to preview, sync, and overwrite flows. - Keep conflict resolution flow; inject locale into overwrite submission. - New: models/modals/SyncWizardModal.jsx - Two-step wizard: (1) method selection (config-sync disabled for now), (2) language selection (en/zh/ja). - Horizontal, centered Radio cards; returns { option, locale } via onConfirm. - UpstreamConflictModal.jsx - Add search input (model fuzzy search) and native pagination. - Column header checkbox now only applies to rows in the current filtered result. - Fix “Cannot access ‘filteredDataSource’ before initialization”. - Refactor with useMemo/useCallback; extract helpers to remove duplicated logic: - getPresentRowsForField, getHeaderState, applyHeaderChange - Minor code cleanups and stability improvements. - i18n (en.json) - Add strings for the sync wizard and related actions (Sync, Sync Wizard, Select method/source/language, etc.). - Adjust minor translations. Hooks - useModelsData.jsx - Extend previewUpstreamDiff, syncUpstream, applyUpstreamOverwrite to accept options with locale. - Send locale via query/body accordingly. Backend (Go) - controller/model_sync.go - Accept locale from query/body and resolve i18n upstream URLs. - Add SYNC_UPSTREAM_BASE for upstream base override (default: https://basellm.github.io/llm-metadata). - Make HTTP timeouts/retries/limits configurable: - SYNC_HTTP_TIMEOUT_SECONDS, SYNC_HTTP_RETRY, SYNC_HTTP_MAX_MB - Add ETag-based caching and support both envelope and pure array JSON formats. - Concurrently fetch vendors and models; improve error responses with locale and source URLs. - Include source meta (locale, models_url, vendors_url) in success payloads. Notes - No breaking changes expected. - Lint passes for touched files.
2025-09-02 18:49:37 +08:00
const handleSyncUpstream = async (locale) => {
✨ feat(models-sync): official upstream sync with conflict resolution UI, opt‑out flag, and backend resiliency Backend - Add endpoints: - GET /api/models/sync_upstream/preview — diff preview (filters out models with sync_official = 0) - POST /api/models/sync_upstream — apply sync (create missing; optionally overwrite selected fields) - Respect opt‑out: skip models with sync_official = 0 in both preview and apply - Return detailed stats: created_models, created_vendors, updated_models, skipped_models, plus created_list / updated_list - Add model.Model.SyncOfficial (default 1); auto‑migrated by GORM - Make HTTP fetching robust: - Shared http.Client (connection reuse) with 3x exponential backoff retry - 10MB response cap; keep existing IPv4‑first for *.github.io - Vendor handling: - New ensureVendorID helper (cache lookup → DB lookup → create), reduces round‑trips - Transactional overwrite to avoid partial updates - Small cleanups and clearer helpers (containsField, coalesce, chooseStatus) Frontend - ModelsActions: add “Sync official” button with Popover (p‑2) explaining community contribution; loading = syncing || previewing; preview → conflict modal → apply flow - New UpstreamConflictModal: - Per‑field columns (description/icon/tags/vendor/name_rule/status) with column‑level checkbox to select all - Cell with Checkbox + Tag (“Click to view differences”) and Popover (p‑2) showing Local vs Official values - Auto‑hide columns with no conflicts; responsive width; use native Semi Modal footer - Full i18n coverage - useModelsData: add syncing/previewing states; new methods previewUpstreamDiff, applyUpstreamOverwrite, syncUpstream; refresh vendors/models after apply - EditModelModal: add “Participate in official sync” switch; persisted as sync_official - ModelsColumnDefs: add “Participate in official sync” column i18n - Add missing English keys for the new UI and messages; fix quoting issues Refs - Upstream metadata: https://github.com/basellm/llm-metadata
2025-09-02 02:04:22 +08:00
// 先预览
✨ feat(sync): multi-language sync wizard, backend locale support, and conflict modal UX improvements Frontend (web) - ModelsActions.jsx - Replace “Sync Official” with “Sync” and open a new two-step SyncWizard. - Pass selected locale through to preview, sync, and overwrite flows. - Keep conflict resolution flow; inject locale into overwrite submission. - New: models/modals/SyncWizardModal.jsx - Two-step wizard: (1) method selection (config-sync disabled for now), (2) language selection (en/zh/ja). - Horizontal, centered Radio cards; returns { option, locale } via onConfirm. - UpstreamConflictModal.jsx - Add search input (model fuzzy search) and native pagination. - Column header checkbox now only applies to rows in the current filtered result. - Fix “Cannot access ‘filteredDataSource’ before initialization”. - Refactor with useMemo/useCallback; extract helpers to remove duplicated logic: - getPresentRowsForField, getHeaderState, applyHeaderChange - Minor code cleanups and stability improvements. - i18n (en.json) - Add strings for the sync wizard and related actions (Sync, Sync Wizard, Select method/source/language, etc.). - Adjust minor translations. Hooks - useModelsData.jsx - Extend previewUpstreamDiff, syncUpstream, applyUpstreamOverwrite to accept options with locale. - Send locale via query/body accordingly. Backend (Go) - controller/model_sync.go - Accept locale from query/body and resolve i18n upstream URLs. - Add SYNC_UPSTREAM_BASE for upstream base override (default: https://basellm.github.io/llm-metadata). - Make HTTP timeouts/retries/limits configurable: - SYNC_HTTP_TIMEOUT_SECONDS, SYNC_HTTP_RETRY, SYNC_HTTP_MAX_MB - Add ETag-based caching and support both envelope and pure array JSON formats. - Concurrently fetch vendors and models; improve error responses with locale and source URLs. - Include source meta (locale, models_url, vendors_url) in success payloads. Notes - No breaking changes expected. - Lint passes for touched files.
2025-09-02 18:49:37 +08:00
const data = await previewUpstreamDiff?.({ locale });
✨ feat(models-sync): official upstream sync with conflict resolution UI, opt‑out flag, and backend resiliency Backend - Add endpoints: - GET /api/models/sync_upstream/preview — diff preview (filters out models with sync_official = 0) - POST /api/models/sync_upstream — apply sync (create missing; optionally overwrite selected fields) - Respect opt‑out: skip models with sync_official = 0 in both preview and apply - Return detailed stats: created_models, created_vendors, updated_models, skipped_models, plus created_list / updated_list - Add model.Model.SyncOfficial (default 1); auto‑migrated by GORM - Make HTTP fetching robust: - Shared http.Client (connection reuse) with 3x exponential backoff retry - 10MB response cap; keep existing IPv4‑first for *.github.io - Vendor handling: - New ensureVendorID helper (cache lookup → DB lookup → create), reduces round‑trips - Transactional overwrite to avoid partial updates - Small cleanups and clearer helpers (containsField, coalesce, chooseStatus) Frontend - ModelsActions: add “Sync official” button with Popover (p‑2) explaining community contribution; loading = syncing || previewing; preview → conflict modal → apply flow - New UpstreamConflictModal: - Per‑field columns (description/icon/tags/vendor/name_rule/status) with column‑level checkbox to select all - Cell with Checkbox + Tag (“Click to view differences”) and Popover (p‑2) showing Local vs Official values - Auto‑hide columns with no conflicts; responsive width; use native Semi Modal footer - Full i18n coverage - useModelsData: add syncing/previewing states; new methods previewUpstreamDiff, applyUpstreamOverwrite, syncUpstream; refresh vendors/models after apply - EditModelModal: add “Participate in official sync” switch; persisted as sync_official - ModelsColumnDefs: add “Participate in official sync” column i18n - Add missing English keys for the new UI and messages; fix quoting issues Refs - Upstream metadata: https://github.com/basellm/llm-metadata
2025-09-02 02:04:22 +08:00
const conflictItems = data?.conflicts || [];
if (conflictItems.length > 0) {
setConflicts(conflictItems);
setShowConflict(true);
return;
}
// 无冲突,直接同步缺失
✨ feat(sync): multi-language sync wizard, backend locale support, and conflict modal UX improvements Frontend (web) - ModelsActions.jsx - Replace “Sync Official” with “Sync” and open a new two-step SyncWizard. - Pass selected locale through to preview, sync, and overwrite flows. - Keep conflict resolution flow; inject locale into overwrite submission. - New: models/modals/SyncWizardModal.jsx - Two-step wizard: (1) method selection (config-sync disabled for now), (2) language selection (en/zh/ja). - Horizontal, centered Radio cards; returns { option, locale } via onConfirm. - UpstreamConflictModal.jsx - Add search input (model fuzzy search) and native pagination. - Column header checkbox now only applies to rows in the current filtered result. - Fix “Cannot access ‘filteredDataSource’ before initialization”. - Refactor with useMemo/useCallback; extract helpers to remove duplicated logic: - getPresentRowsForField, getHeaderState, applyHeaderChange - Minor code cleanups and stability improvements. - i18n (en.json) - Add strings for the sync wizard and related actions (Sync, Sync Wizard, Select method/source/language, etc.). - Adjust minor translations. Hooks - useModelsData.jsx - Extend previewUpstreamDiff, syncUpstream, applyUpstreamOverwrite to accept options with locale. - Send locale via query/body accordingly. Backend (Go) - controller/model_sync.go - Accept locale from query/body and resolve i18n upstream URLs. - Add SYNC_UPSTREAM_BASE for upstream base override (default: https://basellm.github.io/llm-metadata). - Make HTTP timeouts/retries/limits configurable: - SYNC_HTTP_TIMEOUT_SECONDS, SYNC_HTTP_RETRY, SYNC_HTTP_MAX_MB - Add ETag-based caching and support both envelope and pure array JSON formats. - Concurrently fetch vendors and models; improve error responses with locale and source URLs. - Include source meta (locale, models_url, vendors_url) in success payloads. Notes - No breaking changes expected. - Lint passes for touched files.
2025-09-02 18:49:37 +08:00
await syncUpstream?.({ locale });
✨ feat(models-sync): official upstream sync with conflict resolution UI, opt‑out flag, and backend resiliency Backend - Add endpoints: - GET /api/models/sync_upstream/preview — diff preview (filters out models with sync_official = 0) - POST /api/models/sync_upstream — apply sync (create missing; optionally overwrite selected fields) - Respect opt‑out: skip models with sync_official = 0 in both preview and apply - Return detailed stats: created_models, created_vendors, updated_models, skipped_models, plus created_list / updated_list - Add model.Model.SyncOfficial (default 1); auto‑migrated by GORM - Make HTTP fetching robust: - Shared http.Client (connection reuse) with 3x exponential backoff retry - 10MB response cap; keep existing IPv4‑first for *.github.io - Vendor handling: - New ensureVendorID helper (cache lookup → DB lookup → create), reduces round‑trips - Transactional overwrite to avoid partial updates - Small cleanups and clearer helpers (containsField, coalesce, chooseStatus) Frontend - ModelsActions: add “Sync official” button with Popover (p‑2) explaining community contribution; loading = syncing || previewing; preview → conflict modal → apply flow - New UpstreamConflictModal: - Per‑field columns (description/icon/tags/vendor/name_rule/status) with column‑level checkbox to select all - Cell with Checkbox + Tag (“Click to view differences”) and Popover (p‑2) showing Local vs Official values - Auto‑hide columns with no conflicts; responsive width; use native Semi Modal footer - Full i18n coverage - useModelsData: add syncing/previewing states; new methods previewUpstreamDiff, applyUpstreamOverwrite, syncUpstream; refresh vendors/models after apply - EditModelModal: add “Participate in official sync” switch; persisted as sync_official - ModelsColumnDefs: add “Participate in official sync” column i18n - Add missing English keys for the new UI and messages; fix quoting issues Refs - Upstream metadata: https://github.com/basellm/llm-metadata
2025-09-02 02:04:22 +08:00
};
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements Backend • Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps • Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go` • Auto-migrate new tables in DB startup logic Frontend • Build complete “Model Management” module under `/console/models` - New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs - Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile` • Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature • Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes Table UX improvements • Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style) • Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags • Color all tags deterministically using `stringToColor` for consistent theming • Change vendor column tag color to white for better contrast Misc • Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
// Handle delete selected models with confirmation
const handleDeleteSelectedModels = () => {
setShowDeleteModal(true);
};
// Handle delete confirmation
const handleConfirmDelete = () => {
batchDeleteModels();
setShowDeleteModal(false);
};
// Handle clear selection
const handleClearSelected = () => {
setSelectedKeys([]);
};
// Handle add selected models to prefill group
const handleCopyNames = async () => {
const text = selectedKeys.map((m) => m.model_name).join(',');
if (!text) return;
const ok = await copy(text);
if (ok) {
showSuccess(t('已复制模型名称'));
} else {
showError(t('复制失败'));
}
};
const handleAddToPrefill = () => {
// Prepare initial data
const items = selectedKeys.map((m) => m.model_name);
setPrefillInit({ id: undefined, type: 'model', items });
setShowAddPrefill(true);
};
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements Backend • Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps • Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go` • Auto-migrate new tables in DB startup logic Frontend • Build complete “Model Management” module under `/console/models` - New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs - Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile` • Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature • Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes Table UX improvements • Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style) • Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags • Color all tags deterministically using `stringToColor` for consistent theming • Change vendor column tag color to white for better contrast Misc • Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
return (
<>
<div className='flex flex-wrap gap-2 w-full md:w-auto order-2 md:order-1'>
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements Backend • Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps • Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go` • Auto-migrate new tables in DB startup logic Frontend • Build complete “Model Management” module under `/console/models` - New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs - Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile` • Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature • Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes Table UX improvements • Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style) • Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags • Color all tags deterministically using `stringToColor` for consistent theming • Change vendor column tag color to white for better contrast Misc • Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
<Button
type='primary'
className='flex-1 md:flex-initial'
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements Backend • Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps • Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go` • Auto-migrate new tables in DB startup logic Frontend • Build complete “Model Management” module under `/console/models` - New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs - Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile` • Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature • Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes Table UX improvements • Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style) • Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags • Color all tags deterministically using `stringToColor` for consistent theming • Change vendor column tag color to white for better contrast Misc • Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
onClick={() => {
setEditingModel({
id: undefined,
});
setShowEdit(true);
}}
size='small'
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements Backend • Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps • Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go` • Auto-migrate new tables in DB startup logic Frontend • Build complete “Model Management” module under `/console/models` - New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs - Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile` • Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature • Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes Table UX improvements • Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style) • Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags • Color all tags deterministically using `stringToColor` for consistent theming • Change vendor column tag color to white for better contrast Misc • Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
>
{t('添加模型')}
</Button>
<Button
type='secondary'
className='flex-1 md:flex-initial'
size='small'
onClick={() => setShowMissingModal(true)}
>
{t('未配置模型')}
</Button>
✨ feat(models-sync): official upstream sync with conflict resolution UI, opt‑out flag, and backend resiliency Backend - Add endpoints: - GET /api/models/sync_upstream/preview — diff preview (filters out models with sync_official = 0) - POST /api/models/sync_upstream — apply sync (create missing; optionally overwrite selected fields) - Respect opt‑out: skip models with sync_official = 0 in both preview and apply - Return detailed stats: created_models, created_vendors, updated_models, skipped_models, plus created_list / updated_list - Add model.Model.SyncOfficial (default 1); auto‑migrated by GORM - Make HTTP fetching robust: - Shared http.Client (connection reuse) with 3x exponential backoff retry - 10MB response cap; keep existing IPv4‑first for *.github.io - Vendor handling: - New ensureVendorID helper (cache lookup → DB lookup → create), reduces round‑trips - Transactional overwrite to avoid partial updates - Small cleanups and clearer helpers (containsField, coalesce, chooseStatus) Frontend - ModelsActions: add “Sync official” button with Popover (p‑2) explaining community contribution; loading = syncing || previewing; preview → conflict modal → apply flow - New UpstreamConflictModal: - Per‑field columns (description/icon/tags/vendor/name_rule/status) with column‑level checkbox to select all - Cell with Checkbox + Tag (“Click to view differences”) and Popover (p‑2) showing Local vs Official values - Auto‑hide columns with no conflicts; responsive width; use native Semi Modal footer - Full i18n coverage - useModelsData: add syncing/previewing states; new methods previewUpstreamDiff, applyUpstreamOverwrite, syncUpstream; refresh vendors/models after apply - EditModelModal: add “Participate in official sync” switch; persisted as sync_official - ModelsColumnDefs: add “Participate in official sync” column i18n - Add missing English keys for the new UI and messages; fix quoting issues Refs - Upstream metadata: https://github.com/basellm/llm-metadata
2025-09-02 02:04:22 +08:00
<Popover
position='bottom'
trigger='hover'
content={
<div className='p-2 max-w-[360px]'>
<div className='text-[var(--semi-color-text-2)] text-sm'>
{t(
'模型社区需要大家的共同维护,如发现数据有误或想贡献新的模型数据,请访问:',
)}
</div>
<a
href='https://github.com/basellm/llm-metadata'
target='_blank'
rel='noreferrer'
className='text-blue-600 underline'
>
https://github.com/basellm/llm-metadata
</a>
</div>
}
>
<Button
type='secondary'
className='flex-1 md:flex-initial'
size='small'
loading={syncing || previewing}
✨ feat(sync): multi-language sync wizard, backend locale support, and conflict modal UX improvements Frontend (web) - ModelsActions.jsx - Replace “Sync Official” with “Sync” and open a new two-step SyncWizard. - Pass selected locale through to preview, sync, and overwrite flows. - Keep conflict resolution flow; inject locale into overwrite submission. - New: models/modals/SyncWizardModal.jsx - Two-step wizard: (1) method selection (config-sync disabled for now), (2) language selection (en/zh/ja). - Horizontal, centered Radio cards; returns { option, locale } via onConfirm. - UpstreamConflictModal.jsx - Add search input (model fuzzy search) and native pagination. - Column header checkbox now only applies to rows in the current filtered result. - Fix “Cannot access ‘filteredDataSource’ before initialization”. - Refactor with useMemo/useCallback; extract helpers to remove duplicated logic: - getPresentRowsForField, getHeaderState, applyHeaderChange - Minor code cleanups and stability improvements. - i18n (en.json) - Add strings for the sync wizard and related actions (Sync, Sync Wizard, Select method/source/language, etc.). - Adjust minor translations. Hooks - useModelsData.jsx - Extend previewUpstreamDiff, syncUpstream, applyUpstreamOverwrite to accept options with locale. - Send locale via query/body accordingly. Backend (Go) - controller/model_sync.go - Accept locale from query/body and resolve i18n upstream URLs. - Add SYNC_UPSTREAM_BASE for upstream base override (default: https://basellm.github.io/llm-metadata). - Make HTTP timeouts/retries/limits configurable: - SYNC_HTTP_TIMEOUT_SECONDS, SYNC_HTTP_RETRY, SYNC_HTTP_MAX_MB - Add ETag-based caching and support both envelope and pure array JSON formats. - Concurrently fetch vendors and models; improve error responses with locale and source URLs. - Include source meta (locale, models_url, vendors_url) in success payloads. Notes - No breaking changes expected. - Lint passes for touched files.
2025-09-02 18:49:37 +08:00
onClick={() => {
setSyncLocale('zh');
setShowSyncModal(true);
}}
✨ feat(models-sync): official upstream sync with conflict resolution UI, opt‑out flag, and backend resiliency Backend - Add endpoints: - GET /api/models/sync_upstream/preview — diff preview (filters out models with sync_official = 0) - POST /api/models/sync_upstream — apply sync (create missing; optionally overwrite selected fields) - Respect opt‑out: skip models with sync_official = 0 in both preview and apply - Return detailed stats: created_models, created_vendors, updated_models, skipped_models, plus created_list / updated_list - Add model.Model.SyncOfficial (default 1); auto‑migrated by GORM - Make HTTP fetching robust: - Shared http.Client (connection reuse) with 3x exponential backoff retry - 10MB response cap; keep existing IPv4‑first for *.github.io - Vendor handling: - New ensureVendorID helper (cache lookup → DB lookup → create), reduces round‑trips - Transactional overwrite to avoid partial updates - Small cleanups and clearer helpers (containsField, coalesce, chooseStatus) Frontend - ModelsActions: add “Sync official” button with Popover (p‑2) explaining community contribution; loading = syncing || previewing; preview → conflict modal → apply flow - New UpstreamConflictModal: - Per‑field columns (description/icon/tags/vendor/name_rule/status) with column‑level checkbox to select all - Cell with Checkbox + Tag (“Click to view differences”) and Popover (p‑2) showing Local vs Official values - Auto‑hide columns with no conflicts; responsive width; use native Semi Modal footer - Full i18n coverage - useModelsData: add syncing/previewing states; new methods previewUpstreamDiff, applyUpstreamOverwrite, syncUpstream; refresh vendors/models after apply - EditModelModal: add “Participate in official sync” switch; persisted as sync_official - ModelsColumnDefs: add “Participate in official sync” column i18n - Add missing English keys for the new UI and messages; fix quoting issues Refs - Upstream metadata: https://github.com/basellm/llm-metadata
2025-09-02 02:04:22 +08:00
>
✨ feat(sync): multi-language sync wizard, backend locale support, and conflict modal UX improvements Frontend (web) - ModelsActions.jsx - Replace “Sync Official” with “Sync” and open a new two-step SyncWizard. - Pass selected locale through to preview, sync, and overwrite flows. - Keep conflict resolution flow; inject locale into overwrite submission. - New: models/modals/SyncWizardModal.jsx - Two-step wizard: (1) method selection (config-sync disabled for now), (2) language selection (en/zh/ja). - Horizontal, centered Radio cards; returns { option, locale } via onConfirm. - UpstreamConflictModal.jsx - Add search input (model fuzzy search) and native pagination. - Column header checkbox now only applies to rows in the current filtered result. - Fix “Cannot access ‘filteredDataSource’ before initialization”. - Refactor with useMemo/useCallback; extract helpers to remove duplicated logic: - getPresentRowsForField, getHeaderState, applyHeaderChange - Minor code cleanups and stability improvements. - i18n (en.json) - Add strings for the sync wizard and related actions (Sync, Sync Wizard, Select method/source/language, etc.). - Adjust minor translations. Hooks - useModelsData.jsx - Extend previewUpstreamDiff, syncUpstream, applyUpstreamOverwrite to accept options with locale. - Send locale via query/body accordingly. Backend (Go) - controller/model_sync.go - Accept locale from query/body and resolve i18n upstream URLs. - Add SYNC_UPSTREAM_BASE for upstream base override (default: https://basellm.github.io/llm-metadata). - Make HTTP timeouts/retries/limits configurable: - SYNC_HTTP_TIMEOUT_SECONDS, SYNC_HTTP_RETRY, SYNC_HTTP_MAX_MB - Add ETag-based caching and support both envelope and pure array JSON formats. - Concurrently fetch vendors and models; improve error responses with locale and source URLs. - Include source meta (locale, models_url, vendors_url) in success payloads. Notes - No breaking changes expected. - Lint passes for touched files.
2025-09-02 18:49:37 +08:00
{t('同步')}
✨ feat(models-sync): official upstream sync with conflict resolution UI, opt‑out flag, and backend resiliency Backend - Add endpoints: - GET /api/models/sync_upstream/preview — diff preview (filters out models with sync_official = 0) - POST /api/models/sync_upstream — apply sync (create missing; optionally overwrite selected fields) - Respect opt‑out: skip models with sync_official = 0 in both preview and apply - Return detailed stats: created_models, created_vendors, updated_models, skipped_models, plus created_list / updated_list - Add model.Model.SyncOfficial (default 1); auto‑migrated by GORM - Make HTTP fetching robust: - Shared http.Client (connection reuse) with 3x exponential backoff retry - 10MB response cap; keep existing IPv4‑first for *.github.io - Vendor handling: - New ensureVendorID helper (cache lookup → DB lookup → create), reduces round‑trips - Transactional overwrite to avoid partial updates - Small cleanups and clearer helpers (containsField, coalesce, chooseStatus) Frontend - ModelsActions: add “Sync official” button with Popover (p‑2) explaining community contribution; loading = syncing || previewing; preview → conflict modal → apply flow - New UpstreamConflictModal: - Per‑field columns (description/icon/tags/vendor/name_rule/status) with column‑level checkbox to select all - Cell with Checkbox + Tag (“Click to view differences”) and Popover (p‑2) showing Local vs Official values - Auto‑hide columns with no conflicts; responsive width; use native Semi Modal footer - Full i18n coverage - useModelsData: add syncing/previewing states; new methods previewUpstreamDiff, applyUpstreamOverwrite, syncUpstream; refresh vendors/models after apply - EditModelModal: add “Participate in official sync” switch; persisted as sync_official - ModelsColumnDefs: add “Participate in official sync” column i18n - Add missing English keys for the new UI and messages; fix quoting issues Refs - Upstream metadata: https://github.com/basellm/llm-metadata
2025-09-02 02:04:22 +08:00
</Button>
</Popover>
<Button
type='secondary'
className='flex-1 md:flex-initial'
size='small'
onClick={() => setShowGroupManagement(true)}
>
{t('预填组管理')}
</Button>
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements Backend • Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps • Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go` • Auto-migrate new tables in DB startup logic Frontend • Build complete “Model Management” module under `/console/models` - New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs - Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile` • Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature • Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes Table UX improvements • Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style) • Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags • Color all tags deterministically using `stringToColor` for consistent theming • Change vendor column tag color to white for better contrast Misc • Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
<CompactModeToggle
compactMode={compactMode}
setCompactMode={setCompactMode}
t={t}
/>
</div>
<SelectionNotification
selectedKeys={selectedKeys}
t={t}
onDelete={handleDeleteSelectedModels}
onAddPrefill={handleAddToPrefill}
onClear={handleClearSelected}
onCopy={handleCopyNames}
/>
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements Backend • Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps • Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go` • Auto-migrate new tables in DB startup logic Frontend • Build complete “Model Management” module under `/console/models` - New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs - Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile` • Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature • Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes Table UX improvements • Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style) • Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags • Color all tags deterministically using `stringToColor` for consistent theming • Change vendor column tag color to white for better contrast Misc • Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
<Modal
title={t('批量删除模型')}
visible={showDeleteModal}
onCancel={() => setShowDeleteModal(false)}
onOk={handleConfirmDelete}
type='warning'
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements Backend • Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps • Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go` • Auto-migrate new tables in DB startup logic Frontend • Build complete “Model Management” module under `/console/models` - New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs - Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile` • Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature • Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes Table UX improvements • Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style) • Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags • Color all tags deterministically using `stringToColor` for consistent theming • Change vendor column tag color to white for better contrast Misc • Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
>
<div>
{t('确定要删除所选的 {{count}} 个模型吗?', {
count: selectedKeys.length,
})}
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements Backend • Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps • Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go` • Auto-migrate new tables in DB startup logic Frontend • Build complete “Model Management” module under `/console/models` - New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs - Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile` • Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature • Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes Table UX improvements • Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style) • Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags • Color all tags deterministically using `stringToColor` for consistent theming • Change vendor column tag color to white for better contrast Misc • Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
</div>
</Modal>
✨ feat(sync): multi-language sync wizard, backend locale support, and conflict modal UX improvements Frontend (web) - ModelsActions.jsx - Replace “Sync Official” with “Sync” and open a new two-step SyncWizard. - Pass selected locale through to preview, sync, and overwrite flows. - Keep conflict resolution flow; inject locale into overwrite submission. - New: models/modals/SyncWizardModal.jsx - Two-step wizard: (1) method selection (config-sync disabled for now), (2) language selection (en/zh/ja). - Horizontal, centered Radio cards; returns { option, locale } via onConfirm. - UpstreamConflictModal.jsx - Add search input (model fuzzy search) and native pagination. - Column header checkbox now only applies to rows in the current filtered result. - Fix “Cannot access ‘filteredDataSource’ before initialization”. - Refactor with useMemo/useCallback; extract helpers to remove duplicated logic: - getPresentRowsForField, getHeaderState, applyHeaderChange - Minor code cleanups and stability improvements. - i18n (en.json) - Add strings for the sync wizard and related actions (Sync, Sync Wizard, Select method/source/language, etc.). - Adjust minor translations. Hooks - useModelsData.jsx - Extend previewUpstreamDiff, syncUpstream, applyUpstreamOverwrite to accept options with locale. - Send locale via query/body accordingly. Backend (Go) - controller/model_sync.go - Accept locale from query/body and resolve i18n upstream URLs. - Add SYNC_UPSTREAM_BASE for upstream base override (default: https://basellm.github.io/llm-metadata). - Make HTTP timeouts/retries/limits configurable: - SYNC_HTTP_TIMEOUT_SECONDS, SYNC_HTTP_RETRY, SYNC_HTTP_MAX_MB - Add ETag-based caching and support both envelope and pure array JSON formats. - Concurrently fetch vendors and models; improve error responses with locale and source URLs. - Include source meta (locale, models_url, vendors_url) in success payloads. Notes - No breaking changes expected. - Lint passes for touched files.
2025-09-02 18:49:37 +08:00
<SyncWizardModal
visible={showSyncModal}
onClose={() => setShowSyncModal(false)}
loading={syncing || previewing}
t={t}
onConfirm={async ({ option, locale }) => {
setSyncLocale(locale);
if (option === 'official') {
await handleSyncUpstream(locale);
}
setShowSyncModal(false);
}}
/>
<MissingModelsModal
visible={showMissingModal}
onClose={() => setShowMissingModal(false)}
onConfigureModel={(name) => {
setEditingModel({ id: undefined, model_name: name });
setShowEdit(true);
setShowMissingModal(false);
}}
t={t}
/>
<PrefillGroupManagement
visible={showGroupManagement}
onClose={() => setShowGroupManagement(false)}
/>
<EditPrefillGroupModal
visible={showAddPrefill}
onClose={() => setShowAddPrefill(false)}
editingGroup={prefillInit}
onSuccess={() => setShowAddPrefill(false)}
/>
✨ feat(models-sync): official upstream sync with conflict resolution UI, opt‑out flag, and backend resiliency Backend - Add endpoints: - GET /api/models/sync_upstream/preview — diff preview (filters out models with sync_official = 0) - POST /api/models/sync_upstream — apply sync (create missing; optionally overwrite selected fields) - Respect opt‑out: skip models with sync_official = 0 in both preview and apply - Return detailed stats: created_models, created_vendors, updated_models, skipped_models, plus created_list / updated_list - Add model.Model.SyncOfficial (default 1); auto‑migrated by GORM - Make HTTP fetching robust: - Shared http.Client (connection reuse) with 3x exponential backoff retry - 10MB response cap; keep existing IPv4‑first for *.github.io - Vendor handling: - New ensureVendorID helper (cache lookup → DB lookup → create), reduces round‑trips - Transactional overwrite to avoid partial updates - Small cleanups and clearer helpers (containsField, coalesce, chooseStatus) Frontend - ModelsActions: add “Sync official” button with Popover (p‑2) explaining community contribution; loading = syncing || previewing; preview → conflict modal → apply flow - New UpstreamConflictModal: - Per‑field columns (description/icon/tags/vendor/name_rule/status) with column‑level checkbox to select all - Cell with Checkbox + Tag (“Click to view differences”) and Popover (p‑2) showing Local vs Official values - Auto‑hide columns with no conflicts; responsive width; use native Semi Modal footer - Full i18n coverage - useModelsData: add syncing/previewing states; new methods previewUpstreamDiff, applyUpstreamOverwrite, syncUpstream; refresh vendors/models after apply - EditModelModal: add “Participate in official sync” switch; persisted as sync_official - ModelsColumnDefs: add “Participate in official sync” column i18n - Add missing English keys for the new UI and messages; fix quoting issues Refs - Upstream metadata: https://github.com/basellm/llm-metadata
2025-09-02 02:04:22 +08:00
<UpstreamConflictModal
visible={showConflict}
onClose={() => setShowConflict(false)}
conflicts={conflicts}
onSubmit={async (payload) => {
✨ feat(sync): multi-language sync wizard, backend locale support, and conflict modal UX improvements Frontend (web) - ModelsActions.jsx - Replace “Sync Official” with “Sync” and open a new two-step SyncWizard. - Pass selected locale through to preview, sync, and overwrite flows. - Keep conflict resolution flow; inject locale into overwrite submission. - New: models/modals/SyncWizardModal.jsx - Two-step wizard: (1) method selection (config-sync disabled for now), (2) language selection (en/zh/ja). - Horizontal, centered Radio cards; returns { option, locale } via onConfirm. - UpstreamConflictModal.jsx - Add search input (model fuzzy search) and native pagination. - Column header checkbox now only applies to rows in the current filtered result. - Fix “Cannot access ‘filteredDataSource’ before initialization”. - Refactor with useMemo/useCallback; extract helpers to remove duplicated logic: - getPresentRowsForField, getHeaderState, applyHeaderChange - Minor code cleanups and stability improvements. - i18n (en.json) - Add strings for the sync wizard and related actions (Sync, Sync Wizard, Select method/source/language, etc.). - Adjust minor translations. Hooks - useModelsData.jsx - Extend previewUpstreamDiff, syncUpstream, applyUpstreamOverwrite to accept options with locale. - Send locale via query/body accordingly. Backend (Go) - controller/model_sync.go - Accept locale from query/body and resolve i18n upstream URLs. - Add SYNC_UPSTREAM_BASE for upstream base override (default: https://basellm.github.io/llm-metadata). - Make HTTP timeouts/retries/limits configurable: - SYNC_HTTP_TIMEOUT_SECONDS, SYNC_HTTP_RETRY, SYNC_HTTP_MAX_MB - Add ETag-based caching and support both envelope and pure array JSON formats. - Concurrently fetch vendors and models; improve error responses with locale and source URLs. - Include source meta (locale, models_url, vendors_url) in success payloads. Notes - No breaking changes expected. - Lint passes for touched files.
2025-09-02 18:49:37 +08:00
return await applyUpstreamOverwrite?.({
overwrite: payload,
✨ feat(sync): multi-language sync wizard, backend locale support, and conflict modal UX improvements Frontend (web) - ModelsActions.jsx - Replace “Sync Official” with “Sync” and open a new two-step SyncWizard. - Pass selected locale through to preview, sync, and overwrite flows. - Keep conflict resolution flow; inject locale into overwrite submission. - New: models/modals/SyncWizardModal.jsx - Two-step wizard: (1) method selection (config-sync disabled for now), (2) language selection (en/zh/ja). - Horizontal, centered Radio cards; returns { option, locale } via onConfirm. - UpstreamConflictModal.jsx - Add search input (model fuzzy search) and native pagination. - Column header checkbox now only applies to rows in the current filtered result. - Fix “Cannot access ‘filteredDataSource’ before initialization”. - Refactor with useMemo/useCallback; extract helpers to remove duplicated logic: - getPresentRowsForField, getHeaderState, applyHeaderChange - Minor code cleanups and stability improvements. - i18n (en.json) - Add strings for the sync wizard and related actions (Sync, Sync Wizard, Select method/source/language, etc.). - Adjust minor translations. Hooks - useModelsData.jsx - Extend previewUpstreamDiff, syncUpstream, applyUpstreamOverwrite to accept options with locale. - Send locale via query/body accordingly. Backend (Go) - controller/model_sync.go - Accept locale from query/body and resolve i18n upstream URLs. - Add SYNC_UPSTREAM_BASE for upstream base override (default: https://basellm.github.io/llm-metadata). - Make HTTP timeouts/retries/limits configurable: - SYNC_HTTP_TIMEOUT_SECONDS, SYNC_HTTP_RETRY, SYNC_HTTP_MAX_MB - Add ETag-based caching and support both envelope and pure array JSON formats. - Concurrently fetch vendors and models; improve error responses with locale and source URLs. - Include source meta (locale, models_url, vendors_url) in success payloads. Notes - No breaking changes expected. - Lint passes for touched files.
2025-09-02 18:49:37 +08:00
locale: syncLocale,
});
✨ feat(models-sync): official upstream sync with conflict resolution UI, opt‑out flag, and backend resiliency Backend - Add endpoints: - GET /api/models/sync_upstream/preview — diff preview (filters out models with sync_official = 0) - POST /api/models/sync_upstream — apply sync (create missing; optionally overwrite selected fields) - Respect opt‑out: skip models with sync_official = 0 in both preview and apply - Return detailed stats: created_models, created_vendors, updated_models, skipped_models, plus created_list / updated_list - Add model.Model.SyncOfficial (default 1); auto‑migrated by GORM - Make HTTP fetching robust: - Shared http.Client (connection reuse) with 3x exponential backoff retry - 10MB response cap; keep existing IPv4‑first for *.github.io - Vendor handling: - New ensureVendorID helper (cache lookup → DB lookup → create), reduces round‑trips - Transactional overwrite to avoid partial updates - Small cleanups and clearer helpers (containsField, coalesce, chooseStatus) Frontend - ModelsActions: add “Sync official” button with Popover (p‑2) explaining community contribution; loading = syncing || previewing; preview → conflict modal → apply flow - New UpstreamConflictModal: - Per‑field columns (description/icon/tags/vendor/name_rule/status) with column‑level checkbox to select all - Cell with Checkbox + Tag (“Click to view differences”) and Popover (p‑2) showing Local vs Official values - Auto‑hide columns with no conflicts; responsive width; use native Semi Modal footer - Full i18n coverage - useModelsData: add syncing/previewing states; new methods previewUpstreamDiff, applyUpstreamOverwrite, syncUpstream; refresh vendors/models after apply - EditModelModal: add “Participate in official sync” switch; persisted as sync_official - ModelsColumnDefs: add “Participate in official sync” column i18n - Add missing English keys for the new UI and messages; fix quoting issues Refs - Upstream metadata: https://github.com/basellm/llm-metadata
2025-09-02 02:04:22 +08:00
}}
t={t}
loading={syncing}
/>
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements Backend • Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps • Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go` • Auto-migrate new tables in DB startup logic Frontend • Build complete “Model Management” module under `/console/models` - New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs - Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile` • Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature • Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes Table UX improvements • Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style) • Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags • Color all tags deterministically using `stringToColor` for consistent theming • Change vendor column tag color to white for better contrast Misc • Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
</>
);
};
export default ModelsActions;