/*
 *  Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

import { LLMFactory } from '@/constants/llm';

/**
 * Provider factories that opt into the "List Models" picker UI.
 *
 * For these factories, the modal hides the traditional model_name,
 * model_type, max_tokens, and is_tools form fields and instead shows a
 * "List Models" button that fetches available models from the provider's
 * `/providers/<factory>/models` endpoint. The user can multi-select models
 * from the response; each selected model is converted to an `IModelInfo`
 * entry and submitted as `model_info`.
 *
 * For all other factories the picker is hidden and the form renders the
 * 4 model_* fields directly.
 */
export const LIST_MODEL_PROVIDERS = new Set<string>([
  // aimlapi.com serves its full /v1/models catalog (700+) via the AIMLAPI
  // ModelMeta on the backend, so the dialog uses the list picker (mirror of
  // that registry) instead of a single manual model_name field.
  LLMFactory.AIMLAPI,
  LLMFactory.Ollama,
  LLMFactory.OpenRouter,
  LLMFactory.VLLM,
  LLMFactory.OpenAiAPICompatible,
  LLMFactory.LMStudio,
  LLMFactory.VolcEngine,
  LLMFactory.Xinference,
  LLMFactory.LocalAI,
  LLMFactory.FunASR,
  LLMFactory.BaiduYiYan,
  LLMFactory.NewAPI,
  LLMFactory.RAGcon,
  LLMFactory.SoMark,

  // LLMFactory.HuggingFace,
  // LLMFactory.GoogleCloud,
  // LLMFactory.TencentCloud,
  // LLMFactory.XunFeiSpark,
  // LLMFactory.GPUStack,
  // LLMFactory.FishAudio,
  // LLMFactory.MinerU,
  // LLMFactory.PaddleOCR,
]);

/**
 * The set of form-field names that are owned by the list-models picker
 * (not registered in the dynamic form when the picker is active).
 *
 * Doubles as the whitelist of fields that remain editable in viewMode —
 * in viewMode every other field is disabled so only model-related edits
 * are possible.
 */
export const LIST_MODEL_FIELD_NAMES = new Set<string>([
  'model_name',
  'model_type',
  'max_tokens',
  'is_tools',
]);
