From 9738a53f49fae5386455179ec52170682b4ef908 Mon Sep 17 00:00:00 2001 From: sususu98 Date: Wed, 18 Mar 2026 10:48:03 +0800 Subject: [PATCH] feat: add -local-model flag to skip remote model catalog fetching When enabled, the server uses only the embedded models.json loaded at init() and skips registry.StartModelsUpdater(), disabling the initial remote fetch and 3-hour periodic refresh. The management panel auto-updater (managementasset.StartAutoUpdater) is unaffected. --- cmd/server/main.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index 3d9ee6cf..e12e5261 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -74,6 +74,7 @@ func main() { var password string var tuiMode bool var standalone bool + var localModel bool // Define command-line flags for different operation modes. flag.BoolVar(&login, "login", false, "Login Google Account") @@ -93,6 +94,7 @@ func main() { flag.StringVar(&password, "password", "", "") flag.BoolVar(&tuiMode, "tui", false, "Start with terminal management UI") flag.BoolVar(&standalone, "standalone", false, "In TUI mode, start an embedded local server") + flag.BoolVar(&localModel, "local-model", false, "Use embedded model catalog only, skip remote model fetching") flag.CommandLine.Usage = func() { out := flag.CommandLine.Output() @@ -491,11 +493,16 @@ func main() { cmd.WaitForCloudDeploy() return } + if localModel && (!tuiMode || standalone) { + log.Info("Local model mode: using embedded model catalog, remote model updates disabled") + } if tuiMode { if standalone { // Standalone mode: start an embedded local server and connect TUI client to it. managementasset.StartAutoUpdater(context.Background(), configFilePath) - registry.StartModelsUpdater(context.Background()) + if !localModel { + registry.StartModelsUpdater(context.Background()) + } hook := tui.NewLogHook(2000) hook.SetFormatter(&logging.LogFormatter{}) log.AddHook(hook) @@ -568,7 +575,9 @@ func main() { } else { // Start the main proxy service managementasset.StartAutoUpdater(context.Background(), configFilePath) - registry.StartModelsUpdater(context.Background()) + if !localModel { + registry.StartModelsUpdater(context.Background()) + } cmd.StartService(cfg, configFilePath, password) } }