MCPcopy Index your code
hub / github.com/TaskingAI/TaskingAI / __validate_model

Function __validate_model

backend/app/services/inference/chat_completion.py:18–41  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

16
17
18async 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
44async def chat_completion(

Callers 2

chat_completionFunction · 0.70
stream_chat_completionFunction · 0.70

Calls 4

raise_http_errorFunction · 0.90
is_chat_completionMethod · 0.80
model_schemaMethod · 0.80
is_custom_hostMethod · 0.80

Tested by

no test coverage detected