实现行为树执行器、任务协调和技能接口
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
"""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
|
||||
Reference in New Issue
Block a user