Validate the model and make sure it is a chat completion model :param model: the model object :return: the provider model id and properties
(model: Model)
| 16 | |
| 17 | |
| 18 | async def __validate_model(model: Model): |
| 19 | """ |
| 20 | Validate the model and make sure it is a chat completion model |
| 21 | :param model: the model object |
| 22 | :return: the provider model id and properties |
| 23 | """ |
| 24 | if not model.is_chat_completion(): |
| 25 | raise_http_error( |
| 26 | ErrorCode.REQUEST_VALIDATION_ERROR, |
| 27 | message=f"Model {model.model_id} is not a chat completion model.", |
| 28 | ) |
| 29 | |
| 30 | model_schema: ModelSchema = model.model_schema() |
| 31 | if model_schema is None or model_schema.type == ModelType.WILDCARD: |
| 32 | provider_model_id = model.provider_model_id |
| 33 | properties = model.properties |
| 34 | elif model.is_custom_host(): |
| 35 | provider_model_id = model_schema.provider_model_id |
| 36 | properties = model.properties |
| 37 | else: |
| 38 | provider_model_id = model_schema.provider_model_id |
| 39 | properties = model_schema.properties |
| 40 | |
| 41 | return provider_model_id, properties |
| 42 | |
| 43 | |
| 44 | async def chat_completion( |
no test coverage detected