nlpmed_engine.utils package¶
Submodules¶
nlpmed_engine.utils.utils module¶
- class nlpmed_engine.utils.utils.ModelSpec¶
Bases:
TypedDict- device: str¶
- max_length: int¶
- model_path: str¶
- tokenizer_path: str¶
- nlpmed_engine.utils.utils.build_initial_config() dict[str, Any]¶
Build the full pipeline config dict, including ml_inference models block. The first model name in API_ML_MODEL_NAMES will be treated as the default at runtime.
- Returns:
dict[str, Any]: The configuration dictionary for the engine.
- nlpmed_engine.utils.utils.get_effective_param(instance_value: Any, provided_value: Any, *, required: bool = True) Any¶
- nlpmed_engine.utils.utils.read_models_from_env() dict[str, ModelSpec]¶
Read model configurations from environment variables.
- Raises:
RuntimeError – If a configured model is missing its model or tokenizer path.
- Returns:
Model specifications keyed by configured model name.
- Return type:
dict[str, ModelSpec]
Example return structure:
{ "modelA": { "device": "cpu", "model_path": "...", "tokenizer_path": "...", "max_length": 512, }, "modelB": { "device": "cpu", "model_path": "...", "tokenizer_path": "...", "max_length": 1024, }, }