"""Adapter for the inference(prompt, image, task=...) API shown in module DR. loader is a deployment-pinned callable returning the already loaded model. No guessed vendor import, checkpoint download, remote code execution flag or CUDA map. """ import importlib def create(config): module,name=config['loader'].split(':',1) model=getattr(importlib.import_module(module),name)(config['model']) def infer(request): capability=request['capability'] task=config.get('task_mapping',{}).get(capability) if task is None:raise ValueError('capability has no validated model task mapping') image=request.get('observation',{}).get('image_path') return model.inference(request['prompt'],image,task=task,do_sample=False) return infer