MCPcopy Create free account
hub / github.com/modelscope/modelscope / external_engine_for_llm_checker

Function external_engine_for_llm_checker

modelscope/pipelines/builder.py:301–337  ·  view source on GitHub ↗
(model: Union[str, List[str], Model,
                                                 List[Model]],
                                    revision: Optional[str],
                                    kwargs: Dict[str, Any])

Source from the content-addressed store, hash-verified

299
300
301def external_engine_for_llm_checker(model: Union[str, List[str], Model,
302 List[Model]],
303 revision: Optional[str],
304 kwargs: Dict[str, Any]) -> Optional[str]:
305 from .nlp.llm_pipeline import ModelTypeHelper, LLMAdapterRegistry
306 from ..hub.check_model import get_model_id_from_cache
307 if isinstance(model, list):
308 model = model[0]
309 if not isinstance(model, str):
310 model = model.model_dir
311
312 llm_framework = kwargs.get('llm_framework', '')
313 if llm_framework == 'swift':
314 try:
315 from swift.model import get_model_info_meta
316 except ImportError:
317 from swift.llm import get_model_info_meta
318 # check if swift supports
319 if os.path.exists(model):
320 model_id = get_model_id_from_cache(model)
321 else:
322 model_id = model
323
324 try:
325 info = get_model_info_meta(model_id)
326 model_type = info[0].model_type
327 except Exception as e:
328 logger.warning(f'Cannot using llm_framework with {model_id}, '
329 f'ignoring llm_framework={llm_framework} : {e}')
330 model_type = None
331 if model_type:
332 return 'llm'
333
334 model_type = ModelTypeHelper.get(
335 model, revision, with_adapter=True, split='-', use_cache=True)
336 if LLMAdapterRegistry.contains(model_type):
337 return 'llm'
338
339
340def clear_llm_info(kwargs: Dict, pipeline_name: str):

Callers 1

pipelineFunction · 0.85

Calls 4

get_model_id_from_cacheFunction · 0.85
containsMethod · 0.80
getMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…