From 24914d359bf8d8a47076aa1b573cc5533660f601 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Fri, 13 Mar 2026 01:45:24 -0700 Subject: [PATCH] fix: disable remote code loading for ai-assist model hint lookup --- studio/backend/utils/datasets/llm_assist.py | 7 ++++++- studio/backend/utils/models/model_config.py | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/studio/backend/utils/datasets/llm_assist.py b/studio/backend/utils/datasets/llm_assist.py index 398d73cdcc..c5892bfbc2 100644 --- a/studio/backend/utils/datasets/llm_assist.py +++ b/studio/backend/utils/datasets/llm_assist.py @@ -515,7 +515,12 @@ def _run_multi_pass_advisor( try: from utils.models.model_config import load_model_config - config = load_model_config(model_name, use_auth = True, token = hf_token) + config = load_model_config( + model_name, + use_auth = True, + token = hf_token, + trust_remote_code = False, + ) archs = getattr(config, "architectures", []) if archs and "Gemma3nForConditionalGeneration" in archs: is_gemma_3n = True diff --git a/studio/backend/utils/models/model_config.py b/studio/backend/utils/models/model_config.py index 960e263cb2..23ef9b2cbb 100644 --- a/studio/backend/utils/models/model_config.py +++ b/studio/backend/utils/models/model_config.py @@ -383,7 +383,10 @@ for canonical_file, model_names in MODEL_NAME_MAPPING.items(): def load_model_config( - model_name: str, use_auth: bool = False, token: Optional[str] = None + model_name: str, + use_auth: bool = False, + token: Optional[str] = None, + trust_remote_code: bool = True, ): """ Load model config with optional authentication control. @@ -392,18 +395,23 @@ def load_model_config( if token: # Explicit token provided - use it return AutoConfig.from_pretrained( - model_name, trust_remote_code = True, token = token + model_name, trust_remote_code = trust_remote_code, token = token ) if not use_auth: # Load without any authentication (for public model checks) with without_hf_auth(): return AutoConfig.from_pretrained( - model_name, trust_remote_code = True, token = None + model_name, + trust_remote_code = trust_remote_code, + token = None, ) # Use default authentication (cached tokens) - return AutoConfig.from_pretrained(model_name, trust_remote_code = True) + return AutoConfig.from_pretrained( + model_name, + trust_remote_code = trust_remote_code, + ) # VLM architecture suffixes and known VLM model_type values.