Load excluded model list
(filename: str)
| 211 | |
| 212 | |
| 213 | def load_excluded_models(filename: str): |
| 214 | """Load excluded model list""" |
| 215 | from api_utils.server_state import state |
| 216 | |
| 217 | excluded_model_ids = getattr(state, "excluded_model_ids", set()) |
| 218 | excluded_file_path = os.path.join(os.path.dirname(__file__), "..", "..", filename) |
| 219 | try: |
| 220 | if os.path.exists(excluded_file_path): |
| 221 | with open(excluded_file_path, "r", encoding="utf-8") as f: |
| 222 | loaded_ids = {line.strip() for line in f if line.strip()} |
| 223 | if loaded_ids: |
| 224 | excluded_model_ids.update(loaded_ids) |
| 225 | state.excluded_model_ids = excluded_model_ids |
| 226 | logger.debug( |
| 227 | f"Loaded {len(loaded_ids)} models from '{filename}' into exclusion list" |
| 228 | ) |
| 229 | else: |
| 230 | logger.debug( |
| 231 | f"'{filename}' file is empty or contains no valid model IDs, exclusion list unchanged." |
| 232 | ) |
| 233 | else: |
| 234 | logger.debug( |
| 235 | f"Model exclusion list file '{filename}' not found, list is empty." |
| 236 | ) |
| 237 | except Exception as e: |
| 238 | logger.error( |
| 239 | f"Error loading excluded models from '{filename}': {e}", exc_info=True |
| 240 | ) |