skill_examples

530 downloads 5 likes on ModelScope updated

Model card

智能体技能 Agent Skills

1. 简介

MS-Agent Skills项目是对 Anthropic Agent Skills协议的实现,旨在通过模块化、可复用的“技能”封装,提升智能体在复杂任务中的表现与适应性。

本仓库的skill文件来源于Anthropic Skills: https://github.com/anthropics/skills

更多内容请参考:


2. 智能体技能文件夹结构

skill-name/
├── SKILL.md              # Main skill definition           (Required)
├── reference.md          # Detailed reference material     (Optional)
├── LICENSE.txt           # License information             (Optional)
├── resources/            # Additional resources            (Optional)
│   ├── template.xlsx     # Example files
│   └── data.json         # Data files
└── scripts/              # Executable scripts              (Optional)
    ├── main.py           # Main implementation
    └── helper.py         # Helper functions

3. 下载

SDK下载

# Install ModelScope
pip install modelscope
# Using SDK
from modelscope import snapshot_download
model_dir = snapshot_download('ms-agent/skill_examples')

Git下载

#Git模型下载
git clone https://www.modelscope.cn/ms-agent/skill_examples.git

4. 使用方法

下面是一个实现流场粒子艺术生成的示例

pip install ms-agent -U
import os
from ms_agent.agent import create_agent_skill


def main():
    """
    Main function to create and run an agent with skills.
    """
    work_dir: str = './temp_workspace'
    # Refer to `https://github.com/modelscope/ms-agent/tree/main/projects/agent_skills/skills`
    skill_id_or_dir: str = 'ms-agent/skill_examples'
    use_sandbox: bool = True

    ## Configuration for ModelScope API-Inference, or set your own model with OpenAI API compatible format
    ## Free LLM API inference calls for ModelScope users, refer to [ModelScope API-Inference](https://modelscope.cn/docs/model-service/API-Inference/intro)
    model: str = 'Qwen/Qwen3-235B-A22B-Instruct-2507'
    api_key: str = 'xx-xx'  # For ModelScope users, refer to `https://modelscope.cn/my/myaccesstoken` to get your access token
    base_url: str = 'https://api-inference.modelscope.cn/v1/'

    agent = create_agent_skill(
        # Use a skill from ModelScope Hub by its ID. A list of IDs is also supported. e.g. `ms-agent/skill_examples`
        # To use local skills, provide the path to the directory, e.g., skills='./skills'
        # For more details on skill IDs, see: https://modelscope.cn/models/ms-agent/skill_examples
        skills=skill_id_or_dir,
        model=model,
        api_key=os.getenv('OPENAI_API_KEY', api_key),
        base_url=os.getenv('OPENAI_BASE_URL', base_url),
        stream=True,
        # Note: Make sure the `Docker Daemon` is running if use_sandbox=True
        use_sandbox=use_sandbox,
        work_dir=work_dir,
    )

    user_query: str = ('Create generative art using p5.js with seeded randomness, flow fields, and particle systems, '
                       'please fill in the details and provide the complete code based on the templates.')

    response = agent.run(query=user_query)
    print(f'\n\n** Agent skill results: {response}\n')


if __name__ == '__main__':

    main()
  • skill_id_or_dir: 支持传入本地技能目录路径,或从ModelScope Hub加载技能ID。
    • skill_id_or_dir (str): 示例: 'path/to/skill-directory', 'ms-agent/skill_examples', 'ma-agent/skill_examples/pdf' (格式为 owner/skill_name or owner/skill_name/subfolder)
    • 参考 AgentSkillExamples
  • 本地执行

    • 若 use_sandbox=False,技能脚本将在本地环境中直接执行
    • 请确保您信任该技能脚本,以避免潜在的安全风险
    • 请确保本地 Python 环境中已安装脚本所需的全部依赖项
  • 沙箱执行

    • 若 use_sandbox=True,技能脚本将通过 ms-enclave 在隔离的 Docker 容器中执行
    • 该方式提供安全的执行环境,可有效防止对宿主系统造成潜在危害
    • 请确保您的机器上已安装 Docker,并且 Docker 服务(Docker Daemon)正在运行
    • 沙箱环境将根据技能声明的依赖项自动安装所需依赖,无需手动配置

5. MS-Agent项目

GitHub: https://github.com/modelscope/ms-agent