default (Model Selector)
What it is
- A small utility module that selects and returns the default
ChatModelto use based on runtime configuration and availability of an OpenAI API key.
Public API
get_model() -> ChatModel- Returns a
ChatModelinstance:- Uses the airgapped Qwen model when
ai_mode == "airgap"or when no OpenAI API key is configured. - Otherwise uses the cloud ChatGPT model (
gpt_4_1_mini).
- Uses the airgapped Qwen model when
- Returns a
Configuration/Dependencies
- Reads configuration via:
ABIModule.get_instance().configuration.global_config.ai_mode("cloud" | "local" | "airgap")naas_abi_marketplace.ai.chatgpt.ABIModule.get_instance().configuration.openai_api_key
- Imports models lazily (at call time):
naas_abi.models.airgap_qwen.modelnaas_abi_marketplace.ai.chatgpt.models.gpt_4_1_mini.model
Usage
from naas_abi.models.default import get_model
model = get_model()
print(type(model))
Caveats
- If
ai_modeis not"airgap"but the OpenAI API key is missing/empty, the function will still force the airgapped model. - Selection depends on
ABIModule.get_instance()being properly initialized and configured at runtime.