MCPcopy Create free account
hub / github.com/modelscope/ms-agent / execute

Method execute

ms_agent/skill/container.py:1343–1390  ·  view source on GitHub ↗

Unified async execution interface. Args: executor_type: Type of executor to use. skill_id: Identifier of the skill. script_path: Path to script file (for PYTHON_SCRIPT, JAVASCRIPT). func: Callable function (for PYTHON_FUNCTION).

(self,
                      executor_type: ExecutorType,
                      skill_id: str = 'unknown',
                      script_path: Union[str, Path] = None,
                      func: Callable = None,
                      command: Union[str, List[str]] = None,
                      code: str = None,
                      input_spec: ExecutionInput = None,
                      **kwargs)

Source from the content-addressed store, hash-verified

1341 return '\n'.join(lines)
1342
1343 async def execute(self,
1344 executor_type: ExecutorType,
1345 skill_id: str = 'unknown',
1346 script_path: Union[str, Path] = None,
1347 func: Callable = None,
1348 command: Union[str, List[str]] = None,
1349 code: str = None,
1350 input_spec: ExecutionInput = None,
1351 **kwargs) -> ExecutionOutput:
1352 """
1353 Unified async execution interface.
1354
1355 Args:
1356 executor_type: Type of executor to use.
1357 skill_id: Identifier of the skill.
1358 script_path: Path to script file (for PYTHON_SCRIPT, JAVASCRIPT).
1359 func: Callable function (for PYTHON_FUNCTION).
1360 command: Shell command (for SHELL).
1361 code: Inline code (for PYTHON_CODE, JAVASCRIPT).
1362 input_spec: Input specification.
1363 **kwargs: Additional executor-specific arguments.
1364
1365 Returns:
1366 ExecutionOutput with results.
1367 """
1368 if executor_type == ExecutorType.PYTHON_SCRIPT:
1369 return await self.execute_python_script(
1370 script_path=script_path,
1371 skill_id=skill_id,
1372 input_spec=input_spec)
1373 elif executor_type == ExecutorType.PYTHON_CODE:
1374 return await self.execute_python_code(
1375 code=code, skill_id=skill_id, input_spec=input_spec)
1376 elif executor_type == ExecutorType.PYTHON_FUNCTION:
1377 return self.execute_python_function(
1378 func=func, skill_id=skill_id, input_spec=input_spec)
1379 elif executor_type == ExecutorType.SHELL:
1380 return await self.execute_shell(
1381 command=command, skill_id=skill_id, input_spec=input_spec)
1382 elif executor_type == ExecutorType.JAVASCRIPT:
1383 return await self.execute_javascript(
1384 script_path=script_path,
1385 code=code,
1386 skill_id=skill_id,
1387 input_spec=input_spec,
1388 **kwargs)
1389 else:
1390 raise ValueError(f'Unsupported executor type: {executor_type}')
1391
1392 def execute_sync(self,
1393 executor_type: ExecutorType,

Callers 1

execute_syncMethod · 0.95

Calls 5

execute_python_scriptMethod · 0.95
execute_python_codeMethod · 0.95
execute_shellMethod · 0.95
execute_javascriptMethod · 0.95

Tested by

no test coverage detected