Get the ModelWrapper for the external model.
(config: InferenceModelConfig)
| 214 | |
| 215 | |
| 216 | async def get_external_model_wrapper(config: InferenceModelConfig) -> ModelWrapper: |
| 217 | """Get the ModelWrapper for the external model.""" |
| 218 | if config.engine_type != "external": |
| 219 | raise ValueError("This function is only for creating external model wrapper.") |
| 220 | api_address = os.environ.get(config.external_model_config.base_url_env) |
| 221 | api_address = api_address.rstrip("/") if api_address else None |
| 222 | api_key = os.environ.get(config.external_model_config.api_key_env, "EMPTY") |
| 223 | config.api_key = api_key |
| 224 | config.enable_openai_api = True |
| 225 | return ModelWrapper(models=[], config=config, api_address=api_address) |